How to use the function 'sim.moveToPose()'

Typically: "How do I... ", "How can I... " questions
Post Reply
Hacher
Posts: 15
Joined: 28 Nov 2024, 02:00

How to use the function 'sim.moveToPose()'

Post by Hacher »

I'm trying to use function 'sim.moveToPose()' to make a point to point movement, but I got some problems.
My code:

Code: Select all

sim=require'sim'
function sysCall_init()
a=sim.setInt32Signal('RG2_open',0)
end
function sysCall_thread()
local euler={0, -90, 0}
local position={-0.68781, -0.110, 0.31352}
local target_pose = sim.buildMatrix(position, euler)
print(target_pose)
move_object = sim.getObject("/RG2")
tip=sim.getObject("/tip")
target=sim.getObject("/target")
base=sim.getObject("/link1")
local ik = {
    tip = tip,
    target = target,
    base = base
}
local params = {
    ik = ik,
    targetPose = target_pose
}
sim.moveToPose(params)
end
And I got error:
...ram Files/CoppeliaRobotics/CoppeliaSimEdu/lua/motion.lua:294: missing or invalid 'targetPose' field.
stack traceback:
[C]: in function 'error'
...ram Files/CoppeliaRobotics/CoppeliaSimEdu/lua/motion.lua:294: in function 'sim.moveToPose_init'
...ram Files/CoppeliaRobotics/CoppeliaSimEdu/lua/motion.lua:618: in function 'sim.moveToPose'
[string "/UR5/Script"]:86: in function 'sysCall_thread'
stack traceback:
[C]: in function 'error'
...ogram Files/CoppeliaRobotics/CoppeliaSimEdu/lua/base.lua:441: in function <...ogram Files/CoppeliaRobotics/CoppeliaSimEdu/lua/base.lua:430>
Is there any instance of the using of this function?

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

Re: How to use the function 'sim.moveToPose()'

Post by coppelia »

Hello,

have a look at the demo scene scenes/basicTrajectoryGeneration.ttt: the red and purple cylinders use sim.moveToPose

Cheers

Hacher
Posts: 15
Joined: 28 Nov 2024, 02:00

Re: How to use the function 'sim.moveToPose()'

Post by Hacher »

Thkans for your reply. I have undertood how to use this function, but the trajectory planed by this function may have collision with the ground, is there any method to aviod such collision?

Looking forward to your reply. Thank you.

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

Re: How to use the function 'sim.moveToPose()'

Post by coppelia »

The function is purely kinematic and does not evaluate any potential collision situation. You'll have to check that yourself. In that case it is more appropriate to use the more elemental functions sim.moveToPose_init, sim.moveToPose_step and sim.moveToPose_cleanup. See in the same demo scene the scripts attached to the yellow and cyan cylinders.

Cheers

Post Reply