Hokuyo laser and Kuka's YouBot (C++)

Typically: "How do I... ", "How can I... " questions
Post Reply
jegovila
Posts: 6
Joined: 19 May 2013, 00:06

Hokuyo laser and Kuka's YouBot (C++)

Post by jegovila » 15 Jul 2013, 22:06

Hello

I control the YouBot's omnidirectional wheels with a client in C++, but now I want to add a laser to my application.

I am using the Hokuyo Laser as a child of the Kuka's YouBot but when I call the function:

Code: Select all

result=simLaunchExecutable('Client',portNb.." "..wheelJoints[1].." "..wheelJoints[2].." "..wheelJoints[3].." "..wheelJoints[4].." "..laserHandle,0)
I have the next error:
Lua runtime error: [string "SCRIPT youBot#0"]:85: attempt to concatenate global 'laserHandle' (a nil value)

And if I try to use the initialization instructions on the child script from Hokuyo:

Code: Select all

laserScannerHandle=simGetObjectHandle("Hokuyo_URG_04LX_UG01")
laserScannerObjectName=simGetObjectName(laserScannerHandle) 
communicationTube=simTubeOpen(0,laserScannerObjectName..'_HOKUYO',1)
I Have the next error:
Lua call error: [string "SCRIPT youBot#0"]:15: Object does not exist. (simGetObjectHandle)
Lua call error: [string "SCRIPT youBot#0"]:16: Object does not exist. (simGetObjectName)
Lua runtime error: [string "SCRIPT youBot#0"]:17: attempt to concatenate global 'laserScannerObjectName' (a nil value)


I did not change the Hokuyo's script.
The YouBot script is non-threaded, could this be the problem?
How can I send the laser as an argument to my client?}

Thanks!

coppelia
Site Admin
Posts: 7150
Joined: 14 Dec 2012, 00:25

Re: Hokuyo laser and Kuka's YouBot (C++)

Post by coppelia » 15 Jul 2013, 22:35

Hello,

I suspect that you didn't understand how object handles are retrieved from a child script in V-REP. Have also a look at this post.

As a simple example, suppose that:
  • Your Hokuyo model name is Hokuyo_URG_O4LX_UG01#3
  • Your YouBot model name is YouBot
  • You have a child script associated with object Hokuyo_URG_O4LX_UG01#3
  • You have a child script associated with object YouBot
Then, you have to retrieve handles like that:

From the child script associated with object Hokuyo_URG_O4LX_UG01#3 you can retrieve:
  • the handle of Hokuyo_URG_O4LX_UG01#3 with simGetObjectHandle('Hokuyo_URG_O4LX_UG01'), or
  • the handle of Hokuyo_URG_O4LX_UG01#3 with simGetObjectHandle('Hokuyo_URG_O4LX_UG01#3'), or <-- explicit naming
  • the handle of Hokuyo_URG_O4LX_UG01#3 with simGetObjectAssociatedWithScript(sim_handle_self)
  • the handle of YouBot with simGetObjectHandle('YouBot#') <-- explicit naming

From the child script associated with object YouBot you can retrieve:
  • the handle of YouBot with simGetObjectHandle('YouBot'), or
  • the handle of YouBot with simGetObjectHandle(YouBot#'), or <-- explicit naming
  • the handle of YouBot with simGetObjectAssociatedWithScript(sim_handle_self)
  • the handle of Hokuyo_URG_O4LX_UG01#3 with simGetObjectHandle('Hokuyo_URG_O4LX_UG01#3') <-- explicit naming
Basically the child script will automatically append a name suffix that matches the child script's name suffix. This mechanism is very powerfull, since it allows to copy and paste a same robot many times, without having to adjust its child script code.

Cheers

Post Reply