Change control mode in Python for Torque mode #632
-
Dear Robotology community I need to move the torque value of the different joints using python. Thank you, Kind regards, Tim |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Can you provide the code that you are tryng to run and the exact error you are getting? Thanks! |
Beta Was this translation helpful? Give feedback.
-
hello ! import yarp;
import time;
import numpy as np;
yarp.Network.init();
props = yarp.Property()
props.put("device","remote_controlboard")
props.put("local","/client/right_arm")
props.put("remote","/icubSim/right_arm")
armDriver = yarp.PolyDriver(props)
iPos = armDriver.viewIPositionControl()
iVel = armDriver.viewIVelocityControl()
iTorque = armDriver.viewITorqueControl()
iEnc = armDriver.viewIEncoders()
iimp = armDriver.viewIImpedanceControl()
ictrl = armDriver.viewIControlMode()
jnts=iPos.getAxes()
iimp.setImpedance(4, 0.111, 0.014)
encs=yarp.Vector(jnts)
iEnc.getEncoders(encs.data())
ictrl.setControlMode(4,VOCAB_CM_TORQUE);
jnt_torque = 3
iTorque.setRefTorque(4,jnt_torque) this is based on the python tutorial. Traceback (most recent call last):
File "/home/timozegu/code/python/python-motor-control.py", line 35, in <module>
ictrl.setControlMode(4,VOCAB_CM_TORQUE);
NameError: name 'VOCAB_CM_TORQUE' is not defined it is working fine on c++ where do almost the same thing : ictrl->setControlMode(4,VOCAB_CM_TORQUE); Thank you, Tim |
Beta Was this translation helpful? Give feedback.
-
In C++ |
Beta Was this translation helpful? Give feedback.
-
thank you very much for your answer, it worked ! Thank you :) Tim |
Beta Was this translation helpful? Give feedback.
In C++
VOCAB_CM_TORQUE
is a preprocessor definition, so it is used without namespace. However, in Python it is wrapped as a normal constant, so it needs to be used asyarp.VOCAB_CM_TORQUE
, see https://github.com/roboticslab-uc3m/tools/blob/878c99f6ee48051665afe487b17d6b5a415a18c7/programs/pidTuning.py#L80 or https://github.com/robotology/blender-robotics-utils/blob/8839079844acb6c3a91860276b083a9a06a4be4c/script/blenderRCBPanel/blenderRCBPanel.py#L121 for an example of the use ofsetControlMode
in Python.