forked from ros-drivers/rosserial
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ros-drivers#2 in PHEN/rosserial from update_upstre…
…am to jade-devel * commit 'a707373c7e9f9ad40ad9440550840e29960c9290': Changed hardcoded pin 13 to LED_BUILTIN (ros-drivers#328) Re-attempting rosserial for VEX Cortex (ros-drivers#380) Added service to force an Arduino hard reset in serial_node.py (ros-drivers#349) Fix compiling on boost > 1.66 (ros-drivers#362) Use the ! prefix introduced in gcc4mbed for mbed examples (ros-drivers#304) Add support for boolean parameters (ros-drivers#355) Change Travis to use clang-5.0.0 (ros-drivers#363) [python] fix an unboundlocalerror (ros-drivers#346) Added ESP32 support (ros-drivers#345) Retry opening the serial port every 3 seconds (ros-drivers#342) In rosserial_arduino, changed embedded type size for ROS uint64 to 8 bytes from 4. (ros-drivers#312) 0.7.7 Changes Copy src/examples to install dir so make_libraries.py doesn't fail (ros-drivers#336) Add overall spin timeout to rosserial read. (ros-drivers#334) Fixing formatting on files. (ros-drivers#333) Fix catkin lint errors (ros-drivers#296)
- Loading branch information
Showing
111 changed files
with
2,412 additions
and
998 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
*.swp | ||
rosserial_server/doc/ | ||
*.user* | ||
*.out | ||
*.geany | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,38 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(rosserial_arduino) | ||
|
||
find_package(catkin REQUIRED COMPONENTS message_generation) | ||
find_package(catkin REQUIRED COMPONENTS | ||
message_generation | ||
) | ||
|
||
add_message_files(FILES | ||
Adc.msg | ||
) | ||
Adc.msg | ||
) | ||
|
||
add_service_files(FILES | ||
Test.srv | ||
) | ||
Test.srv | ||
) | ||
|
||
catkin_python_setup() | ||
|
||
generate_messages() | ||
|
||
catkin_package( | ||
CATKIN_DEPENDS message_runtime | ||
CFG_EXTRAS rosserial_arduino-extras.cmake | ||
CFG_EXTRAS ${PROJECT_NAME}-extras.cmake | ||
) | ||
|
||
install(DIRECTORY src/ros_lib | ||
install( | ||
DIRECTORY src/ros_lib | ||
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/src | ||
) | ||
|
||
install(DIRECTORY arduino-cmake | ||
install( | ||
DIRECTORY arduino-cmake | ||
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} | ||
) | ||
|
||
install(PROGRAMS src/rosserial_arduino/make_libraries.py | ||
catkin_install_python( | ||
PROGRAMS src/${PROJECT_NAME}/make_libraries.py nodes/serial_node.py | ||
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} | ||
) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env python | ||
|
||
##################################################################### | ||
# Software License Agreement (BSD License) | ||
# | ||
# Copyright (c) 2011, Willow Garage, Inc. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above | ||
# copyright notice, this list of conditions and the following | ||
# disclaimer in the documentation and/or other materials provided | ||
# with the distribution. | ||
# * Neither the name of Willow Garage, Inc. nor the names of its | ||
# contributors may be used to endorse or promote products derived | ||
# from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
import rospy | ||
from rosserial_arduino import SerialClient | ||
from serial import SerialException | ||
from time import sleep | ||
|
||
import sys | ||
|
||
if __name__=="__main__": | ||
|
||
rospy.init_node("serial_node") | ||
rospy.loginfo("ROS Serial Python Node") | ||
|
||
port_name = rospy.get_param('~port','/dev/ttyUSB0') | ||
baud = int(rospy.get_param('~baud','57600')) | ||
|
||
# Number of seconds of sync failure after which Arduino is auto-reset. | ||
# 0 = no timeout, auto-reset disabled | ||
auto_reset_timeout = int(rospy.get_param('~auto_reset_timeout','0')) | ||
|
||
# for systems where pyserial yields errors in the fcntl.ioctl(self.fd, TIOCMBIS, \ | ||
# TIOCM_DTR_str) line, which causes an IOError, when using simulated port | ||
fix_pyserial_for_test = rospy.get_param('~fix_pyserial_for_test', False) | ||
|
||
# TODO: do we really want command line params in addition to parameter server params? | ||
sys.argv = rospy.myargv(argv=sys.argv) | ||
if len(sys.argv) >= 2 : | ||
port_name = sys.argv[1] | ||
|
||
while not rospy.is_shutdown(): | ||
rospy.loginfo("Connecting to %s at %d baud" % (port_name, baud)) | ||
try: | ||
client = SerialClient(port_name, baud, fix_pyserial_for_test=fix_pyserial_for_test, auto_reset_timeout=auto_reset_timeout) | ||
client.run() | ||
except KeyboardInterrupt: | ||
break | ||
except SerialException: | ||
sleep(1.0) | ||
continue | ||
except OSError: | ||
sleep(1.0) | ||
continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env python | ||
|
||
from distutils.core import setup | ||
from catkin_pkg.python_setup import generate_distutils_setup | ||
|
||
d = generate_distutils_setup( | ||
packages=['rosserial_arduino'], | ||
package_dir={'': 'src'}, | ||
) | ||
|
||
setup(**d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file modified
0
rosserial_arduino/src/ros_lib/examples/ServiceClient/client.py
100755 → 100644
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env python | ||
|
||
##################################################################### | ||
# Software License Agreement (BSD License) | ||
# | ||
# Copyright (c) 2011, Willow Garage, Inc. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above | ||
# copyright notice, this list of conditions and the following | ||
# disclaimer in the documentation and/or other materials provided | ||
# with the distribution. | ||
# * Neither the name of Willow Garage, Inc. nor the names of its | ||
# contributors may be used to endorse or promote products derived | ||
# from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
import time | ||
|
||
import rospy | ||
from std_srvs.srv import Empty, EmptyResponse | ||
|
||
from serial import Serial | ||
|
||
from rosserial_python import SerialClient as _SerialClient | ||
|
||
MINIMUM_RESET_TIME = 30 | ||
|
||
class SerialClient(_SerialClient): | ||
|
||
def __init__(self, *args, **kwargs): | ||
# The number of seconds to wait after a sync failure for a sync success before automatically performing a reset. | ||
# If 0, no reset is performed. | ||
self.auto_reset_timeout = kwargs.pop('auto_reset_timeout', 0) | ||
self.lastsync_reset = rospy.Time.now() | ||
rospy.Service('~reset_arduino', Empty, self.resetArduino) | ||
super(SerialClient, self).__init__(*args, **kwargs) | ||
|
||
def resetArduino(self, *args, **kwargs): | ||
""" | ||
Forces the Arduino to perform a reset, as though its reset button was pressed. | ||
""" | ||
with self.read_lock, self.write_lock: | ||
rospy.loginfo('Beginning Arduino reset on port %s. Closing serial port...' % self.port.portstr) | ||
self.port.close() | ||
with Serial(self.port.portstr) as arduino: | ||
arduino.setDTR(False) | ||
time.sleep(3) | ||
arduino.flushInput() | ||
arduino.setDTR(True) | ||
time.sleep(5) | ||
rospy.loginfo('Reopening serial port...') | ||
self.port.open() | ||
rospy.loginfo('Arduino reset complete.') | ||
self.lastsync_reset = rospy.Time.now() | ||
self.requestTopics() | ||
return EmptyResponse() | ||
|
||
def sendDiagnostics(self, level, msg_text): | ||
super(SerialClient, self).sendDiagnostics(level, msg_text) | ||
# Reset when we haven't received any data from the Arduino in over N seconds. | ||
if self.auto_reset_timeout and (rospy.Time.now() - self.last_read).secs >= self.auto_reset_timeout: | ||
if (rospy.Time.now() - self.lastsync_reset).secs < MINIMUM_RESET_TIME: | ||
rospy.loginfo('Sync has failed, but waiting for last reset to complete.') | ||
else: | ||
rospy.loginfo('Sync has failed for over %s seconds. Initiating automatic reset.' % self.auto_reset_timeout) | ||
self.resetArduino() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from SerialClient import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.