mirror of
https://github.com/YikeStone/ros_arduino_bridge.git
synced 2025-08-03 19:24:09 +05:30
added code for arduino pwm output
This commit is contained in:
parent
e0f00edf8c
commit
d83dcb8cb6
@ -15,6 +15,7 @@ add_service_files(FILES
|
||||
DigitalWrite.srv
|
||||
ServoRead.srv
|
||||
ServoWrite.srv
|
||||
AnalogWrite.srv
|
||||
)
|
||||
|
||||
generate_messages(
|
||||
|
@ -77,6 +77,9 @@ class ArduinoROS():
|
||||
# A service to turn a digital sensor on or off
|
||||
rospy.Service('~digital_write', DigitalWrite, self.DigitalWriteHandler)
|
||||
|
||||
# A service to set pwm values for the pins
|
||||
rospy.Service('~analog_write', AnalogWrite, self.AnalogWriteHandler)
|
||||
|
||||
# Initialize the controlller
|
||||
self.controller = Arduino(self.port, self.baud, self.timeout)
|
||||
|
||||
@ -174,6 +177,10 @@ class ArduinoROS():
|
||||
self.controller.digital_write(req.pin, req.value)
|
||||
return DigitalWriteResponse()
|
||||
|
||||
def AnalogWriteHandler(self, req):
|
||||
self.controller.analog_write(req.pin, req.value)
|
||||
return AnalogWriteRrsponse()
|
||||
|
||||
def shutdown(self):
|
||||
# Stop the robot
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user