I am trying to move an object (simply cuboid) through a prismatic joint (torque/force mode) of which I want setting up the position by a slider (UI). The script does not return errors, but it does not work. Someone has suggestions.
Thanks a lot
Sirx
Code: Select all
function PosChange_callback(ui,id,newVal)
pos=newVal*100
end
function sysCall_init()
-- This is executed exactly once, the first time this script is executed
Cuboid=sim.getObjectAssociatedWithScript(sim.handle_self) -- this is bubbleRob's handle
leftMotor=sim.getObjectHandle("Prismatic_joint") -- Handle of the left motor
minMaxSpeed={0.1,1} -- Min and max speeds for each motor
backUntilTime=-1 -- Tells whether bubbleRob is in forward or backward mode
-- Create the custom UI:
xml = '<ui title="'..sim.getObjectName(Cuboid)..' pos" closeable="false" resizeable="false" activate="false">'..
[[
<hslider minimum="0" maximum="100" onchange="PosChange_callback" id="1"/>
<label text="" style="* {margin-left: 200px;}"/>
</ui>
]]
ui=simUI.create(xml)
pos=0
simUI.setSliderValue(ui,1,0)
end
function sysCall_actuation()
sim.setJointTargetPosition(leftMotor,pos)
end
function sysCall_cleanup()
simUI.destroy(ui)
end