From 489debcdd5dc737809be80c4da1c4dc4f0d8df99 Mon Sep 17 00:00:00 2001 From: Patrick Goebel Date: Thu, 17 Dec 2015 16:17:25 -0800 Subject: [PATCH] Changed min_angle to min_position and max_angle to max_position to allow for joint types other than servos --- ros_arduino_python/config/arduino_params.yaml | 4 ++-- ros_arduino_python/config/servo_example_params.yaml | 2 +- .../src/ros_arduino_python/servo_controller.py | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ros_arduino_python/config/arduino_params.yaml b/ros_arduino_python/config/arduino_params.yaml index a53c852..eb7a587 100644 --- a/ros_arduino_python/config/arduino_params.yaml +++ b/ros_arduino_python/config/arduino_params.yaml @@ -51,6 +51,6 @@ sensors: { # Joint name and configuration is an example only joints: { - head_pan_joint: {pin: 3, init_position: 0, init_speed: 90, neutral: 90, min_angle: -90, max_angle: 90, invert: False, continous: False}, - head_tilt_joint: {pin: 5, init_position: 0, init_speed: 90, neutral: 90, min_angle: -90, max_angle: 90, invert: False, continous: False} + head_pan_joint: {pin: 3, init_position: 0, init_speed: 90, neutral: 90, min_position: -90, max_position: 90, invert: False, continuous: False}, + head_tilt_joint: {pin: 5, init_position: 0, init_speed: 90, neutral: 90, min_position: -90, max_position: 90, invert: False, continuous: False} } diff --git a/ros_arduino_python/config/servo_example_params.yaml b/ros_arduino_python/config/servo_example_params.yaml index 18596c1..c2504f5 100644 --- a/ros_arduino_python/config/servo_example_params.yaml +++ b/ros_arduino_python/config/servo_example_params.yaml @@ -27,5 +27,5 @@ sensors: { # Joint name and pin assignment is an example only joints: { - head_pan_joint: {pin: 3, init_position: 30, init_speed: 90, neutral: 90, min_angle: -90, max_angle: 90, invert: False, continous: False} + head_pan_joint: {pin: 3, init_position: 30, init_speed: 90, neutral: 90, min_position: -90, max_position: 90, invert: False, continuous: False} } diff --git a/ros_arduino_python/src/ros_arduino_python/servo_controller.py b/ros_arduino_python/src/ros_arduino_python/servo_controller.py index 3de3018..526f92f 100755 --- a/ros_arduino_python/src/ros_arduino_python/servo_controller.py +++ b/ros_arduino_python/src/ros_arduino_python/servo_controller.py @@ -64,8 +64,8 @@ class Servo(Joint): # Min/max/neutral values self.neutral = radians(rospy.get_param(n + "neutral", 90.0)) # degrees - self.max_angle = radians(rospy.get_param(n + "max_angle", 90.0)) # degrees - self.min_angle = radians(rospy.get_param(n + "min_angle", -90.0)) # degrees + self.max_position = radians(rospy.get_param(n + "max_position", 90.0)) # degrees + self.min_position = radians(rospy.get_param(n + "min_position", -90.0)) # degrees self.range = radians(rospy.get_param(n + "range", 180)) # degrees self.max_speed = radians(rospy.get_param(n + "max_speed", 250.0)) # deg/s @@ -88,11 +88,11 @@ class Servo(Joint): def command_cb(self, req): # Check limits - if req.data > self.max_angle: - req.data = self.max_angle + if req.data > self.max_position: + req.data = self.max_position - if req.data < self.min_angle: - req.data = self.min_angle + if req.data < self.min_position: + req.data = self.min_position # Adjust for the neutral offset if self.invert: