Page 1 of 1

show object's trajectory

Posted: 19 May 2022, 16:12
by huihui
There is a force sensor at the end of my robotic arm. With the movement of the robotic arm, the force sensor also moves. I want to display the movement trajectory of the force sensor in the scene. I read many tutorials and said that Graph can be set, but I found that That method should only be used in lower versions, I am using the latest version 4.3.0 now, and there are no similar settings that can be set in the GUI. How should I solve my problem in the latest version?

Re: show object's trajectory

Posted: 20 May 2022, 14:22
by coppelia
Hello,

a simple way to display a trace of the object, is to add a child script to the object with following content:

Code: Select all

function sysCall_init()
    h=sim.getObject('.')
    dr=sim.addDrawingObject(sim.drawing_lines|sim.drawing_cyclic,2,0,-1,300,{1,0,1})
    pt=sim.getObjectPosition(h,sim.handle_world)
end

function sysCall_sensing()
    local l={pt[1],pt[2],pt[3]}
    pt=sim.getObjectPosition(h,sim.handle_world)
    l[4]=pt[1]
    l[5]=pt[2]
    l[6]=pt[3]
    sim.addDrawingObjectItem(dr,l)
end
Cheers

Re: show object's trajectory

Posted: 21 May 2022, 15:13
by huihui
coppelia wrote: 20 May 2022, 14:22 Hello,

a simple way to display a trace of the object, is to add a child script to the object with following content:

Code: Select all

function sysCall_init()
    h=sim.getObject('.')
    dr=sim.addDrawingObject(sim.drawing_lines|sim.drawing_cyclic,2,0,-1,300,{1,0,1})
    pt=sim.getObjectPosition(h,sim.handle_world)
end

function sysCall_sensing()
    local l={pt[1],pt[2],pt[3]}
    pt=sim.getObjectPosition(h,sim.handle_world)
    l[4]=pt[1]
    l[5]=pt[2]
    l[6]=pt[3]
    sim.addDrawingObjectItem(dr,l)
end
Cheers
It works.Thanks!