Hello!
Alright, I'll just get straight to the point.
The code that you sent me with the moving the object in a square-shaped trajectory has helped me a lot thus far, however it has something extra that is giving me problems which are preventing me from achieving major progress for my project.
When the all the indicated endpoints for the sim.moveToPose loop are covered by motion, the object goes back to the initial pose. I wish that there was a way the object could just stay and stop at the pose indicated by the last row of the trajectories table.
This problem is demonstrated in the video link attached as a
cuboid shown just for example of how the code works.
https://drive.google.com/file/d/1NTi3MX ... sp=sharing
Here is also the modified version of the code I used:
Code: Select all
function sysCall_init()
corout=coroutine.create(coroutineMain)
cube = sim.getObject('.')
end
function sysCall_actuation()
if coroutine.status(corout)~='dead' then
local ok,errorMsg=coroutine.resume(corout)
if errorMsg then
error(debug.traceback(corout,errorMsg),2)
end
end
end
function sysCall_cleanup()
-- do some clean-up here
end
function coroutineMain()
-- Put some initialization code here
vel = 40
accel = 40
jerk = 10
cubepse = sim.getObjectPose(cube, -1)
trajrow1 = cubepse
trajrow2 = sim.copyTable(trajrow1)
trajrow2[2] = trajrow2[2]+0.05
trajrow2[3] = trajrow2[3]+0.02
trajrow3 = sim.copyTable(trajrow1)
trajrow3[2] = trajrow3[2]+0.1
trajrow4 = sim.copyTable(trajrow1)
local trajectories={
-- define a square. waypoints are {x,y,z,qx,qy,qz,qw}
trajrow1,
trajrow2,
trajrow3}
for i=1,#trajectories do
local from,to=trajectories[i],trajectories[i%3+1]
sim.moveToPose(-1,from,{vel},{accel},{jerk},to,function(currentPose,currentVel,currentAccel,auxData)
sim.setObjectPose(cube,-1,currentPose)
end,nil,{1,1,1,0.1})
end
end
Thanks in advance. I need it now more that before.