mirror of
https://github.com/YikeStone/ros_arduino_bridge.git
synced 2025-08-03 11:14:08 +05:30
Merge pull request #12 from PTroester/hydro-devel
Added code to use the pwm output, hydro-devel
This commit is contained in:
commit
d201fddf48
@ -15,6 +15,7 @@ add_service_files(FILES
|
||||
DigitalWrite.srv
|
||||
ServoRead.srv
|
||||
ServoWrite.srv
|
||||
AnalogWrite.srv
|
||||
)
|
||||
|
||||
generate_messages(
|
||||
|
3
ros_arduino_msgs/srv/AnalogWrite.srv
Normal file
3
ros_arduino_msgs/srv/AnalogWrite.srv
Normal file
@ -0,0 +1,3 @@
|
||||
uint8 pin
|
||||
float32 value
|
||||
---
|
@ -76,8 +76,11 @@ 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
|
||||
# Initialize the controlller
|
||||
self.controller = Arduino(self.port, self.baud, self.timeout)
|
||||
|
||||
# Make the connection
|
||||
@ -173,7 +176,11 @@ class ArduinoROS():
|
||||
def DigitalWriteHandler(self, req):
|
||||
self.controller.digital_write(req.pin, req.value)
|
||||
return DigitalWriteResponse()
|
||||
|
||||
|
||||
def AnalogWriteHandler(self, req):
|
||||
self.controller.analog_write(req.pin, req.value)
|
||||
return AnalogWriteResponse()
|
||||
|
||||
def shutdown(self):
|
||||
# Stop the robot
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user