assigning of coordinates

Typically: "How do I... ", "How can I... " questions
Post Reply
shami1996
Posts: 4
Joined: 02 Dec 2017, 19:37

assigning of coordinates

Post by shami1996 » 05 Dec 2017, 11:43

how can i assign the coordinates of one robot to the 2nd robot, please write an example.

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

Re: assigning of coordinates

Post by coppelia » 05 Dec 2017, 22:33

If you have static objects, you can do something like:

Code: Select all

simSetObjectPosition(object2Handle,object1Handle,{0,0,0})
simSetObjectOrientation(object2Handle,object1Handle,{0,0,0})
But a robot is usually dynamic and you cannot simply teleport it. So you would read the position of robot1, and control the motors of robot2 to slowly drive towards the read position.

Cheers

shami1996
Posts: 4
Joined: 02 Dec 2017, 19:37

Re: assigning of coordinates

Post by shami1996 » 06 Dec 2017, 16:38

but what if the two robots are not statics but moving in an environment, then how can one robot send its coordinates to other robot.

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

Re: assigning of coordinates

Post by coppelia » 09 Dec 2017, 17:56

You can send coordinates as you would send other type of information. The simplest would be to pack the coordinates inside of a string signal. e.g.:

In robot1:

Code: Select all

local p=simGetObjectPosition(modelHandle,-1)
local e=simGetObjectOrientation(modelHandle,-1)
local str=simPackFloatTable({p[1],p[2],p[3],e[1],e[2],e[3]})
simSetStringSignal('robot1PositionAndOrientation',str)
In robot2:

Code: Select all

local str=simGetStringSignal('robot1PositionAndOrientation')
if str then
    local data=simUnpackFloatTable(str)
    local p={data[1],data[2],data[3]}
    local e={data[4],data[5],data[6]}
end
Cheers

shami1996
Posts: 4
Joined: 02 Dec 2017, 19:37

Re: assigning of coordinates

Post by shami1996 » 10 Dec 2017, 17:53

i have added this in my python program but this is not showing or printing the coordinates recieved.
please guide me for python language

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

Re: assigning of coordinates

Post by coppelia » 10 Dec 2017, 21:58

You need to do some work on your own. Have a look at the many examples that come with V-REP (scenes, model, and also python demo scripts in programming/remoteApiBindings/python

Cheers

shami1996
Posts: 4
Joined: 02 Dec 2017, 19:37

Re: assigning of coordinates

Post by shami1996 » 15 Dec 2017, 18:30

kindly write lua script of v-rep for receiving data from python.

Post Reply