4 wheels robot + ROS + pixhawk + mavros

Hi to all,

I usually use pixhawk with ardurover for my skid-steering rovers, however, at the moment, I’m building a four wheeled robot with four steering wheels, too. This means that I have a total of 8 brushless motors (4 for the traction controlled in direction and speed, 4 for the steering controlled in angle position at fixed velocity). I wrote a C++ ROS node that correctly control all the motors and it works fine.

Now, I want to use ardurover running on a pixhawk to make the rover move autonomously; the problem is that the output from the pixhawk will be the servo output (PWM) on RC1 and RC3 while my motors work over CANbus.

So, the idea is to leave the servo output floating without connecting anything and to use mavros in ROS2 to subscribe to /mavros/rc/out and read the pulses and then translate them into motors commands. I’m planning to do something like this:

Pixhawk → RC output → my ros node use mavros to read from /mavros/rc/out and translate the PWM made for translation and rotation into motor commands.

Is it a good idea or it is better to do not rely on /mavros/rc/out topic?

Thank you!

anyone that can help me please?

Which model of Pixhawk are you using? If it’s a H7-based model, the best solution would be to write a driver (in Lua) for the Pixhawk to communicate directly with the motors over CANBus.

See ardupilot/libraries/AP_Scripting/drivers/torqeedo-torqlink.lua at master · ArduPilot/ardupilot · GitHub for an example

1 Like

Thank you for your reply, I’m using pixhawk 6X or 6C.

I saw the sample you linked, but it seems quite complex to do it. The Can protocol for my brushless motors (myactuator models) is not so easy to implement from scratch, moreover, only 4 motors work on Can bus, the other 4 motors used for traction work with a standard brushless controller that only has a rs232 serial port and comes with a C/C++ library. So, the best solution would be to use the output of /mavros/rc/out or any other pixhawk feature to do this. I never used Lua language, I could give it a try, but I don’t know if it’s the best solution in my specific case.