Motor direction, differential drive with MAVROS

asked 2017-11-08 09:07:34 -0600

flavia1394 gravatar image

Hi, I would like to build a catamaran without a steering servo but rather with 2 motors (left+right) for the steering, like a differential drive with MAVROS.

I have got a pxfmini with a raspberry pi3.

I executed and compiled this code and everything works fine, now I want to change the code to control two motors instead of a motor and a servo.

I would like to change the class ErleRoverManager so I can use two motors. Do you think it's a good idea add a method, for example that allow the catamaran to turn left or right thanks to differential drive? (void ErleRoverManager::turnLeft() could set a velocity and a direction on the motorA and the same velocity but opposite direction on the motorB ) If both the wheels are driven in the same direction and speed, the robot will go in a straight line. If both wheels are turned with equal speed in opposite directions, the robot will rotate about the central point of the axis. So how can I control the direction of the motors with APM planner or through the code? And also, when I have to override the channels can I do this, since I don't have any servo??

msg_override.channels[0] = erlerover_manager.getLinearVelocityA(); // motorA

msg_override.channels[1] = 0;

msg_override.channels[2] = erlerover_manager.getLinearVelocityB(); //motorB

msg_override.channels[3] = 0;

msg_override.channels[4] = 0;

msg_override.channels[5] = 0;

msg_override.channels[6] = 0;

msg_override.channels[7] = 0;

Thank you.

edit retag flag offensive close merge delete