How to show the trajectory curve of the end-effector of manipulator?

Typically: "How do I... ", "How can I... " questions
Post Reply
zhangm365
Posts: 46
Joined: 19 Jun 2021, 12:58

How to show the trajectory curve of the end-effector of manipulator?

Post by zhangm365 »

HELLO,

How to display the trajectory curve of the end-effector of manipulator in the latest version of the software (V4.2) ?
Last edited by zhangm365 on 14 Jan 2022, 10:09, edited 1 time in total.

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

Re: How to show the trajectory curve of the end-effector of manipulator?

Post by coppelia »

Hello,

the easiest would be to add a dummy to your scene, attach it to the end-effector, then attach following child script to the dummy:

Code: Select all

function sysCall_init()
    h=sim.getObjectHandle(sim.handle_self)
    dr=sim.addDrawingObject(sim.drawing_lines|sim.drawing_cyclic,2,0,-1,500,{1,0,1})
    pt=sim.getObjectPosition(h,-1)
end

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

zhangm365
Posts: 46
Joined: 19 Jun 2021, 12:58

Re: How to show the trajectory curve of the end-effector of manipulator?

Post by zhangm365 »

Thank your prompt reply.
Why does the displayed trajectory disappear automatically?
Can it be retained?

fferri
Posts: 1187
Joined: 09 Sep 2013, 19:28

Re: How to show the trajectory curve of the end-effector of manipulator?

Post by fferri »

Yes you can increase drawing object maxItemCount, which is the 5th argument of sim.addDrawingObject, and you can explicitly clear the drawing object with sim.addDrawingObjectItem(dr,nil)

zhangm365
Posts: 46
Joined: 19 Jun 2021, 12:58

Re: How to show the trajectory curve of the end-effector of manipulator?

Post by zhangm365 »

ok, thanks your reply.

As scripts pointed out int the figure:

https://vrep.oss-cn-shenzhen.aliyuncs.c ... RjNjk4N2Fi


Can the variables between two child scripts, as the picture showed, identify each other?

fferri
Posts: 1187
Joined: 09 Sep 2013, 19:28

Re: How to show the trajectory curve of the end-effector of manipulator?

Post by fferri »

Yes. One way is to use signals.

You can set a signal in one script, and read the signal with the same name in the other script.

Related API functions:
  • sim.setIntegerSignal / sim.getIntegerSignal / sim.clearIntegerSignal
  • sim.setFloatSignal / sim.getFloatSignal / sim.clearFloatSignal
  • sim.setDoubleSignal / sim.getDoubleSignal / sim.clearDoubleSignal
  • sim.setStringSignal / sim.getStringSignal / sim.clearStringSignal
  • sim.getSignalName
  • sim.waitForSignal
More types of data can be exchanged by packing/unpacking data.

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

Re: How to show the trajectory curve of the end-effector of manipulator?

Post by coppelia »

You can also use custom data attached to objects.

Cheers

Post Reply