From 9614e9b29abf286b580781fcb42419d89b18f0ae Mon Sep 17 00:00:00 2001 From: Patrick Goebel Date: Sun, 23 Dec 2012 15:13:51 -0800 Subject: [PATCH] Changed from degrees to radians when specifying servos positions --- ros_arduino_firmware/manifest.xml | 2 +- .../MegaRobogaiaPololu/MegaRobogaiaPololu.ino | 2 -- .../src/libraries/MegaRobogaiaPololu/servos.h | 4 ++-- ros_arduino_msgs/manifest.xml | 2 +- ros_arduino_python/manifest.xml | 2 +- ros_arduino_python/src/arduino_driver.py | 13 +++++++++---- ros_arduino_python/src/arduino_driver.pyc | Bin 13942 -> 14252 bytes ros_arduino_python/src/arduino_sensors.py | 2 +- ros_arduino_python/src/arduino_sensors.pyc | Bin 12162 -> 12162 bytes stack.xml | 2 +- 10 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ros_arduino_firmware/manifest.xml b/ros_arduino_firmware/manifest.xml index d601871..245bdf3 100644 --- a/ros_arduino_firmware/manifest.xml +++ b/ros_arduino_firmware/manifest.xml @@ -1,7 +1,7 @@ - ros_arduino_firmware + ROS Arduino Firmware Patrick Goebel diff --git a/ros_arduino_firmware/src/libraries/MegaRobogaiaPololu/MegaRobogaiaPololu.ino b/ros_arduino_firmware/src/libraries/MegaRobogaiaPololu/MegaRobogaiaPololu.ino index ccbae63..0f66429 100644 --- a/ros_arduino_firmware/src/libraries/MegaRobogaiaPololu/MegaRobogaiaPololu.ino +++ b/ros_arduino_firmware/src/libraries/MegaRobogaiaPololu/MegaRobogaiaPololu.ino @@ -208,8 +208,6 @@ int runCommand() { #ifdef USE_SERVOS case SERVO_WRITE: servos[arg1].write(arg2); - Serial.print(arg1); - Serial.print(arg2); Serial.println("OK"); break; case SERVO_READ: diff --git a/ros_arduino_firmware/src/libraries/MegaRobogaiaPololu/servos.h b/ros_arduino_firmware/src/libraries/MegaRobogaiaPololu/servos.h index 4a0d92d..6100723 100644 --- a/ros_arduino_firmware/src/libraries/MegaRobogaiaPololu/servos.h +++ b/ros_arduino_firmware/src/libraries/MegaRobogaiaPololu/servos.h @@ -1,11 +1,11 @@ /* Define the attachment of any servos here. - The example shows two servos attached on pins 3 and 6. + The example shows two servos attached on pins 3 and 5. */ #define N_SERVOS 2 Servo servos [N_SERVOS]; -byte servoPins [N_SERVOS] = {3, 6}; +byte servoPins [N_SERVOS] = {3, 5}; diff --git a/ros_arduino_msgs/manifest.xml b/ros_arduino_msgs/manifest.xml index dd70516..62ebb0b 100644 --- a/ros_arduino_msgs/manifest.xml +++ b/ros_arduino_msgs/manifest.xml @@ -1,7 +1,7 @@ - ros_arduino_msgs + ROS Arduino Messages Patrick Goebel diff --git a/ros_arduino_python/manifest.xml b/ros_arduino_python/manifest.xml index f12f132..1d04908 100644 --- a/ros_arduino_python/manifest.xml +++ b/ros_arduino_python/manifest.xml @@ -1,7 +1,7 @@ - ros_arduino_python + ROS Arduino Python Patrick Goebel diff --git a/ros_arduino_python/src/arduino_driver.py b/ros_arduino_python/src/arduino_driver.py index 1228437..c5f0e43 100755 --- a/ros_arduino_python/src/arduino_driver.py +++ b/ros_arduino_python/src/arduino_driver.py @@ -22,14 +22,17 @@ """ import thread -from math import pi as PI +from math import pi as PI, degrees, radians import os import time import sys from serial.serialutil import SerialException from serial import Serial -class Arduino: +SERVO_MAX = 180 +SERVO_MIN = 0 + +class Arduino: ''' Configuration Parameters ''' N_ANALOG_PORTS = 6 @@ -309,13 +312,15 @@ class Arduino: def servo_write(self, id, pos): ''' Usage: servo_write(id, pos) + Position is given in radians and converted to degrees before sending ''' - return self.execute_ack('s %d %d' %(id, pos)) + return self.execute_ack('s %d %d' %(id, min(SERVO_MAX, max(SERVO_MIN, degrees(pos))))) def servo_read(self, id): ''' Usage: servo_read(id) + The returned position is converted from degrees to radians ''' - return self.execute('t %d' %id) + return radians(self.execute('t %d' %id)) def ping(self, pin): ''' The srf05/Ping command queries an SRF05/Ping sonar sensor diff --git a/ros_arduino_python/src/arduino_driver.pyc b/ros_arduino_python/src/arduino_driver.pyc index 65e6182f305d054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wGb_sxjYCPOaK>D>Ym4m|dRJf-3Qb)huiMGo;Gv zTdrI4G%e+ET-|n0^x%#BlA-t4lX#2f{=wK$L)YouGyHw*J+TdI<4@w(+oNgSFfTQx zdXYh&p#-0ll3l9S7UuOm-Ht0ej+z^ow7nks*>O`$5ar4Lro+<{3AD!#{+9+3h?7Pf@?zOC|S$qy@;644W7-43FWiLSL4TjDAcU z)u@!JQXdw5E-bVQ)4OyBde~lP%*pDvw^6bel*`@~FL_wAUB1{p{ Qf2J^f-4CFESNDzl4Xzh>2mk;8 diff --git a/ros_arduino_python/src/arduino_sensors.py b/ros_arduino_python/src/arduino_sensors.py index ced0fa0..b3c6b24 100755 --- a/ros_arduino_python/src/arduino_sensors.py +++ b/ros_arduino_python/src/arduino_sensors.py @@ -72,7 +72,7 @@ class Sensor(object): else: self.msg.value = self.value - # At a timestamp and publish the message + # Add a timestamp and publish the message self.msg.header.stamp = rospy.Time.now() self.pub.publish(self.msg) diff --git a/ros_arduino_python/src/arduino_sensors.pyc b/ros_arduino_python/src/arduino_sensors.pyc index 5cdbfe2b3b78422fec35fd68623f1a334c596712..079bd6d3f95d2d7f40e45ba11ac113b385bdf930 100644 GIT binary patch delta 16 XcmZpQZ;EGU{>;nuKK;lIZg6%Zd$m3QE+_>} diff --git a/stack.xml b/stack.xml index e31df54..f4c5a70 100644 --- a/stack.xml +++ b/stack.xml @@ -1,5 +1,5 @@ - ros_arduino_bridge + ROS Arduino Bridge Maintained by Patrick Goebel BSD