Set position/velocity control mode via code

Typically: "How do I... ", "How can I... " questions
Post Reply
pab
Posts: 9
Joined: 19 Jan 2021, 21:05

Set position/velocity control mode via code

Post by pab »

I need to set position / velocity mode via Lua code (not via the GUI) because I want to be able to switch between these modes.

1)
It seems like I need this parameter from joint reference
"sim.jointfloatparam_dynctrlmode
int32 parameter: the dynamic control mode of the joint"

But it does not seem that the parameter is available to be set because when I query the parameter I get an error. I tried this:
print(sim.getObjectInt32Param(joint,sim.jointfloatparam_dynctrlmode))

where joint is the handle of a joint that has already been defined. This code returns an error.

2)
There are different modes for the joint, free, position, torque, velocity. How to set these modes via code? I am using Lua.

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

Re: Set position/velocity control mode via code

Post by coppelia »

Hello,

it is not sim.jointfloatparam_dynctrlmode, but sim.jointintparam_dynctrlmode¨

e.g.:

Code: Select all

    local m=sim.getObjectInt32Param(jointHandle,sim.jointintparam_dynctrlmode)
    print("mode:",m)
    local m=sim.setObjectInt32Param(jointHandle,sim.jointintparam_dynctrlmode,sim.jointdynctrl_position)
    local m=sim.getObjectInt32Param(jointHandle,sim.jointintparam_dynctrlmode)
    print("mode:",m)
Cheers

Post Reply