How to get table of path points

Typically: "How do I... ", "How can I... " questions
Post Reply
LowKick
Posts: 1
Joined: 11 Apr 2021, 12:10

How to get table of path points

Post by LowKick »

Using the manual (https://www.coppeliarobotics.com/helpFiles/en/paths.htm), I created some path and I want to get an array of coordinates of the waypoints. For simple testing, I use the code from the manual, but I get a nil value from sim.readCustomDataBlock(path,'Path'). How i can get an array of coordinates of waypoint?

Code: Select all

function sysCall_init()
    objectToFollowPath=sim.getObjectHandle(sim.handle_self)
    path=sim.getObjectHandle('Path')
    pathData=sim.unpackDoubleTable(sim.readCustomDataBlock(path,'PATH'))
    local m=Matrix(#pathData/7,7,pathData)
    pathPositions=m:slice(1,1,m:rows(),3):data()
    pathQuaternions=m:slice(1,4,m:rows(),7):data()
    pathLengths,totalLength=sim.getPathLengths(pathPositions,3)
    velocity=0.04 -- m/s
    posAlongPath=0
    previousSimulationTime=0
end

CoppeliaSim v4.1.0

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

Re: How to get table of path points

Post by coppelia »

Hello,

the way path are create and handled changed in CoppeliaSim V4.2.0
The user manual refers to CoppeliaSim V4.2.0. Best is to upgrade to CoppeliaSim V4.2.0 and convert your existing paths to the new paths: select an old path object, open its property window, then click Create similar object

In CoppeliaSim V4.2.0, have also a look at the demo scene: scenes/movingAlongAPath.ttt

Cheers

Post Reply