Page 1 of 2

Summit XL wheel control

Posted: 23 May 2022, 17:28
by blackbird
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.

Code: Select all

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)

Re: Summit XL wheel control

Posted: 24 May 2022, 05:58
by coppelia
Hello,

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

Cheers

Re: Summit XL wheel control

Posted: 24 May 2022, 09:47
by blackbird
Thanks for reply.

Re: Summit XL wheel control

Posted: 24 May 2022, 17:17
by blackbird
I tried functions, functions has no error but robot is not moving. But functions work on lua but not on python.

Re: Summit XL wheel control

Posted: 25 May 2022, 08:01
by coppelia
Is there an error message? With Lua? With Python? is yes, what does it say?
And I didn't understand if it works with Lua?

Make sutre that there is not another script interferring with the motors, i.e. there is a default script that normally acts on the motors.

Cheers

Re: Summit XL wheel control

Posted: 25 May 2022, 09:25
by blackbird
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.

Re: Summit XL wheel control

Posted: 25 May 2022, 09:55
by coppelia
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.

Cheers

Re: Summit XL wheel control

Posted: 25 May 2022, 10:21
by blackbird
Im taking the wheels like this is it true?

Code: Select all

motorHandles={-1,-1,-1,-1}

motorHandles[1]=sim.getObject('./front_left_wheel')
motorHandles[2]=sim.getObject('./front_right_wheel')
motorHandles[3]=sim.getObject('./back_right_wheel')
motorHandles[4]=sim.getObject('./back_left_wheel')

Re: Summit XL wheel control

Posted: 25 May 2022, 10:35
by fferri
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.

See Accessing scene objects programmatically

Re: Summit XL wheel control

Posted: 25 May 2022, 17:59
by blackbird
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.

See Accessing scene objects programmatically
Is this for remote api? Im using zmqRemote api.