Updated README file to include instructions on setting permissions on the serial port

This commit is contained in:
Patrick Goebel 2013-02-24 17:40:51 -08:00
parent d9d0c8b2a8
commit e0fcbbfec8
2 changed files with 46 additions and 8 deletions

View File

@ -29,7 +29,7 @@ Official ROS Documentation
-------------------------- --------------------------
A standard ROS-style version of this documentation can be found on the ROS wiki at: A standard ROS-style version of this documentation can be found on the ROS wiki at:
http://www.ros.org/wiki/ros_arduino_bridge http://www.ros.org/wiki/ros\_arduino\_bridge
System Requirements System Requirements
@ -54,13 +54,46 @@ sketchbook/libraries directory.
Finally, it is assumed you are using version 1.0 or greater of the Finally, it is assumed you are using version 1.0 or greater of the
Arduino IDE. 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:
Installation $ 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 ~/ros_workspace $ cd ~/ros_workspace
$ git clone https://github.com/hbrobotics/ros_arduino_bridge.git $ git clone https://github.com/hbrobotics/ros\_arduino\_bridge.git
$ cd ros_arduino_bridge $ cd ros\_arduino\_bridge
$ rosmake $ rosmake
The provided Arduino library is called ROSArduinoBridge and is The provided Arduino library is called ROSArduinoBridge and is
@ -122,6 +155,8 @@ 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. 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: The list of commands can be found in the file commands.h. The current list includes:
<pre> <pre>

View File

@ -25,7 +25,7 @@ import thread
from math import pi as PI, degrees, radians from math import pi as PI, degrees, radians
import os import os
import time import time
import sys import sys, traceback
from serial.serialutil import SerialException from serial.serialutil import SerialException
from serial import Serial from serial import Serial
@ -68,15 +68,18 @@ class Arduino:
test = self.get_baud() test = self.get_baud()
if test != self.baudrate: if test != self.baudrate:
time.sleep(1) time.sleep(1)
test = self.get_baud() test = self.get_baud()
if test != self.baudrate: if test != self.baudrate:
raise SerialException raise SerialException
print "Connected at", self.baudrate print "Connected at", self.baudrate
print "Arduino is ready." print "Arduino is ready."
except SerialException: except SerialException:
print "Serial Exception:"
print sys.exc_info()
print "Traceback follows:"
traceback.print_exc(file=sys.stdout)
print "Cannot connect to Arduino!" print "Cannot connect to Arduino!"
print "Make sure you are plugged in and turned on."
os._exit(1) os._exit(1)
def open(self): def open(self):