Ask Your Question
0

Can anyone tell me how to control the DC motors using ROS and Arduino

asked 2017-02-12 00:23:47 -0500

antonchi gravatar image

updated 2017-02-13 11:38:12 -0500

i am fairly new to ROS. I'm trying to control 2 DC motors through ROS and Arduino. I've been using rosserial package and also i've tried ros_arduino_bridge.

edit retag flag offensive close merge delete

Comments

The title is fort a short 'title', could you please try to edit your question into a title (one line) and a question (as long as needed?)

NEngelhard gravatar imageNEngelhard ( 2017-02-12 15:18:50 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-02-12 13:15:21 -0500

Mark Rose gravatar image

On the smaller Arduinos with only 2kb RAM I've had trouble using rosserial because of the amount of RAM consumed, so I've abandoned that for ros_arduino_bridge. If you are using a motor driver not already supported by ros_arduino_bridge, you'll have to modify the code in a couple of places.

First, in ROSArduinoBridge.ino, look at this code (lines 48-64):

//#define USE_BASE      // Enable the base controller code
#undef USE_BASE     // Disable the base controller code

/* Define the motor controller and encoder library you are using */
#ifdef USE_BASE
   /* The Pololu VNH5019 dual motor driver shield */
   #define POLOLU_VNH5019

   /* The Pololu MC33926 dual motor driver shield */
   //#define POLOLU_MC33926

   /* The RoboGaia encoder shield */
   #define ROBOGAIA

   /* Encoders directly attached to Arduino board */
   //#define ARDUINO_ENC_COUNTER
#endif

You need to uncomment the definition of USE_BASE, comment out ROBOGAIA, and then add your own define for your motor controller, say #define RKI1340_MOTOR_CONTROLLER.

Then, in motor_driver.ino, you'll need to add code to support that motor driver. The bottom of that file looks like this:

#else
  #error A motor driver must be selected!
#endif

You'll need to add an #elif before the #else for RKI1340_MOTOR_CONTROLLER, and add a definition of void setMotorSpeeds(int leftSpeed, int rightSpeed).

There are other changes required to support encoders different from the ones already coded. You might compare with the changes Marco Walther made to support the Pololu A-Star board with onboard motor driver. (I've contributed to his mods.)

https://github.com/mw46d/ros_arduino_...

edit flag offensive delete link more
0

answered 2017-02-12 04:47:22 -0500

duck-development gravatar image

how do you like to controll the Motors? the Turnspeed? or the Postion? or only on and off?

Greet Anton

edit flag offensive delete link more

Comments

first i want to turn it on and off the apply speed control also.

antonchi gravatar imageantonchi ( 2017-02-12 04:53:52 -0500 )edit

may this help https://www.sites.google.com/site/shr... the other questen is with kind of motor driver Chip ddo you have?

duck-development gravatar imageduck-development ( 2017-02-12 05:05:01 -0500 )edit

i'm using rki 1340 dc motor driver..and thanks for the link

antonchi gravatar imageantonchi ( 2017-02-12 05:24:55 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-02-12 00:23:47 -0500

Seen: 2,021 times

Last updated: Feb 13 '17