Summit XL wheel control

Typically: "How do I... ", "How can I... " questions
blackbird
Posts: 12
Joined: 09 Mar 2022, 12:01

Summit XL wheel control

Post 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)

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

Re: Summit XL wheel control

Post 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

blackbird
Posts: 12
Joined: 09 Mar 2022, 12:01

Re: Summit XL wheel control

Post by blackbird »

Thanks for reply.

blackbird
Posts: 12
Joined: 09 Mar 2022, 12:01

Re: Summit XL wheel control

Post by blackbird »

I tried functions, functions has no error but robot is not moving. But functions work on lua but not on python.

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

Re: Summit XL wheel control

Post 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

blackbird
Posts: 12
Joined: 09 Mar 2022, 12:01

Re: Summit XL wheel control

Post 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.

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

Re: Summit XL wheel control

Post 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

blackbird
Posts: 12
Joined: 09 Mar 2022, 12:01

Re: Summit XL wheel control

Post 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')

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Summit XL wheel control

Post 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

blackbird
Posts: 12
Joined: 09 Mar 2022, 12:01

Re: Summit XL wheel control

Post 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.

Post Reply