I agree that twist is highly problematic as a message type for a whole host of reasons. A lot of the problems that you have on this thread are because twist is in units of velocity.

Let me explain.

In the beginning people started building robots with electronic speed controllers (ESC). They used ESC because that’s what was available because thats what are used in factories. Factories tend to want motors to meter amounts of products per hour so they care about speed and use ESC.

Because people used ESC they gave commands in velocity - because that’s what ESC understand.

However you have a real problem with this - because mobile robots don’t live in velocity space they live in the real world which is measured in terms of distance. Generally you want to tell the robot to go forward 1 meter you don’t want to tell the robot to go at 1m/s for 1 second. The best ESC and robots in the world can’t go from 0m/s to 1m/s instantly and they can’t stop instantly either. The notion of a velocity is and can only ever be a target - its not a precise notion and can’t easily be made to be.

Because of the choice of unit space a number of other nasty work arounds emerged too - for example we all put dead-man timers in our robots (well at least I hope we do!). What is a dead man timer? Well its really a nasty way of converting speed to distance. What we say is, we can’t trust the robot to go more than 10cm because we can’t be sure that there isn’t an obstacle in the way so we are going to tell it to stop if it doesn’t get a new velocity command every 0.1second while its going at 1ms.

Normally your sensor suite can clear an area in front of the robot as safe in terms of distance, however how long before the robot stops is going to be a function of speed. Really what you ought to do is have a different deadman timer for different speeds (shorter dead-man for higher speeds) but as we all know that would be nasty nasty nasty nasty so no-one does it - we just fudge it by having a super short deadman even if that isn’t really that appropriate.

Frankly also issuing commands in terms of velocity is bad too because it forces certain control functions to be higher up in the stack than they need to be. For example consider the problem of driving towards a wall to dock with it. Your sensors tell you that you are 0.5m from the wall - you want to be 0.1m from the wall. Your sensor knows how far away the wall 0.001m precision. You have odometery that is accurate to 0.0001m. You should just tell the motor controller that you want to move forward 0.4 meters and then check to make sure you got to the right place. But oh no! We have to tell the motor controller that you want to go at 0.1m/s and you have to keep telling the motor controller that this is what you want to do every 0.1seconds and repeat this 40 times or more. Because none of the systems really knows how fast the robot is accelerating you have to have a high level control loop that constantly reads the sensor data to see if you’ve done it right etc. etc. etc. What a god awful mess!

My suggestion is that you simply issue commands in terms of cartesian space. The motor controller (which will have to be specific to each robot anyways) has to understand this command and execute it for that robot. This will be much better because invariably the control loop on the motor controller is super fast and is much more able to deal with variations of the dynamics of the robot than higher level stacks.

I’d suggest that you have a command that defines the arc that you’d like the robot to follow and the distance relative to current position. Maximum velocity, maximum acceleration would be settable parameters. The arc could be defined in a number of ways - it could be defined in radians - so for example a command of

d=1 meter
arc = 0 radians

Would cause the robot to driver forward 1 meter. A command of

d=0
arc=pi

Would cause the robot to turn in place

a command of

d= pi /2
arc

Would cause the robot to drive in a semi-circle.

For a differential drive robot this would be easy - the motor controller would execute the arc

For an Ackerman steering type robot - well it obviously can’t turn in place but execution would be easy too.

1 Like