|
@@ -50,15 +50,15 @@ class ArduinoROS():
|
|
|
|
|
|
rospy.Service('~analog_read', AnalogRead, self.AnalogReadHandler)
|
|
|
|
|
|
-
|
|
|
- rospy.Service('~camera_control', CameraControl, self.CameraControlHandler)
|
|
|
-
|
|
|
|
|
|
rospy.Service('~dynamic_pid', DynamicPID, self.DynamicPIDHandler)
|
|
|
|
|
|
|
|
|
rospy.Service('~getInfraredDistance', GetInfraredDistance, self.GetInfraredDistanceHandler)
|
|
|
|
|
|
+
|
|
|
+ rospy.Service('~servo_write', ServoWrite, self.ServoWriteHandler)
|
|
|
+
|
|
|
|
|
|
rospy.on_shutdown(self.shutdown)
|
|
|
|
|
@@ -137,10 +137,6 @@ class ArduinoROS():
|
|
|
value = self.controller.analog_read(req.pin)
|
|
|
return AnalogReadResponse(value)
|
|
|
|
|
|
- def CameraControlHandler(self, req):
|
|
|
- self.controller.camera_angle(req.servo_id, req.servo_angle)
|
|
|
- return CameraControlResponse()
|
|
|
-
|
|
|
def GetInfraredDistanceHandler(self, req):
|
|
|
value = self.controller.detect_distance()
|
|
|
return GetInfraredDistanceResponse(value[0]/100.0, value[1]/100.0, value[2]/100.0)
|
|
@@ -150,6 +146,10 @@ class ArduinoROS():
|
|
|
req.value3, req.value4, 0, 50)
|
|
|
return DynamicPIDResponse()
|
|
|
|
|
|
+ def ServoWriteHandler(self, req):
|
|
|
+ self.controller.servo_write(req.servo_id, req.servo_angle)
|
|
|
+ return ServoWriteResponse()
|
|
|
+
|
|
|
|
|
|
def shutdown(self):
|
|
|
rospy.logwarn("Shutting down Arduino Node...")
|