GithubHelp home page GithubHelp logo

ros_arduino_bridge's Introduction

Overview

This branch (indigo-devel) is intended for ROS Indigo and above, and uses the Catkin buildsystem. It may also be compatible with ROS Hydro.

This ROS stack includes an Arduino library (called ROSArduinoBridge) and a collection of ROS packages for controlling an Arduino-based robot using standard ROS messages and services. The stack does not depend on ROS Serial.

Features of the stack include:

  • Direct support for Ping sonar and Sharp infrared (GP2D12) sensors

  • Can also read data from generic analog and digital sensors

  • Can control digital outputs (e.g. turn a switch or LED on and off)

  • Support for PWM servos

  • Configurable base controller if using the required hardware

The stack includes a base controller for a differential drive robot that accepts ROS Twist messages and publishes odometry data back to the PC. The base controller requires the use of a motor controller and encoders for reading odometry data. The current version of the stack provides support for the following base controller hardware:

NOTE: The Robogaia Mega Encoder shield can only be used with an Arduino Mega. The on-board wheel encoder counters are currently only supported by Arduino Uno.

  • L298 motor driver

  • The library can be easily extended to include support for other motor controllers and encoder hardware or libraries.

Official ROS Documentation

A standard ROS-style version of this documentation can be found on the ROS wiki at:

http://www.ros.org/wiki/ros_arduino_bridge

System Requirements

Python Serial: To install the python-serial package under Ubuntu, use the command:

$ sudo apt-get install python-serial

On non-Ubuntu systems, use either:

$ sudo pip install --upgrade pyserial

or

$ sudo easy_install -U pyserial

Arduino IDE 1.6.6 or Higher: Note that the preprocessing of conditional #include statements is broken in earlier versions of the Arduino IDE. To ensure that the ROS Arduino Bridge firmware compiles correctly, be sure to install version 1.6.6 or higher of the Arduino IDE. You can download the IDE from https://www.arduino.cc/en/Main/Software.

Hardware: The firmware should work with any Arduino-compatible controller for reading sensors and controlling PWM servos. However, to use the base controller, you will need a supported motor controller and encoder hardware as described above. If you do not have this hardware, you can still try the package for reading sensors and controlling servos. See the NOTES section at the end of this document for instructions on how to do this.

To use the base controller you must also install the appropriate libraries for your motor controller and encoders. For the Pololu VNH5019 Dual Motor Shield, the library can be found at:

https://github.com/pololu/Dual-VNH5019-Motor-Shield

For the Pololu MC33926 Dual Motor Shield, the library can be found at:

https://github.com/pololu/dual-mc33926-motor-shield

The Robogaia Mega Encoder library can be found at:

http://www.robogaia.com/uploads/6/8/0/9/6809982/__megaencodercounter-1.3.tar.gz

L298 Motor Driver doesn't require any libraries

These libraries should be installed in your standard Arduino sketchbook/libraries directory.

Finally, it is assumed you are using version 1.0 or greater of the Arduino IDE.

Preparing your Serial Port under Linux

Your Arduino will likely connect to your Linux computer as port /dev/ttyACM# or /dev/ttyUSB# where # is a number like 0, 1, 2, etc., depending on how many other devices are connected. The easiest way to make the determination is to unplug all other USB devices, plug in your Arduino, then run the command:

$ ls /dev/ttyACM*

or

$ ls /dev/ttyUSB*

Hopefully, one of these two commands will return the result you're looking for (e.g. /dev/ttyACM0) and the other will return the error "No such file or directory".

Next you need to make sure you have read/write access to the port. Assuming your Arduino is connected on /dev/ttyACM0, run the command:

$ ls -l /dev/ttyACM0

and you should see an output similar to the following:

crw-rw---- 1 root dialout 166, 0 2013-02-24 08:31 /dev/ttyACM0

Note that only root and the "dialout" group have read/write access. Therefore, you need to be a member of the dialout group. You only have to do this once and it should then work for all USB devices you plug in later on.

To add yourself to the dialout group, run the command:

$ sudo usermod -a -G dialout your_user_name

where your_user_name is your Linux login name. You will likely have to log out of your X-window session then log in again, or simply reboot your machine if you want to be sure.

When you log back in again, try the command:

$ groups

and you should see a list of groups you belong to including dialout.

Installation of the ros_arduino_bridge Stack

$ cd ~/catkin_workspace/src
$ git clone https://github.com/hbrobotics/ros_arduino_bridge.git
$ cd ~/catkin_workspace
$ catkin_make

The provided Arduino library is called ROSArduinoBridge and is located in the ros_arduino_firmware package. This sketch is specific to the hardware requirements above but it can also be used with other Arduino-type boards (e.g. Uno) by turning off the base controller as described in the NOTES section at the end of this document.

To install the ROSArduinoBridge library, follow these steps:

$ cd SKETCHBOOK_PATH

where SKETCHBOOK_PATH is the path to your Arduino sketchbook directory.

$ cp -rp `rospack find ros_arduino_firmware`/src/libraries/ROSArduinoBridge ROSArduinoBridge

This last command copies the ROSArduinoBridge sketch files into your sketchbook folder. The next section describes how to configure, compile and upload this sketch.

Loading the ROSArduinoBridge Sketch

  • If you are using the base controller, make sure you have already installed the appropriate motor controller and encoder libraries into your Arduino sketchbook/librariesfolder.

  • Launch the Arduino 1.0 IDE and load the ROSArduinoBridge sketch. You should be able to find it by going to:

    File->Sketchbook->ROSArduinoBridge

NOTE: If you don't have the required base controller hardware but still want to try the code, see the notes at the end of the file.

Choose one of the supported motor controllers by uncommenting its #define statement and commenting out any others. By default, the Pololu VNH5019 driver is chosen.

Choose a supported encoder library by by uncommenting its #define statement and commenting out any others. the Robogaia Mega Encoder shield is chosen by default.

If you want to control PWM servos attached to your controller, look for the line:

#define USE_SERVOS

and make sure it is not commented out like this:

//#define USE_SERVOS

You must then edit the include file servos.h and change the N_SERVOS parameter as well as the pin numbers for the servos you have attached.

  • Compile and upload the sketch to your Arduino.

Firmware Commands

The ROSArduinoLibrary accepts single-letter commands over the serial port for polling sensors, controlling servos, driving the robot, and reading encoders. These commands can be sent to the Arduino over any serial interface, including the Serial Monitor in the Arduino IDE.

NOTE: Before trying these commands, set the Serial Monitor baudrate to 57600 and the line terminator to "Carriage return" or "Both NL & CR" using the two pulldown menus on the lower right of the Serial Monitor window.

The list of commands can be found in the file commands.h. The current list includes:

#define ANALOG_READ    'a'
#define GET_BAUDRATE   'b'
#define PIN_MODE       'c'
#define DIGITAL_READ   'd'
#define READ_ENCODERS  'e'
#define MOTOR_SPEEDS   'm'
#define PING           'p'
#define RESET_ENCODERS 'r'
#define SERVO_WRITE    's'
#define SERVO_READ     't'
#define UPDATE_PID     'u'
#define DIGITAL_WRITE  'w'
#define ANALOG_WRITE   'x'

For example, to get the analog reading on pin 3, use the command:

a 3

To change the mode of digital pin 3 to OUTPUT, send the command:

c 3 1

To get the current encoder counts:

e

To move the robot forward at 20 encoder ticks per second:

m 20 20

Testing your Wiring Connections

On a differential drive robot, the motors are connected to the motor controller terminals with opposite polarities to each other. Similarly, the A/B leads from the encoders are connected in the reverse sense to each other. However, you still need to make sure that (a) the wheels move forward when given a positive motor speed and (b) that the encoder counts increase when the wheels move forward.

After placing your robot on blocks, you can use the Serial Monitor in the Arduino IDE to test both requirements. Use the 'm' command to activate the motors, the 'e' command to get the encoder counts, and the 'r' command to reset the encoders to 0. Remember that at the firmware level, motor speeds are given in encoder ticks per second so that for an encoder resolution of, say 4000 counts per wheel revolution, a command such as 'm 20 20' should move the wheels fairly slowly. (The wheels will only move for 2 seconds which is the default setting for the AUTO_STOP_INTERVAL.) Also remember that the first argument is the left motor speed and the second argument is the right motor speed. Similarly, when using the 'e' command, the first number returned is the left encoder count and the second number is the right encoder count.

Finally, you can use the 'r' and 'e' commands to verify the expected encoder counts by rotating the wheels by hand roughly one full turn and checking the reported counts.

Configuring the ros_arduino_python Node

Now that your Arduino is running the required sketch, you can configure the ROS side of things on your PC. You define your robot's dimensions, PID parameters, and sensor configuration by editing the YAML file in the directory ros_arduino_python/config. So first move into that directory:

$ roscd ros_arduino_python/config

Now copy the provided config file to one you can modify:

$ cp arduino_params.yaml my_arduino_params.yaml

Bring up your copy of the params file (my_arduino_params.yaml) in your favorite text editor. It should start off looking like this:

port: /dev/ttyUSB0
baud: 57600
timeout: 0.1

rate: 50
sensorstate_rate: 10

use_base_controller: False
base_controller_rate: 10

# === Robot drivetrain parameters
#wheel_diameter: 0.146
#wheel_track: 0.2969
#encoder_resolution: 8384 # from Pololu for 131:1 motors
#gear_reduction: 1.0
#motors_reversed: True

# === PID parameters
#Kp: 20
#Kd: 12
#Ki: 0
#Ko: 50
#accel_limit: 1.0

# === Sensor definitions.  Examples only - edit for your robot.
#     Sensor type can be one of the follow (case sensitive!):
#	  * Ping
#	  * GP2D12
#	  * Analog
#	  * Digital
#	  * PololuMotorCurrent
#	  * PhidgetsVoltage
#	  * PhidgetsCurrent (20 Amp, DC)

sensors: {
  #motor_current_left:   {pin: 0, type: PololuMotorCurrent, rate: 5},
  #motor_current_right:  {pin: 1, type: PololuMotorCurrent, rate: 5},
  #ir_front_center:      {pin: 2, type: GP2D12, rate: 10},
  #sonar_front_center:   {pin: 5, type: Ping, rate: 10},
  arduino_led:          {pin: 13, type: Digital, rate: 5, direction: output}
}

NOTE: Do not use tabs in your .yaml file or the parser will barf it back out when it tries to load it. Always use spaces instead. ALSO: When defining your sensor parameters, the last sensor in the list does not get a comma (,) at the end of the line but all the rest must have a comma.

Let's now look at each section of this file.

Port Settings

The port will likely be either /dev/ttyACM0 or /dev/ttyUSB0. Set accordingly.

The MegaRobogaiaPololu Arudino sketch connects at 57600 baud by default.

Polling Rates

The main rate parameter (50 Hz by default) determines how fast the outside ROS loop runs. The default should suffice in most cases. In any event, it should be at least as fast as your fastest sensor rate (defined below).

The sensorstate_rate determines how often to publish an aggregated list of all sensor readings. Each sensor also publishes on its own topic and rate.

The use_base_controller parameter is set to False by default. Set it to True to use base control (assuming you have the required hardware.) You will also have to set the PID paramters that follow.

The base_controller_rate determines how often to publish odometry readings.

Defining Sensors

The sensors parameter defines a dictionary of sensor names and sensor parameters. (You can name each sensor whatever you like but remember that the name for a sensor will also become the topic name for that sensor.)

The four most important parameters are pin, type, rate and direction. The rate defines how many times per second you want to poll that sensor. For example, a voltage sensor might only be polled once a second (or even once every 2 seconds: rate=0.5), whereas a sonar sensor might be polled at 20 times per second. The type must be one of those listed (case sensitive!). The default direction is input so to define an output pin, set the direction explicitly to output. In the example above, the Arduino LED (pin 13) will be turned on and off at a rate of 2 times per second.

Setting Drivetrain and PID Parameters

To use the base controller, you will have to uncomment and set the robot drivetrain and PID parameters. The sample drivetrain parameters are for 6" drive wheels that are 11.5" apart. Note that ROS uses meters for distance so convert accordingly. The sample encoder resolution (ticks per revolution) is from the specs for the Pololu 131:1 motor. Set the appropriate number for your motor/encoder combination. Set the motors_reversed to True if you find your wheels are turning backward, otherwise set to False.

The PID parameters are trickier to set. You can start with the sample values but be sure to place your robot on blocks before sending it your first Twist command.

Launching the ros_arduino_python Node

Take a look at the launch file arduino.launch in the ros_arduino_python/launch directory. As you can see, it points to a config file called my_arduino_params.yaml. If you named your config file something different, change the name in the launch file.

With your Arduino connected and running the MegaRobogaiaPololu sketch, launch the ros_arduino_python node with your parameters:

$ roslaunch ros_arduino_python arduino.launch

You should see something like the following output:

process[arduino-1]: started with pid [6098]
Connecting to Arduino on port /dev/ttyUSB0 ...
Connected at 57600
Arduino is ready.
[INFO] [WallTime: 1355498525.954491] Connected to Arduino on port /dev/ttyUSB0 at 57600 baud
[INFO] [WallTime: 1355498525.966825] motor_current_right {'rate': 5, 'type': 'PololuMotorCurrent', 'pin': 1}
[INFO]
etc

If you have any Ping sonar sensors on your robot and you defined them in your config file, they should start flashing to indicate you have made the connection.

Viewing Sensor Data

To see the aggregated sensor data, echo the sensor state topic:

$ rostopic echo /arduino/sensor_state

To see the data on any particular sensor, echo its topic name:

$ rostopic echo /arduino/sensor/sensor_name

For example, if you have a sensor called ir_front_center, you can see its data using:

$ rostopic echo /arduino/sensor/ir_front_center

You can also graph the range data using rxplot:

$ rxplot -p 60 /arduino/sensor/ir_front_center/range

Sending Twist Commands and Viewing Odometry Data

Place your robot on blocks, then try publishing a Twist command:

$ rostopic pub -1 /cmd_vel geometry_msgs/Twist '{ angular: {z: 0.5} }'

The wheels should turn in a direction consistent with a counter-clockwise rotation (right wheel forward, left wheel backward). If they turn in the opposite direction, set the motors_reversed parameter in your config file to the opposite of its current setting, then kill and restart the arduino.launch file.

Stop the robot with the command:

$ rostopic pub -1 /cmd_vel geometry_msgs/Twist '{}'

To view odometry data:

$ rostopic echo /odom

or

$ rxplot -p 60 /odom/pose/pose/position/x:y, /odom/twist/twist/linear/x, /odom/twist/twist/angular/z

ROS Services

The ros_arduino_python package also defines a few ROS services as follows:

digital_set_direction - set the direction of a digital pin

$ rosservice call /arduino/digital_set_direction pin direction

where pin is the pin number and direction is 0 for input and 1 for output.

digital_write - send a LOW (0) or HIGH (1) signal to a digital pin

$ rosservice call /arduino/digital_write pin value

where pin is the pin number and value is 0 for LOW and 1 for HIGH.

servo_write - set the position of a servo

$ rosservice call /arduino/servo_write id pos

where id is the index of the servo as defined in the Arduino sketch (servos.h) and pos is the position in radians (0 - 3.14).

servo_read - read the position of a servo

$ rosservice call /arduino/servo_read id

where id is the index of the servo as defined in the Arduino sketch (servos.h)

Using the on-board wheel encoder counters (Arduino Uno only)

The firmware supports on-board wheel encoder counters for Arduino Uno. This allows connecting wheel encoders directly to the Arduino board, without the need for any additional wheel encoder counter equipment (such as a RoboGaia encoder shield).

For speed, the code is directly addressing specific Atmega328p ports and interrupts, making this implementation Atmega328p (Arduino Uno) dependent. (It should be easy to adapt for other boards/AVR chips though.)

To use the on-board wheel encoder counters, connect your wheel encoders to Arduino Uno as follows:

Left wheel encoder A output -- Arduino UNO pin 2
Left wheel encoder B output -- Arduino UNO pin 3

Right wheel encoder A output -- Arduino UNO pin A4
Right wheel encoder B output -- Arduino UNO pin A5

Make the following changes in the ROSArduinoBridge sketch to disable the RoboGaia encoder shield, and enable the on-board one:

/* The RoboGaia encoder shield */
//#define ROBOGAIA
/* Encoders directly attached to Arduino board */
#define ARDUINO_ENC_COUNTER

Compile the changes and upload to your controller.

Using L298 Motor driver

the wiring between the L298 motor driver and arduino board is defined in motor_driver.h in the firmware as follow:

#define RIGHT_MOTOR_BACKWARD 5
#define LEFT_MOTOR_BACKWARD  6
#define RIGHT_MOTOR_FORWARD  9
#define LEFT_MOTOR_FORWARD   10
#define RIGHT_MOTOR_ENABLE 12
#define LEFT_MOTOR_ENABLE 13

wire them this way or change them if you want, and make sure that the L298 motor driver is defined then compile and upload the firmware.

NOTES

If you do not have the hardware required to run the base controller, follow the instructions below so that you can still use your Arduino-compatible controller to read sensors and control PWM servos.

First, you need to edit the ROSArduinoBridge sketch. At the top of the file comment out the line:

#define USE_BASE

so that it looks like this:

//#define USE_BASE

NOTE: If you are using a version of the Arduino IDE previous to 1.6.6, you also need to comment out the line that looks like this in the file encoder_driver.ino:

#include "MegaEncoderCounter.h"

so it looks like this:

//#include "MegaEncoderCounter.h"

Compile the changes and upload to your controller.

Next, edit your my_arduino_params.yaml file and make sure the use_base_controller parameter is set to False. That's all there is to it.

ros_arduino_bridge's People

Contributors

fibird avatar mikeferguson avatar waynegramlich avatar yellow-sky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ros_arduino_bridge's Issues

ros_arduino_python node died

Version: Indigo on RaspberryPi

I use ros_arduino_python to controll arduino on rpi.Lastday it worked fine.But today when I roslaunch the launch file,some erros happen.

Connecting to Arduino on port /dev/ttyUSB0 ...
Traceback (most recent call last):
  File "/opt/ros/indigo/share/ros_arduino_python/nodes/arduino_node.py", line 195, in <module>
    myArduino = ArduinoROS()
  File "/opt/ros/indigo/share/ros_arduino_python/nodes/arduino_node.py", line 87, in __init__
    self.controller.connect()
  File "/opt/ros/indigo/lib/python2.7/dist-packages/ros_arduino_python/arduino_driver.py", line 68, in connect
    test = self.get_baud()
  File "/opt/ros/indigo/lib/python2.7/dist-packages/ros_arduino_python/arduino_driver.py", line 261, in get_baud
    return int(self.execute('b'));
  File "/opt/ros/indigo/lib/python2.7/dist-packages/ros_arduino_python/arduino_driver.py", line 178, in execute
    return int(value)
TypeError: int() argument must be a string or a number, not 'NoneType'

I check the arduino_driver.py and I didn't find the reason.Rebooting node doesn't work.
Here are the log files:
e86d038a-4755-11e7-8caf-b827eb1042b5.zip

What type of L298 board are you using?

I spent part of the weekend wondering why the ros_arduino_firmware wasn't doing speed control on my motors. I noticed that the code for the L298 looks like this:
https://github.com/hbrobotics/ros_arduino_bridge/blob/indigo-devel/ros_arduino_firmware/src/libraries/ROSArduinoBridge/motor_driver.ino#L76

Specifically, you're PWMing the motor direction pins:
if (i == LEFT) {
if (reverse == 0) { analogWrite(RIGHT_MOTOR_FORWARD, spd); analogWrite(RIGHT_MOTOR_BACKWARD, 0); }
else if (reverse == 1) { analogWrite(RIGHT_MOTOR_BACKWARD, spd); analogWrite(RIGHT_MOTOR_FORWARD, 0); }
}
else /if (i == RIGHT) //no need for condition/ {
if (reverse == 0) { analogWrite(LEFT_MOTOR_FORWARD, spd); analogWrite(LEFT_MOTOR_BACKWARD, 0); }
else if (reverse == 1) { analogWrite(LEFT_MOTOR_BACKWARD, spd); analogWrite(LEFT_MOTOR_FORWARD, 0); }
}

However, all the L298's that I have, for example this:
https://www.amazon.com/DROK-Controller-H-Bridge-Mega2560-Duemilanove/dp/B00CAG6GX2
the speed control is the enable pin, not the FORWARD/BACKWARD pins.

So I am curious what board you have. Otherwise, I think this code must be in error- you're supposed to PWM the enable pins, not the motor direction pins.

How and where to call get_encoder_counts in arduino_driver.py?

I am using custom encoder by directly connecting it to interrupt pins in Arduino UNO. I have enabled #define ARDUINO_ENC_COUNTER
I am able to get encoder's value by sending 'e' on Arduino's serial monitor.
How to publish this message to ROS?

As addressed in Issue #34, which states to call function get_encoder_counts in file "arduino_driver.py" in which it sends command to serial and returns data fetching from serial. How to proceed with calling the function?

Wont compile for NodeMCU (esp8266 boards)?

Below is the debug message i recieved on the arduino IDE

ROSArduinoBridge:125: error: 'int index' redeclared as different kind of symbol int index = 0; ^ In file included from /home/chris/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/stdlib.h:11:0, Multiple libraries were found for "Servo.h" Used: /home/chris/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/Servo Not used: /opt/arduino-1.8.4/libraries/Servo from /home/chris/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/cores/esp8266/Arduino.h:27, from /home/chris/Arduino/ROSArduinoBridge/ROSArduinoBridge.ino:79: /home/chris/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/string.h:55:8: error: previous declaration of 'char* index(const char*, int)' char *_EXFUN(index,(const char *, int)); ^ /home/chris/Arduino/ROSArduinoBridge/ROSArduinoBridge.ino: In function 'void resetCommand()': ROSArduinoBridge:149: error: assignment of function 'char* index(const char*, int)' index = 0; ^ ROSArduinoBridge:149: error: cannot convert 'int' to 'char*(const char*, int)' in assignment /home/chris/Arduino/ROSArduinoBridge/ROSArduinoBridge.ino: In function 'void loop()': ROSArduinoBridge:295: error: invalid types 'char [16][char*(const char*, int)]' for array subscript if (arg == 1) argv1[index] = NULL; ^ ROSArduinoBridge:296: error: invalid types 'char [16][char*(const char*, int)]' for array subscript else if (arg == 2) argv2[index] = NULL; ^ ROSArduinoBridge:305: error: invalid types 'char [16][char*(const char*, int)]' for array subscript argv1[index] = NULL; ^ ROSArduinoBridge:307: error: assignment of function 'char* index(const char*, int)' index = 0; ^ ROSArduinoBridge:307: error: cannot convert 'int' to 'char*(const char*, int)' in assignment ROSArduinoBridge:318: error: invalid types 'char [16][char*(const char*, int)]' for array subscript argv1[index] = chr; ^ ROSArduinoBridge:319: error: ISO C++ forbids incrementing a pointer of type 'char* (*)(const char*, int)' [-fpermissive] index++; ^ ROSArduinoBridge:319: error: lvalue required as increment operand ROSArduinoBridge:322: error: invalid types 'char [16][char*(const char*, int)]' for array subscript argv2[index] = chr; ^ ROSArduinoBridge:323: error: ISO C++ forbids incrementing a pointer of type 'char* (*)(const char*, int)' [-fpermissive] index++; ^ ROSArduinoBridge:323: error: lvalue required as increment operand exit status 1 'int index' redeclared as different kind of symbol

Can not find what encoder counter to get

After many hours of troubleshooting, I still can not read encoder counts on pin 2 and pin 3. I have tried different uno's, different encoders, looking at the encoder pwm with an oscilloscope, reading and writing to pin 2 and 3 (which works), change to other ports... Any advice would be greatly appreciated.

I decided I may break down and use a mega with an encoder counter. Since the robogaia is discontinued, does anyone have advice on what other encoder counter works with the recommended motor drivers?

Publisher needs queue size

Shouldn't lines such as following line 166 of arduino_sensors.py

self.pub = rospy.Publisher("~sensor/" + self.name, Range)

be changed to include queue_size as follows

self.pub = rospy.Publisher("~sensor/" + self.name, Range, queue_size=10)

as well as other similar files in the ros_arduino_bridge software?

Without the queue_size being defined, several errors were reported when executing:

roslaunch ros_arduino_python arduino.launch

Problem with encoder readings on A4 A5

I have tried setup the connections properly , while testing i am always getting flawed reading (almost static ) on the Analog ports . I am using an Arduino UNO , the encoders are connected directly to the arduino .

For the motor control , i am using L298.

What should i do to change , to change the A4,A5 pin to any of the portD pins .

`
/* Interrupt routine for LEFT encoder, taking care of actual counting */
ISR (PCINT2_vect){
static uint8_t enc_last=0;

enc_last <<=2; //shift previous state two places
enc_last |= (PIND & (3 << 2)) >> 2; //read the current state into lowest 2 bits

left_enc_pos += ENC_STATES[(enc_last & 0x0f)];

}

/* Interrupt routine for RIGHT encoder, taking care of actual counting */
ISR (PCINT1_vect){
static uint8_t enc_last=0;

enc_last <<=2; //shift previous state two places
enc_last |= (PINC & (3 << 4)) >> 4; //read the current state into lowest 2 bits

right_enc_pos += ENC_STATES[(enc_last & 0x0f)];

}`

What should i change here?

Encoder reading using Ardunio Mega

I can send PWM signal to the motor and it responds well I am trying to read the encoder value using e but it always shows "0 0"
I modified motor_driver.h according to where my encoder PINs are connected I am using Arduino mega interrupt PINS PIN2,PIN3 AND PIN20,PIN21 for the left and right encoder

/* *************************************************************
   Encoder driver function definitions - by James Nugen
   ************************************************************ */
   
   
#ifdef ARDUINO_ENC_COUNTER
  //below can be changed, but should be PORTD pins; 
  //otherwise additional changes in the code are required
  #define LEFT_ENC_PIN_A 20  
  #define LEFT_ENC_PIN_B 21  
  
  //below can be changed, but should be PORTC pins
  #define RIGHT_ENC_PIN_A 2 
  #define RIGHT_ENC_PIN_B 3  
#endif
   
long readEncoder(int i);
void resetEncoder(int i);
void resetEncoders();

Does this package support non-pololu drivers?

I am using my own motor driver instead of pololu drivers.
Do this package support the drivers other than which it is developed for., in that case what are all the changes need to be done?

How to get encoder position in ros node?

I am reading the encoder pins by using the ros arduino bridge, where i am subscribing to the encoder pins inside my ros node i.e a c++ program. Here every time a new pin value arrives in program all its variables are reset. But as i saw the encoder programs one variable has to store the privious encoder position, so how can it be done in c++. The arduino program to read encoder is:

[
/* Rotary encoder read example */
#define ENC_A 14
#define ENC_B 15
#define ENC_PORT PINC

void setup()
{
  /* Setup encoder pins as inputs */
  pinMode(ENC_A, INPUT);
  digitalWrite(ENC_A, HIGH);
  pinMode(ENC_B, INPUT);
  digitalWrite(ENC_B, HIGH);
  Serial.begin (115200);
  Serial.println("Start");
}

void loop()
{
 static uint8_t counter = 0;      //this variable will be changed by encoder input
 int8_t tmpdata;
 /**/
  tmpdata = read_encoder();
  if( tmpdata ) {
    Serial.print("Counter value: ");
    Serial.print(counter, DEC);
    counter += tmpdata;
  }
}

/* returns change in encoder state (-1,0,1) */
int8_t read_encoder()
{
  static int8_t enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
  static uint8_t old_AB = 0;
  /**/
  old_AB <<= 2;                   //remember previous state
  old_AB |= ( ENC_PORT & 0x03 );  //add current state
  return ( enc_states[( old_AB & 0x0f )]);
}](url)
/* Rotary encoder read example */
#define ENC_A 14
#define ENC_B 15
#define ENC_PORT PINC

void setup()
{
  /* Setup encoder pins as inputs */
  pinMode(ENC_A, INPUT);
  digitalWrite(ENC_A, HIGH);
  pinMode(ENC_B, INPUT);
  digitalWrite(ENC_B, HIGH);
  Serial.begin (115200);
  Serial.println("Start");
}

void loop()
{
 static uint8_t counter = 0;      //this variable will be changed by encoder input
 int8_t tmpdata;
 /**/
  tmpdata = read_encoder();
  if( tmpdata ) {
    Serial.print("Counter value: ");
    Serial.print(counter, DEC);
    counter += tmpdata;
  }
}

/* returns change in encoder state (-1,0,1) */
int8_t read_encoder()
{
  static int8_t enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
  static uint8_t old_AB = 0;
  /**/
  old_AB <<= 2;                   //remember previous state
  old_AB |= ( ENC_PORT & 0x03 );  //add current state
  return ( enc_states[( old_AB & 0x0f )]);
}](url)returns change in encoder state (-1,0,1) */
int8_t read_encoder()
{
  static int8_t enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
  static uint8_t old_AB = 0;
  /**/
  old_AB <<= 2;                   //remember previous state
  old_AB |= ( ENC_PORT & 0x03 );  //add current state
  return ( enc_states[( old_AB & 0x0f )]);
}](url)

Currentely my roscpp program is:

[#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <iostream>
#include <ros_arduino_msgs/Digital.h>
using namespace ros_arduino_msgs;
using namespace message_filters;

void callback(const DigitalConstPtr& e1, const DigitalConstPtr& e2)
{ 
  std::cout<<"callback"<<std::endl;
  std::cout<<e1<<std::endl;
}

int main(int argc, char** argv)
{
  ros::init(argc, argv, "vision_node");
  std::cout<<"main"<<std::endl;
  ros::NodeHandle nh;
  message_filters::Subscriber<Digital> e1(nh, "/arduino/sensor/left_encoder_A", 10);
  message_filters::Subscriber<Digital> e2(nh, "/arduino/sensor/left_encoder_B", 10);
  TimeSynchronizer<Digital, Digital> sync(e1, e2, 10);
  sync.registerCallback(boost::bind(&callback, _1, _2));

  ros::spin();

  return 0;
}](url)

Now in the callback function how do i program the encoder? Here since every time the ros node subscribes to a new topic all the parameters inside the program is also reset, i am getting the problem.

encoder command 'e' gives invalid command error

I am following this tutorial. Here all other commands works except the command e which gives the position of the encoder. Here i think because of this error when i use given encoder pins as sensor in yaml file, its output only gives always same value either 0 or 1, even if i rotate the encoder shaft. My yaml file is:

port: /dev/ttyACM0
baud: 57600
timeout: 0.1

rate: 50
sensorstate_rate: 10

use_base_controller: False
base_controller_rate: 10

base_frame: base_link

sensors: {
  #motor_current_left:   {pin: 0, type: PololuMotorCurrent, rate: 5},
  #motor_current_right:  {pin: 1, type: PololuMotorCurrent, rate: 5},
  #ir_front_center:      {pin: 2, type: GP2D12, rate: 10},
  #sonar_front_center:   {pin: 5, type: Ping, rate: 10},
  encoder_A:           {pin: 2, type: Digital, rate: 5, direction: output},
  encoder_B:           {pin: 3, type: Digital, rate: 5, direction: output}
}

# Joint name and configuration is an example only
joints: {
    head_tilt_joint: {pin: 5, init_position: 0, init_speed: 90, neutral: 90, min_position: -90, max_position: 90, invert: False, continuous: False}
}

When i run arduino encoder code and upload it in the board, the encoder is working fine, it shows output in the serial monitor of the arduino but when i upload the ros arduino bridge the encoder pin values always comes same. I am using ros indigo and i'm using master brance of ros arduino bridge since indigo branch was not working properly.

Encoder reading trouble

We are trying to use this package for our differential drive robot. The left encoder is returning negative values, however when we modify the encoder_driver.ino with "0-left_enc_pos;" the left motor recieves 255 PWM singnal.

long readEncoder(int i)
{
if (i == LEFT) return 0-left_enc_pos;
else (i == RIGHT) return right_enc_pos;
}

It fixes the encoder values, but it affects somthing else. Same thing happens if we change the encoder wires.

Any tips on how to fix this?

When I complete the whole installation, I can not push command through /cmd_vel topic?

I complete install the ros arduino bridge, and can send command "m 20 20" through serial port to controll the car.
But I run "roslaunch ros_arduino_python arduino.launch" and I can see the topic like below:

/arduino/sensor/arduino_led
/arduino/sensor_state
/cmd_vel
/odom
/rosout
/rosout_agg
/tf

But I can not controll the car through command "rostopic pub -1 /cmd_vel geometry_msgs/Twist '{ angular: {z: 0.5} }'"
Why?? Can anyone answer?

Problem Launching the ros_arduino_python Node

I have a problem when running: roslaunch ros_arduino_python arduino.launch
I get this message: [arduino.launch] is neither a launch file in package [ros_arduino_python] nor is [ros_arduino_python] a launch file name
The traceback for the exception was written to the log file
I don't know what is wrong, help

  1. my_arduino_params.yaml has to be located in the /home/user/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/config folder or where
  2. how do i know if the ros_arduino_python is correctly installed
  3. the arduino ide has to be open or closed?

im running over Ros-indigo and Ubuntu 14.04

please let me know your comments

Problem with loading type ros_arduino_msgs/ServoWrite

When I ran command for controlling servo I got an error: "Unable to load type [ros_arduino_msgs/ServoWrite]". The same error appeared for reading servo and writing to digital pin. What I missed during installation and configuration your package?

Using Ctrl+C on an Embedded Board can cause re-connection problem

I cannot connect the Arduino board after I used Ctrl+C to terminate the ros_arduino_python/arduino.launch
I get:

Connecting to Arduino on port /dev/ARDUINOBASE ...
Serial Exception:
(<class 'serial.serialutil.SerialException'>, SerialException(), <traceback object at 0xb5f57a80>)
Traceback follows:
Traceback (most recent call last):
File "/root/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/src/ros_arduino_python/arduino_driver.py", line 73, in connect
raise SerialException
SerialException
Cannot connect to Arduino!

Hardware List:
UP-level computer: OrangePi running lubuntu 14.04
Low-level board: Arduino Mega 2560 with CH340(usb-serial converter)

Error while compiling ROSArduinoBridge

I followed the given steps and installed the sketch files to the sketchbook folder. I also installed the dependent sketches of motor and encoder but when i tried to compile the code i get the below error

> ROSArduinoBridge.cpp.o: In function `loop':
/usr/share/arduino/ROSArduinoBridge.ino:280: undefined reference to `MegaEncoderCounter::YAxisGetCount()'
/usr/share/arduino/ROSArduinoBridge.ino:325: undefined reference to `MegaEncoderCounter::XAxisGetCount()'
/usr/share/arduino/ROSArduinoBridge.ino:335: undefined reference to `MegaEncoderCounter::YAxisReset()'
/usr/share/arduino/ROSArduinoBridge.ino:335: undefined reference to `MegaEncoderCounter::XAxisReset()'
/usr/share/arduino/ROSArduinoBridge.ino:335: undefined reference to `DualVNH5019MotorShield::init()'
/usr/share/arduino/ROSArduinoBridge.ino:335: undefined reference to `DualVNH5019MotorShield::setM1Speed(int)'
/usr/share/arduino/ROSArduinoBridge.ino:335: undefined reference to `DualVNH5019MotorShield::setM2Speed(int)'
/usr/share/arduino/ROSArduinoBridge.ino:335: undefined reference to `MegaEncoderCounter::XAxisGetCount()'
/usr/share/arduino/ROSArduinoBridge.ino:335: undefined reference to `MegaEncoderCounter::XAxisGetCount()'
/usr/share/arduino/ROSArduinoBridge.ino:335: undefined reference to `MegaEncoderCounter::MegaEncoderCounter(unsigned char)'
/usr/share/arduino/ROSArduinoBridge.ino:335: undefined reference to `DualVNH5019MotorShield::DualVNH5019MotorShield()'
collect2: error: ld returned 1 exit status

Project idea: link pin to signal type instead of component

Hello,

This might not be the good place to post, but I haven't found any other suitable forum/maillist.
I've been playing with ros_arduino_bridge a little bit and I've found it useful.
Though I'd like to share a few ideas which might improve it, they mainly consider the project
on functional/logical structure but don't specify the implementation.

I like the way you can configure sensors as ANALOG/DIGITAL. But for other components (motors/servos) you prefer to have it's own 'driver' uploaded to the arduino. This is logical, as sending PWM/PPM signals over a serial connection might be overkill if you can avoid it. But I don't like the fact that for each component, you need it's 'driver' uploaded on arduino alongside the ROSArduinoBridge and specify separate commands (in commands.h) if you wish to use it.
It could be a good idea to link pins to signal types instead of components.
Examples of signal types could be PWM, PPM, AC, DIGITAL(slow changing digital signal),
ANALOG, ADC (Analog signal converted to digital on arduino).

  • The methods to process each signal type are also uploaded to the arduino.
  • The signal processing on the arduino depends only on the signal type.
  • There is shared configuration file for ros_arduino_python (used for creating ros node) and ROSArduinoBridge (upload code depending on config),
    there are currently already 2 configuration sites (arduino_params and the #DEFINE statements in ROSArduinoBridge), configuring each pin to own it's own signal type could allow to unite these.
  • commands.h goes away. Instead there are fixed commands which are related to function which influence the characteristics of each signal type,
    thus: instead of " m (motor speed) 9(on pin 9) ", you define that a pin typed by a PWM signal has certain functions which relate to it's characteristics (period, frequency, duty cycle). Having a more generic code uploaded to the arduino would mean that you'd have to implement the PID control in ROS.
  • The ROSArduinoBridge uploaded to arduino contains a few generic methods unrelated to signal types. One of these methods is configurePin(pin, type), which would allow the signal on the pin to be processed on a different way.

The end result would be a more generic code uploaded to the arduino, which only has to be uploaded once and can be dynamically configured. This would be a bit of a mix between ros_arduino_bridge and rosserial.

This is merely a concept and I have no idea on how realizable this concept is. The backbone of it thus consists of linking pins to signal types (with generic libraries) instead of components (with specific 'drivers'/libraries).
Any thoughts would be appreciated.
If you know a better place to post this message, let me know.

kind regards,
Dieter

Error running rosmake

Following the directions in the README I get errors from rosmake (ROS Groovy).

pi@raspberrypi:/ros_ws$ git clone https://github.com/hbrobotics/ros_arduino_bridge.git
Cloning into 'ros_arduino_bridge'...
remote: Counting objects: 287, done.
remote: Compressing objects: 100% (123/123), done.
remote: Total 287 (delta 138), reused 261 (delta 122)
Receiving objects: 100% (287/287), 78.22 KiB, done.
Resolving deltas: 100% (138/138), done.
pi@raspberrypi:
/ros_ws$ cd ros_arduino_bridge
pi@raspberrypi:~/ros_ws/ros_arduino_bridge$ rosmake
[ rosmake ] rosmake starting...
[ rosmake ] No package or stack specified. And current directory 'ros_arduino_bridge' is not a package name or stack name.
[ rosmake ] Packages requested are: []
[ rosmake ] Logging to directory /home/pi/.ros/rosmake/rosmake_output-20130609-151954
[ rosmake ] Expanded args [] to:
[]
[ rosmake ] ERROR: No arguments could be parsed into valid package or stack names.

roslaunch ERROR

When I use roslaunch ros_arduino_python arduino.launch, I get this: ERROR: cannot launch node of type [ros_arduino_python/arduino_node.py]: can't locate node [arduino_node.py] in package [ros_arduino_python].

SyntaxError: unqualified exec is not allowed in function 'from_meta' it contains a nested function with free variables

I got the below error when i tried to run the launch file

roslaunch ros_arduino_python arduino.launch

Traceback (most recent call last): File "/home/chris/final_ws/src/ros_arduino_bridge/ros_arduino_python/nodes/arduino_node.py", line 23, in <module> from ros_arduino_python.arduino_driver import Arduino File "/home/chris/final_ws/src/ros_arduino_bridge/ros_arduino_python/src/ros_arduino_python/arduino_driver.py", line 29, in <module> from serial.serialutil import SerialException File "/usr/local/lib/python2.7/dist-packages/serial/__init__.py", line 17, in <module> from serial import errors, utilities, properties, meta, hooks, test, model File "/usr/local/lib/python2.7/dist-packages/serial/hooks.py", line 15, in <module> from serial import model File "/usr/local/lib/python2.7/dist-packages/serial/model.py", line 1406 exec('%s\n\n%s' % (imports, class_definition), namespace)

motor encoder in Arduino mega 2560

The code gives the implement of motor encoder in arduino Uno, If I want to get the motor encoder count through arduino mega 2560, How should I change?

Can anyone help??

Does ros_arduino_bridge support imu

rencently,i use the ros_arduino_bridge and it works very well.Then i try to do navigation,so i want to add imu to my arduino mega,but i find that it is so difficult to add the other sensors.so can you give me some adviece to add imu to the ros_arduino_bridge. Thank you!

Wrong pin assignment in L298N motor_driver

In motor_driver file for L298N motor driver support - LEFT spd and RIGHT spd pins are exchanged.
Pls correct. Although this is a very small issue, i got very frustrated by it.

Usage question

does ros_arduino_bridge only work according to the communication protocol you wrote? Or can we customize the communication protocol format? I found that the warehouse seems to be a bit old now, is there anyone to maintain it now? Or did someone update some features?

encode problem

if I stired the wheels with my hand,the encoder have numbers.but i input m 50 50,wheels can not stop in 2000ms ,i can not understand where the errors are?

problem reading both encoders

I have an arduino uno on board and when i put 'e'(read encoders) after moving both motors with (m 50 50, or any numbers), i dont have the same or proximate reading, i get something like this: 2 3259, refering 2--> to the left encoder counter, and 3259 the right encoder counter, my connections are
Left wheel encoder A output -- Arduino UNO pin 2
Left wheel encoder B output -- Arduino UNO pin 3

Right wheel encoder A output -- Arduino UNO pin A4
Right wheel encoder B output -- Arduino UNO pin A5

i've tried to change left encoder pins but i get always similar results
wich could be the solution to this problem?

importError no module name tf.broadcaster

I have ros (kineti) running on a raspberry pi3 b+ usb interfaced to a Pro Micro (clone) microcontroller, I have the common_msgs installed and ran catkin_make also sourced devel/setup.bash. This error only occurs when I try to run with the base controller enabled. I wonder if I am missing some critical file. Can you point me in the correct direction? I followed the installation process on this site and can manually controller the motors(although I have not tuned the pid yet), and can read the encoders thru the arduino ide serial monitor. Best regards, and thank you for any suggestions.

Issues with encoder on pins 2 and 3

Hi,
I'm using ros_arduino_bridge with the Pololu 19:1 CPR motor encoders: https://www.pololu.com/product/2822
The motors and encoders are attached to an Arduino Nano or UNO.

I am consistently seeing the encoder counts on pins 2/3 downscaled by a factor of 40 (for example, while rotating the wheel 1 full revolution, the wheel on A4/A5 reports the right value and the . I read up on the other issues (#29), and noticed that some motor boards use pins 2/3 and so there is a way to make the ISR use another pair of pins. However, I am just using an unshielded Nano or UNO. Either way, I also tried pins 3/5 with the ISR code and the #defines changed as suggested in issue 29- when I do that, I get no readings at all.

To control for variables, I've tried swapping the motors (problem remains on pins 2/3). I've inspected the encoder wave forms, everything looks correct.

Are there other options, such as using PORTB, or mechanisms to debug why the (apparently correct) encoder pin changes aren't leading ot the right encoder counts?

Function 'readEncoder' is called with wrong arguments

Hi,

I guess there is an inconstancy in the Arduino firmware code.

Using ROBOGAIA encoder.
PATH: ros_arduino_bridge/ros_arduino_firmware/src/libraries/ROSArduinoBridge

In diff_controller.h:
Function 'readEncoder' is called with '0' and '1' and not 'LEFT' or 'RIGHT' as the wrapper expect.

Ex.:
leftPID.Encoder = readEncoder(0);
rightPID.Encoder = readEncoder(1);

Encoder count was not 4

I change the ros_arduino_bridge to for 4 mecanum,in start there is no problem because i only run just a little,but just now I find when I run a long time,it come the Encoder count was not 4,I print the values,see the values become [].

Hardware selection to implement the package.

I am developing ROS navigation robot, after some research i have zeroed on this package for differential drive and encoder reading. I have my Arduino UNO and planning to buy the this Pololu motor and motor driver.
Can i use my Arduino UNO to control motor and read quadrature encoder data(available in motor), if not what are all the boards i need to buy, only Robogaia encoder shield or also Arduino Mega.

PS: I read some posts noted that Arduino UNO and Mega cant handle the motor encoder because the they don't have enough clock speed. Required clock speed in 50MHz.

Robogaia 6 Encoders and SIX WHEELS

Hello,
i am making a 6 Wheels rover, at the beginning i used just imu without encoders but i get poor results.
Now i have encoders on the 6 motors connected to a robogaia 6 encoders counter (similar to the one used in the ros_arduino_bridge).
I understand how it works and it seems it's great but i need a little help in understanding how i can extend the software to a rover with 6 wheels.
Any help will be much appreciate

Fabio

ros indigo support?

Does this wonderful package work in ROS indigo?
Is this package still the 'best' way to use an arduino in a differential drive robot?
If so, can you add it to the ros software list and bump the wiki up to the newest version? Thanks.

Measurement Units and Dimensions

// #wheel_diameter: 0.146 //
// #wheel_track: 0.2969 //

What are the units for this parameters ?
I have 20cm diameter wheels = radius:10cm and the distance between them is 36 cm.

Thanks

Use Servo.h can't control second servo

Hi,

I cant realize how to work with two servos and their ID in servo.h It seems I can only control one. If someone could explain me more about this part would be great.

Regards.

Tried to add Kangaroo x2 to the Ros arduino bridge

In file included from /home/vanoramonster/catkin_ws/src/ros_arduino_bridge/ros_arduino_firmware/src/libraries/ROSArduinoBridge/ROSArduinoBridge.ino:88:0:
sketch/commands.h:14:0: warning: "PING" redefined
#define PING 'p'
^
In file included from /home/vanoramonster/arduino-1.8.5/hardware/tools/avr/avr/include/avr/iom2560.h:38:0,
from /home/vanoramonster/arduino-1.8.5/hardware/tools/avr/avr/include/avr/io.h:174,
from /home/vanoramonster/arduino-1.8.5/hardware/tools/avr/avr/include/avr/pgmspace.h:90,
from /home/vanoramonster/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Arduino.h:28,
from /home/vanoramonster/catkin_ws/src/ros_arduino_bridge/ros_arduino_firmware/src/libraries/ROSArduinoBridge/ROSArduinoBridge.ino:82:
/home/vanoramonster/arduino-1.8.5/hardware/tools/avr/avr/include/avr/iomxx0_1.h:239:0: note: this is the location of the previous definition
#define PING _SFR_IO8(0x12)

^
/home/vanoramonster/catkin_ws/src/ros_arduino_bridge/ros_arduino_firmware/src/libraries/ROSArduinoBridge/ROSArduinoBridge.ino: In function 'void resetCommand()':
/home/vanoramonster/catkin_ws/src/ros_arduino_bridge/ros_arduino_firmware/src/libraries/ROSArduinoBridge/ROSArduinoBridge.ino:146:7: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
cmd = NULL;
^
/home/vanoramonster/catkin_ws/src/ros_arduino_bridge/ros_arduino_firmware/src/libraries/ROSArduinoBridge/ROSArduinoBridge.ino: In function 'void loop()':
/home/vanoramonster/catkin_ws/src/ros_arduino_bridge/ros_arduino_firmware/src/libraries/ROSArduinoBridge/ROSArduinoBridge.ino:298:34: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
if (arg == 1) argv1[index] = NULL;
^
/home/vanoramonster/catkin_ws/src/ros_arduino_bridge/ros_arduino_firmware/src/libraries/ROSArduinoBridge/ROSArduinoBridge.ino:299:39: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
else if (arg == 2) argv2[index] = NULL;
^
/home/vanoramonster/catkin_ws/src/ros_arduino_bridge/ros_arduino_firmware/src/libraries/ROSArduinoBridge/ROSArduinoBridge.ino:308:22: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
argv1[index] = NULL;
^
libraries/SoftwareSerial/SoftwareSerial.cpp.o (symbol from plugin): In function SoftwareSerial::read()': (.text+0x0): multiple definition of __vector_11'
sketch/ROSArduinoBridge.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
/home/vanoramonster/arduino-1.8.5/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld: Disabling relaxation: it will not work with multiple definitions
libraries/SoftwareSerial/SoftwareSerial.cpp.o (symbol from plugin): In function SoftwareSerial::read()': (.text+0x0): multiple definition of __vector_10'
sketch/ROSArduinoBridge.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

firmware command problem

I am using serial monitor to send command to arduino mega 2560, and LED of RX blink every time I send commands, but it outputs nothing. I read the whole readme file twice, but I didn't find any problems. I think this problem is related to issues #27 .

Update for Noetic?

Awesome Wiki, made it all the way to launching the arduino python node https://github.com/hbrobotics/ros_arduino_bridge/tree/master#launching-the-ros_arduino_python-node before realizing it was written for Indigo:-( Sadly Noetic seems to throw an error. Is it just me, anyone have this working on Noetic?

RLException: error loading <rosparam> tag: file /home/ubuntu/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/config/my_arduino_params.yaml contains invalid YAML: while parsing a block mapping in "<unicode string>", line 6, column 1: port: /dev/ttyACM0 ^ expected <block end>, but found '<scalar>' in "<unicode string>", line 26, column 2: === PID parameters ^ XML is <rosparam file="$(find ros_arduino_python)/config/my_arduino_params.yaml" command="load"/> The traceback for the exception was written to the log file

how to subscribe encoder value in ros node

How can i subscribe the encoder value in ros node and than use it? I tried below code but its no use:

#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <iostream>
#include <ros_arduino_msgs/Digital.h>
using namespace ros_arduino_msgs;
using namespace message_filters;

void callback(const DigitalConstPtr& e1, const DigitalConstPtr& e2)
{ 
  std::cout<<"callback"<<std::endl;
  std::cout<<e1<<std::endl;
}

int main(int argc, char** argv)
{
  ros::init(argc, argv, "vision_node");
  std::cout<<"main"<<std::endl;
  ros::NodeHandle nh;
  message_filters::Subscriber<Digital> e1(nh, "/arduino/sensor/left_encoder_A", 10);
  message_filters::Subscriber<Digital> e2(nh, "/arduino/sensor/left_encoder_B", 10);
  TimeSynchronizer<Digital, Digital> sync(e1, e2, 10);
  sync.registerCallback(boost::bind(&callback, _1, _2));

  ros::spin();

  return 0;
}

My arduino ros yaml file is:

# For a direct USB cable connection, the port name is typically
# /dev/ttyACM# where is # is a number such as 0, 1, 2, etc
# For a wireless connection like XBee, the port is typically
# /dev/ttyUSB# where # is a number such as 0, 1, 2, etc.

port: /dev/ttyACM0
baud: 57600
timeout: 0.1

rate: 50
sensorstate_rate: 10

use_base_controller: False
base_controller_rate: 10

base_frame: base_link

sensors: {
  right_encoder_A:    {pin: 18, type: Digital, rate: 5, direction: output},
  right_encoder_B:   {pin: 19, type: Digital, rate: 5, direction: output}
}

# Joint name and configuration is an example only
joints: {
    joint1: {pin: 3, init_position: 0, init_speed: 90, neutral: 90, min_angle: -90, max_angle: 90, invert: False, continous: False},
    joint2: {pin: 5, init_position: 0, init_speed: 90, neutral: 90, min_angle: -90, max_angle: 90, invert: False, continous: False},
    joint3: {pin: 6, init_position: 0, init_speed: 90, neutral: 90, min_angle: -90, max_angle: 90, invert: False, continous: False}
}

Does ros_arduino_bridge support a gyro or imu?

I am using ros_arduino_bridge to operate an arduino-based robot and it works well both for odometry and motor driving. However, I want to add a gyro to enable better calibration and also to then have the functionality of a turtlebot. Then it is easy to add additional sensors such as a kinect.

I know that I could write stand-alone routines to feed the gyro data directly, but it is a hurdle to get a sufficient understanding of nav msgs and figure out the details of how to correctly publish that data. Since ros_arduino_bridge does such a nice job with wheel odometry, I am hoping that there is a way to incorporate gyro data.

I posted this question to ros.answers.org as well.

Also just want to say thanks for developing this stack. It works superbly and is very well documented. Appreciate the effort!

hydro-devel: ImportError: No module named ros_arduino_python.arduino_driver

I was trying the hydro-devel version for the first time (under ROS Hydro of course) and after doing a catkin_make without errors I got the following error when trying to launch the arduino_python.py node:

process[arduino-1]: started with pid [24163]
Traceback (most recent call last):
File "/home/patrick/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/nodes/arduino_node.py", line 24, in
from ros_arduino_python.arduino_driver import Arduino
ImportError: No module named ros_arduino_python.arduino_driver

How to use encoder sensor in ros arduino bridge

How can i read the encoder position by using the ros arduino bridge. I want to read the position of the servo motor by using the encoder by connecting encoder to the shaft of the servo motor. Does ros arduino bridge provides encoder as a sensor also. If no, how can i implement it?
I am using ros arduino bridge instead of ros_serial because i also want to run other programs like image processing and kinematics in the main computer. arduino is only acting as the bridge which connects the main computer and the sensors / motors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.