Added have_joints variable to top of script to prevent error when exiting node

This commit is contained in:
Patrick Goebel 2015-12-15 06:47:31 -08:00
parent 3559a4461a
commit dfebe5af8b

View File

@ -56,6 +56,9 @@ class ArduinoROS():
self.use_base_controller = rospy.get_param("~use_base_controller", False) self.use_base_controller = rospy.get_param("~use_base_controller", False)
# Assume we don't have any joints by default
self.have_joints = False
# Set up the time for publishing the next SensorState message # Set up the time for publishing the next SensorState message
now = rospy.Time.now() now = rospy.Time.now()
self.t_delta_sensors = rospy.Duration(1.0 / self.sensorstate_rate) self.t_delta_sensors = rospy.Duration(1.0 / self.sensorstate_rate)
@ -178,9 +181,7 @@ class ArduinoROS():
# #
# for controller in self.device.controllers: # for controller in self.device.controllers:
# controller.startup() # controller.startup()
else:
self.have_joints = False
# Initialize the base controller if used # Initialize the base controller if used
if self.use_base_controller: if self.use_base_controller:
self.myBaseController = BaseController(self.device, self.base_frame) self.myBaseController = BaseController(self.device, self.base_frame)
@ -279,7 +280,7 @@ class ArduinoROS():
rospy.loginfo("Detaching servos...") rospy.loginfo("Detaching servos...")
for joint in self.device.joints.values(): for joint in self.device.joints.values():
self.device.detach_servo(joint.pin) self.device.detach_servo(joint.pin)
rospy.sleep(0.1) rospy.sleep(0.2)
if __name__ == '__main__': if __name__ == '__main__':
myArduino = ArduinoROS() myArduino = ArduinoROS()