## Cant find Pathplanning in CoppeliaSim

Typically: "How do I... ", "How can I... " questions
anish
Posts: 12
Joined: 27 Jan 2020, 14:15

### Cant find Pathplanning in CoppeliaSim

Hai,

I tried to use the path planning feature by checking in Calculation modules. But there appears to be not an option for the same. Do I need to add this OMPLplugin additionally after downloading CoppeliaSim?

Actually I want a dummy to follow a path I created. but when I run the simulation the dummy is not moving at all. (The dummy is set as a child of the path.)

coppelia
Posts: 7597
Joined: 14 Dec 2012, 00:25

### Re: Cant find Pathplanning in CoppeliaSim

Hello,

the OMPL plugin should be loaded by CoppeliaSim, by default.
But to have a dummy object follow a path, I don't see any need for path planning. All you want to do is move your dummy in each simulation from a bit further along the path. Correct?
The easiest is to take care of this yourself with following API functions:
Cheers

anish
Posts: 12
Joined: 27 Jan 2020, 14:15

### Re: Cant find Pathplanning in CoppeliaSim

Hai,

Yes, you are right!

The below code worked for me to get to the end of the path:

Code: Select all

    Path_pos = sim.getPositionOnPath(Path,1)
sim.setObjectPosition(Dummy, -1, Path_pos)

and with path length concept I understand we can split the motion to require parts.

But I would like the dummy to move from one path Control Point to the other. As per the documentation http://www.coppeliarobotics.com/helpFil ... OnPath.htm
I tried:-

Code: Select all

    Path_pos = sim.getPositionOnPath(Path,-ctrlPtIndex-2)
sim.setObjectPosition(Dummy, -1, Path_pos)

But the dummy(which is now placed at control point 1) is not moving to the 2nd point. and I am getting the following error:-
Lua runtime error: [string "CHILD SCRIPT Dummy"]:11: attempt to perform arithmetic on global 'ctrlPtIndex' (a nil value)
stack traceback:
[string "CHILD SCRIPT Dummy"]:11: in function
Is there anything missing in the code?

Also, I would like to know if it's possible to use these path API like 'sim.getPositionOnPath' from a python script? My work is mainly using python code.
I could not find any option for that here http://www.coppeliarobotics.com/helpFil ... ctPosition

Best Regards

coppelia
Posts: 7597
Joined: 14 Dec 2012, 00:25

### Re: Cant find Pathplanning in CoppeliaSim

Not sure what your code looks like, but the error says that ctrlPtIndex is not defined, i.e. is nil. Make sure you have spelled that variable correctly.

Also, if using Python remote API, you can virtually call any complex function or sequence of functions:
Cheers

anish
Posts: 12
Joined: 27 Jan 2020, 14:15

### Re: Cant find Pathplanning in CoppeliaSim

Actually my code is the following:

Code: Select all

function sysCall_init()
-- do some initialization here
Path = sim.getObjectHandle('Path')
Dummy = sim.getObjectHandle('Dummy')
end

function sysCall_actuation()
-- put your actuation code here
Path_pos = sim.getPositionOnPath(Path,  -ctrlPtIndex-2 )
sim.setObjectPosition(Dummy, -1, Path_pos)
--Path_pos = sim.getPositionOnPath(Path,1)
--sim.setObjectPosition(Dummy, -1, Path_pos)
end

The information in documentation at http://www.coppeliarobotics.com/helpFil ... OnPath.htm is the following:
table_3 position=sim.getPositionOnPath (number pathHandle,number relativeDistance)
relativeDistance: a value between 0 and 1, where 0 is the beginning of the path, and 1 the end of the path. Make sure you selected the appropriate path length calculation method. See also sim.getPathLength. In order to retrieve the position that lies exactly on a specific path control point, specify following for relativeDistance: -ctrlPtIndex-1 (the value will be rounded appropriately).
I have spelled it correct too, I double checked. I tried replacing '-ctrlPtIndex-1 ' with the name of the path control point that is 'Path point 2' that also didnot work!

Thanks for legacy-remote API info!

Best Regards

coppelia
Posts: 7597
Joined: 14 Dec 2012, 00:25

### Re: Cant find Pathplanning in CoppeliaSim

no, ctrlPtIndex is the variable you use to select an index...
e.g.
• control point index 0 --> use following as second argument: -0-1=-1
• control point index 1 --> use following as second argument: -1-1=-2
• ...
• control point index n --> use following as second argument: -n-1
Cheers

anish
Posts: 12
Joined: 27 Jan 2020, 14:15

### Re: Cant find Pathplanning in CoppeliaSim

:D should have thought about that.

It worked like a charm!