show object's trajectory

Typically: "How do I... ", "How can I... " questions
Post Reply
huihui
Posts: 15
Joined: 15 Apr 2022, 08:51

show object's trajectory

Post 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?

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

Re: show object's trajectory

Post 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

huihui
Posts: 15
Joined: 15 Apr 2022, 08:51

Re: show object's trajectory

Post 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!

Post Reply