Cant find Pathplanning in CoppeliaSim

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

Cant find Pathplanning in CoppeliaSim

Post by anish » 03 Feb 2020, 18:08

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
Site Admin
Posts: 7597
Joined: 14 Dec 2012, 00:25

Re: Cant find Pathplanning in CoppeliaSim

Post by coppelia » 04 Feb 2020, 06:55

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

Post by anish » 05 Feb 2020, 00:26

Hai,

Yes, you are right!

Thanks for your response!

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

Thank you for your time.

Best Regards

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

Re: Cant find Pathplanning in CoppeliaSim

Post by coppelia » 05 Feb 2020, 15:01

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

Post by anish » 05 Feb 2020, 23:36

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!

Advice please!

Thanks for legacy-remote API info!

Best Regards

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

Re: Cant find Pathplanning in CoppeliaSim

Post by coppelia » 06 Feb 2020, 08:43

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

Post by anish » 07 Feb 2020, 00:10

:D should have thought about that.

It worked like a charm!

Thank you for your response!

Best Regards

Post Reply