How would you implement movement of a custom robot with drivers given?

asked 2019-02-05 21:37:55 -0500

tsmalls gravatar image

I am new to ROS and I have ordered an Uctronics K7300 Raspberry Pi robot ( ) which will run the latest Raspbian and ROS Melodic. I plan on using this with an RPLIDAR A1 to make a tour robot. I don't have the parts yet, but I wanted to research ROS in the meantime. This robot was not made to work with ROS, but it comes with all the drivers needed to control it, which is written in C. In other words, I have the following functions available to me:

void go_left(void);
void go_right(void);
void go_forward_left(void);
void go_forward_right(void);
void go_back(void);
void go_back_left(void);
void go_back_right(void);
void stop(void);

My question is, how can I implement this into ROS so that when I use Rviz I can set a navigation goal on the map and it will have a way to move the robot to said goal?

edit retag flag offensive close merge delete


Is that really the API you have available? Because go_left(void) seems like a rather useless function, unless the robot travels in a "grid" (ie: go left one cell).

The nav-stack is not really made to work with such setups. It will work much better with robots that can actually be "steered" ..

gvdhoorn gravatar image gvdhoorn  ( 2019-02-06 02:38:54 -0500 )edit

.. (ie: go left by "4 degrees" this cycle).

It can probably be made to work (you'd probably need other planners), but it won't be optimal.

gvdhoorn gravatar image gvdhoorn  ( 2019-02-06 02:39:35 -0500 )edit

Yeah, this robot does not turn the front wheels, it just adjusts the motors to make a turn, so go_left(void) looks like this:

void go_left(void) {
    DCMotorRun(2, FORWARD);
    DCMotorRun(1, BACKWARD);
    DCMotorRun(3, BACKWARD);
    DCMotorRun(4, FORWARD);
tsmalls gravatar image tsmalls  ( 2019-02-06 12:06:56 -0500 )edit

That sounds like skid-steer, which is not uncommon, but can you vary the amount (ie: velocity) by which the motors run? So can FORWARD be a different value for instance?

gvdhoorn gravatar image gvdhoorn  ( 2019-02-06 12:11:20 -0500 )edit

I see these three #defines, which I guess means pulse width modulation, but it is not used anywhere in the code. I feel like there has to be a way.

#define PWM_MAX 100
#define PWM_HAF 50
#define PWM_MIN 30
tsmalls gravatar image tsmalls  ( 2019-02-06 14:46:46 -0500 )edit

If all else fails, buying another motor controller is always an option. Assuming I can adjust the speed, how would I proceed?

tsmalls gravatar image tsmalls  ( 2019-02-06 16:56:28 -0500 )edit

If we assume you have proper/some form of velocity control over your motors, then something like the diff_drive_controller configured for skid steer could be an option.

That would give you a ..

gvdhoorn gravatar image gvdhoorn  ( 2019-02-07 03:42:15 -0500 )edit

.. geometry_msgs/Twist interface that is standard across all ROS mobile bases for robots and is immediately compatible with things like the navigation stack and tele-operation packages.

gvdhoorn gravatar image gvdhoorn  ( 2019-02-07 03:43:38 -0500 )edit