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

ROS+Arduino Servo Error

asked 2012-04-18 08:06:20 -0600

shakingatoms gravatar image

updated 2014-04-20 14:09:22 -0600

ngrennan gravatar image

I am trying to use the standard servo control example found here: http://www.ros.org/wiki/rosserial_arduino/Tutorials/Servo%20Controller . The program works fine, but only once. When I try to give it a new servo position it never updates. I have to close all of my terminal windows and reset my Arduino before I can try again. I am wondering if there is a way to actually reset the PWM to neutral in between commands. I have tested my servo and it works fine with a normal RC transmitter and receiver.

I am using Ubuntu 10.04 with ROS Electric and an Arduino MEGA 2560.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-05-22 15:06:48 -0600

Poofjunior gravatar image

updated 2012-05-23 07:20:30 -0600

Yep, I'm having the same problem. It looks like what's happening is that when we update the servo command with a new command, it simply ORs the bits together.

In other words, if your first command was 5, which is 00000101 in binary, and you send over 3 as your next command, which is 00000011 in binary, the next value will be 7, which is 00000111 in binary.

It looks like this problem has already been solved here

https://kforge.ros.org/rosserial/hg/rev/10cb30606b34

but I don't know how to apply it.

I've removed the old copy of rosserial in /opt/ros/electric/stacks and added the new version from the trunk into my ROS package path, but I still get the same error.

Any thoughts?

(I'm also running Electric.)

UPDATE: Whoop--it looks like I've discovered the answer! Here's what I did:

Note: I've only gotten this to work with electric.

  1. Remove the old version of rosserial.
  2. acquire the updated version of rosserial using mercurial here: https://kforge.ros.org/rosserial/hg/
  3. rosmake it and put the libraries folder in your Arduino sketchbook.
  4. Make sure you're using Arduino 1.0

(My problem was that I was still running version 022.)

Hope this helps!

(Thanks, Mike Ferguson!)

edit flag offensive delete link more
0

answered 2012-05-22 00:08:57 -0600

I am having the exact same problem. I also modified the code so that the Arduino publishes the value of "cmd_msg.data" into a topic called "/pose". I have the following observations:

  • When ROS Serial Python Node is launched for the first time everything works fine and I am able to receive the published pose. When I send the command "rostopic pub servo std_msgs/UInt16 180 -1" to change the servo arm angle I get the correct response and the published pose is now "180".

  • When I enter the next command "rostopic pub servo std_msgs/UInt16 90 -1" the servo remains in its 180 position and the /pose topic is now publishing "254".

  • No matter how many time I try to send a new servo command the servo remains in its position and the /pose topic keeps on publishing "254"

  • If I hit the reset button onboard the Arduino the servo returns to its 90 degree state momentarily and then goes back to the 180 degree state with /pose still publishing "254".

It seems to me that the ROS Serial Python Node is (a) not sending the correct message after the first message is sent and (b) loses communication with the subscribed topic /servo.

I am using Ubuntu 11.04 with ROS Electric. The Arduino IDE is version 22 and my board is the Nano with ATMEGA328.

edit flag offensive delete link more

Question Tools

4 followers

Stats

Asked: 2012-04-18 08:06:20 -0600

Seen: 1,293 times

Last updated: May 23 '12