I would like to generate path from two points from a child script to be followed by the robot via IK (i.e. tartget).
So I would make three functions (In a way this would be similar to sim.followPath()):
- makepath = function(pos1, pos2) -- this will generate a straight path between two points via pathHandle=sim.createPath, and insertPathCtrlPoints(pathHandle,2,0,2,{ptData1,ptData2}).
- setpath = function(object_to_move, path, vel) -- this will move the object (ikTip) along the path incrementally
- checkpath = function(object_to_move, path) -- this will check if it arrived the end end of the path
But I don't know a way to share the created 'path' to other functions in the sctipt.
Can you advise?
generate path from a script and share it among functionss
Re: generate path from a script and share it among functionss
Hello,
I would advise against using a path object at first, since you will lose flexibility. If you need to generate a path, simply use a table containing path points or configurations, e.g.:
Then you can easily manipulate that data structure, e.g. increase/reduce the number of points, or extract an interpolated point, etc. If you need to share the path with some other parts in a given script it is trivial. If you need to share it with another script, then you have several possibilities, e.g.:
or by simply calling a function in another script and passing the path as argument with
Cheers
I would advise against using a path object at first, since you will lose flexibility. If you need to generate a path, simply use a table containing path points or configurations, e.g.:
Code: Select all
local path={ {0,0}, {x,y} } -- e.g. a path with 2 points in the x/y space
Code: Select all
sim.setStringSignal("myData",sim.packTable(path))
-- In the other script, you can read that with:
local path=sim.getStringSignal('myData')
path=sim.unpackTable(path)
-- or in a similar way:
sim.writeCustomDataBlock(...)
--
sim.readCustomDataBlock(...)
sim.callScriptFunction
.Cheers