Hi, i want to make robot go right, left, forward or stop by reading hand gesture from file. I did read hand gesture from file. I did also change the robot's position with sim.setObjectPosition but this is not what i want.
from zmqRemoteApi import RemoteAPIClient
print('Program started')
client = RemoteAPIClient()
sim = client.getObject('sim')
objectHandle = sim.getObject('/RobotnikSummitXL')
while True:
with open('../hand_gesture/mp_hand_gesture/write.txt','rt') as f:
for line in f:
if line == 'okay':
pos = [-0.50, 0.4249919652938843, 0.3089343011379242]
sim.setObjectPosition(objectHandle, -1, pos)
elif line == 'live long':
pos = [-0.90, 0.4249919652938843, 0.3089343011379242]
sim.setObjectPosition(objectHandle, -1, pos)
instead of instantly changing the position of the robot, you'll have to act on the motors of the robot. Normally, those motors are driven in velocity control. In that mode, you can adjust the torque of each motor with sim.setJointTargetForce (or sim.setJointMaxForce in V4.3 and earlier), and the velocity with sim.setJointTargetVelocity
There is no error messages. When im running this code sim.setJointTargetVelocity in coppelia with lua, its working, robot is moving. Buy when im running this code in pycharm with python, code is running without error but robot is not moving.
Make sure you are targetting the right joint. And that you do otherwise exactly the same thing. Behind the scene, sim.setJointTargetVelocity is doing exactly the same thing, whether from Lua or Python.
The correctness of the call to sim.getObject with a relative path argument depends on where the script is located.
sim.getObject'./front_left_wheel' will work from the robot's script, but not from a script outside the robot hierarchy tree.
From other scripts you can use an absolute partial path, e.g. '/RobotnikSummitXL/front_left_wheel' (which is roughly the same as '/RobotnikSummitXL/*/front_left_wheel') or another path that is valid and not ambiguous.
fferri wrote: ↑25 May 2022, 10:35
The correctness of the call to sim.getObject with a relative path argument depends on where the script is located.
sim.getObject'./front_left_wheel' will work from the robot's script, but not from a script outside the robot hierarchy tree.
From other scripts you can use an absolute partial path, e.g. '/RobotnikSummitXL/front_left_wheel' (which is roughly the same as '/RobotnikSummitXL/*/front_left_wheel') or another path that is valid and not ambiguous.