Hello, I was attracted by the video related to motion planning of serial manipulator in https://www.youtube.com/watch?v=Kkn4OkP ... TUB4-Eb6B_. Besides, I put my questions with comments below the video. Here I give my question again. "I was confused that how can I created the auxiliary shapes? Is there any API function that can do this ? Or any tutorial could found from the user manual?"
Thanks!
How to build the auxiliary shapes with certain API funcitons?
Re: How to build the auxiliary shapes with certain API funcitons?
Hello,
You have several possibilities. One of them is:
Cheers
You have several possibilities. One of them is:
- add a dummy
- attach the child script below
- attach the dummy to the object/model you want to trace
- run the simulation
Code: Select all
function sysCall_init()
parentObjectHandle=sim.getObjectParent(sim.getObjectHandle(sim.handle_self))
everyXseconds=1
trailCount=4
color={0,1,0}
opacity=0.1
trail={}
lastTime=0
end
function sysCall_sensing()
local t=sim.getSimulationTime()
if t-lastTime>everyXseconds then
lastTime=t
if #trail>=trailCount then
sim.removeObject(trail[1])
table.remove(trail,1)
end
if parentObjectHandle>=0 then
local s=createTrace(parentObjectHandle)
if s then
trail[#trail+1]=s
end
end
end
end
function createTrace(o)
local originalObjects={}
if sim.getModelProperty(o)&sim.modelproperty_not_model==0 then
originalObjects=sim.getObjectsInTree(o,sim.object_shape_type,0)
else
originalObjects={o}
end
local toCopy={}
for i=1,#originalObjects,1 do
local r0,r=sim.getObjectInt32Parameter(originalObjects[i],sim.objintparam_visible)
if r~=0 then
toCopy[#toCopy+1]=originalObjects[i]
end
end
local copy=sim.copyPasteObjects(toCopy,0)--2+4+8+16+32)
copy=sim.groupShapes(copy)
local script=sim.getScriptAssociatedWithObject(copy)
if script>=0 then
sim.associateScriptWithObject(script,-1)
end
sim.setObjectProperty(copy,sim.objectproperty_selectinvisible)
sim.setObjectInt32Param(copy,sim.shapeintparam_respondable,0)
sim.setObjectInt32Param(copy,sim.shapeintparam_static,1)
sim.setShapeColor(copy,nil,sim.colorcomponent_ambient_diffuse,color)
sim.setShapeColor(copy,nil,sim.colorcomponent_transparency,{opacity})
return copy
end
Re: How to build the auxiliary shapes with certain API funcitons?
Thanks a lot! It works! :)