ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The cmd_vel is a velocity command, so you need to convert the velocity command to a PWM setting that corresponds to that speed.

Two scenarios:

1 - In a straight line: reasonably doable. Get a measuring tape and a stop watch and determine speed with both sides set at 25% PWM, then 50%, then 75%, then 100%. Find the equation that converts PWM to speed. (MS excel is good for something like this). This equation may be linear but may be a polynomial or some other function. You'll need to also determine your minimum speed. Start with PWM at 0 and slowly increase it until the robot starts moving. Once it's moving, that is your minimum speed. In Move_base there is a parameter for minimum speed. Not sure about Hector.

2 - Turning: This will be very difficult given the way you've setup the robot: 4 wheels and no encoders. 2 wheels and no encoders would be many times less complicated. What makes 4 wheel so difficult is that you could set the PWM different on left and right and the robot may still go straight. Once to you make the PWM difference large enough to break the wheel friction and start rotation, it may rotate very quickly. Basically you need to get all 4 wheels to start sliding to rotate which will require a lot more force than keeping it rotating. If the controllers requests a slow turn, it likely will not turn at all. With only 2 wheels, the wheels do not slide at all when rotating so this effect is much smaller. But...you can try it using the method as above. Use a stop watch and time how long a rotation takes given different values of PMW. You will then also find the minimum rotation speed to use as a parameter in the controller if it is anything like move_base.

With 4 wheels and encoders, the same issue doesn't appear because you know the actual wheel speed.

Good luck.

The cmd_vel is a velocity command, so you need to convert the velocity command to a PWM setting that corresponds to that speed.

Two scenarios:

1 - In a straight line: reasonably doable. Get a measuring tape and a stop watch and determine speed with both sides set at 25% PWM, then 50%, then 75%, then 100%. Find the equation that converts PWM to speed. (MS excel is good for something like this). This equation may be linear but may be a polynomial or some other function. You'll need to also determine your minimum speed. Start with PWM at 0 and slowly increase it until the robot starts moving. Once it's moving, that is your minimum speed. In Move_base there is a parameter for minimum speed. Not sure about Hector.Hector. If the robot doesn't go straight with same PWM value for both sides, you will have different equations for each side.

2 - Turning: This will be very difficult given the way you've setup the robot: 4 wheels and no encoders. 2 wheels and no encoders would be many times less complicated. What makes 4 wheel so difficult is that you could set the PWM different on left and right and the robot may still go straight. Once to you make the PWM difference large enough to break the wheel friction and start rotation, it may rotate very quickly. Basically you need to get all 4 wheels to start sliding to rotate which will require a lot more force than keeping it rotating. If the controllers requests a slow turn, it likely will not turn at all. With only 2 wheels, the wheels do not slide at all when rotating so this effect is much smaller. But...you can try it using the method as above. Use a stop watch and time how long a rotation takes given different values of PMW. You will then also find the minimum rotation speed to use as a parameter in the controller if it is anything like move_base.

With 4 wheels and encoders, the same issue doesn't appear because you know the actual wheel speed.

Good luck.

The cmd_vel is a velocity command, so you need to convert the velocity command to a PWM setting that corresponds to that speed.

Two scenarios:

1 - In a straight line: reasonably doable. Get a measuring tape and a stop watch and determine speed with both sides set at 25% PWM, then 50%, then 75%, then 100%. Find the equation that converts PWM to speed. (MS excel is good for something like this). This equation may be linear but may be a polynomial or some other function. You'll need to also determine your minimum speed. Start with PWM at 0 and slowly increase it until the robot starts moving. Once it's moving, that is your minimum speed. In Move_base there is a parameter for minimum speed. Not sure about Hector. If the robot doesn't go straight with same PWM value for both sides, you will have different equations for each side.

2 - Turning: This will be very difficult given the way you've setup the robot: 4 wheels and no encoders. 2 wheels and no encoders would be many times less complicated. What makes 4 wheel so difficult is that you could set the PWM different on left and right and the robot may still go straight. Once to you make the PWM difference large enough to break the wheel friction and start rotation, it may rotate very quickly. Basically you need to get all 4 wheels to start sliding to rotate which will require a lot more force than keeping it rotating. If the controllers requests a slow turn, it likely will not turn at all. With only 2 wheels, the wheels do not slide at all when rotating so this effect is much smaller. But...you can try it using the method as above. Use a stop watch and time how long a rotation takes given different values of PMW. You will then also find the minimum rotation speed to use as a parameter in the controller if it is anything like move_base.

With 4 wheels and encoders, the same issue doesn't appear because you know the actual wheel speed.

Good luck.

UPDATED BASED ON FOLLOW ON QUESTION: Sorry if I misunderstood your question.
The bit of code you added is a CALLBACK intended to run when the controller issues a new CMD_VEL message. As you noted, you can paste your own code to convert command to PWM in that location, but that doesn't help you get the PWM values down to the Arduino. I have no experience with ROS and Arduino but I assume you use a serial port to get data to the Arduino. You say ROSSERIAL is working. So ROSSERIAL tutorials should then show you how to connect your PWM values in the CALLBACK to where it gets used in the Arduino.