Robotics StackExchange | Archived questions

ros_arduino_brigde no connection after first connect

Hello,

i am using the rosarduinobridge on a Arduino UNO with encoders. Also i am using a Dagu Trex (arduino nano) whichs subscribes to the "cmd_vel". After i flashed the sketch to the Arduino, i can connect to the Arduino and use it. Works all perfect.

But when I close the node and want to connect to the Arduino again it is not possible. I checked the port and it is correct.

Once i reflash it works again until i reconnect again.

This is the log when i try to connect again:

 started roslaunch server http://ubuntu:33870/

SUMMARY
========

PARAMETERS
 * /arduino/Kd: 12
 * /arduino/Ki: 0
 * /arduino/Ko: 50
 * /arduino/Kp: 10
 * /arduino/accel_limit: 1.0
 * /arduino/base_controller_rate: 10
 * /arduino/base_frame: base_link
 * /arduino/baud: 57600
 * /arduino/encoder_resolution: 272
 * /arduino/gear_reduction: 1.0
 * /arduino/motors_reversed: False
 * /arduino/port: /dev/ttyUSB1
 * /arduino/rate: 50
 * /arduino/sensorstate_rate: 10
 * /arduino/timeout: 0.1
 * /arduino/use_base_controller: True
 * /arduino/wheel_diameter: 0.12
 * /arduino/wheel_track: 0.25
 * /rosdistro: jade
 * /rosserial_server/port: /dev/ttyUSB0
 * /rosversion: 1.11.20

NODES
  /
    arduino (ros_arduino_python/arduino_node.py)
    rosserial_message_info (rosserial_python/message_info_service.py)
    rosserial_server (rosserial_server/serial_node)
    rviz (rviz/rviz)
    teleop (teleop_twist_keyboard/teleop_twist_keyboard.py)

auto-starting new master
process[master]: started with pid [5307]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 881ad58a-9151-11e6-8bb2-6894237e958b
process[rosout-1]: started with pid [5320]
started core service [/rosout]
process[rosserial_server-2]: started with pid [5337]
process[rosserial_message_info-3]: started with pid [5338]
process[arduino-4]: started with pid [5348]
process[teleop-5]: started with pid [5352]
process[rviz-6]: started with pid [5353]
[ INFO] [1476369005.729067278]: rviz version 1.11.14
[ INFO] [1476369005.729188461]: compiled against Qt version 4.8.6
[ INFO] [1476369005.729241906]: compiled against OGRE version 1.9.0 (Ghadamon)
[ INFO] [1476369006.041779204]: Stereo is NOT SUPPORTED
[ INFO] [1476369006.042130605]: OpenGl version: 3 (GLSL 1.3).
[DEBUG] [WallTime: 1476369006.656749] init_node, name[/arduino], pid[5348]
[DEBUG] [WallTime: 1476369006.657364] binding to 0.0.0.0 0
[DEBUG] [WallTime: 1476369006.657810] bound to 0.0.0.0 60373
[DEBUG] [WallTime: 1476369006.664508] ... service URL is rosrpc://ubuntu:60373
[DEBUG] [WallTime: 1476369006.665048] [/arduino/get_loggers]: new Service instance
[DEBUG] [WallTime: 1476369006.668261] ... service URL is rosrpc://ubuntu:60373
[DEBUG] [WallTime: 1476369006.668744] [/arduino/set_logger_level]: new Service instance
/home/senintel/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/nodes/arduino_node.py:62: SyntaxWarning: The publisher should be created with an explicit keyword argument 'queue_size'. Please see http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers for more information.
  self.cmd_vel_pub = rospy.Publisher('cmd_vel', Twist)
/home/senintel/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/nodes/arduino_node.py:66: SyntaxWarning: The publisher should be created with an explicit keyword argument 'queue_size'. Please see http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers for more information.
  self.sensorStatePub = rospy.Publisher('~sensor_state', SensorState)
[DEBUG] [WallTime: 1476369006.708764] ... service URL is rosrpc://ubuntu:60373
[DEBUG] [WallTime: 1476369006.709069] [/arduino/servo_write]: new Service instance
[DEBUG] [WallTime: 1476369006.711850] ... service URL is rosrpc://ubuntu:60373
[DEBUG] [WallTime: 1476369006.712294] [/arduino/servo_read]: new Service instance
[DEBUG] [WallTime: 1476369006.720304] ... service URL is rosrpc://ubuntu:60373
[DEBUG] [WallTime: 1476369006.721411] [/arduino/digital_set_direction]: new Service instance
[DEBUG] [WallTime: 1476369006.724108] ... service URL is rosrpc://ubuntu:60373
[DEBUG] [WallTime: 1476369006.724412] [/arduino/digital_write]: new Service instance
[DEBUG] [WallTime: 1476369006.727408] ... service URL is rosrpc://ubuntu:60373
[DEBUG] [WallTime: 1476369006.727822] [/arduino/analog_write]: new Service instance
Connecting to Arduino on port /dev/ttyUSB1 ...
Traceback (most recent call last):
  File "/home/senintel/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/nodes/arduino_node.py", line 195, in <module>
    myArduino = ArduinoROS()
  File "/home/senintel/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/nodes/arduino_node.py", line 87, in __init__
    self.controller.connect()
  File "/home/senintel/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/src/ros_arduino_python/arduino_driver.py", line 68, in connect
    test = self.get_baud()
  File "/home/senintel/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/src/ros_arduino_python/arduino_driver.py", line 261, in get_baud
    return int(self.execute('b'));
  File "/home/senintel/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/src/ros_arduino_python/arduino_driver.py", line 178, in execute
    return int(value)
TypeError: int() argument must be a string or a number, not 'NoneType'
[INFO] [WallTime: 1476369013.950018] Stopping the robot...
[INFO] [WallTime: 1476369013.951215] Shutting down Arduino Node...
[arduino-4] process has died [pid 5348, exit code 1, cmd /home/senintel/catkin_ws/src/ros_arduino_bridge/ros_arduino_python/nodes/arduino_node.py __name:=arduino __log:=/home/senintel/.ros/log/881ad58a-9151-11e6-8bb2-6894237e958b/arduino-4.log].
log file: /home/senintel/.ros/log/881ad58a-9151-11e6-8bb2-6894237e958b/arduino-4*.log

And this is the arduino-4*.log:

[rospy.client][INFO] 2016-10-13 16:30:06,542: init_node, name[/arduino], pid[5348]
[xmlrpc][INFO] 2016-10-13 16:30:06,543: XML-RPC server binding to 0.0.0.0:0
[xmlrpc][INFO] 2016-10-13 16:30:06,543: Started XML-RPC server [http://ubuntu:36274/]
[rospy.init][INFO] 2016-10-13 16:30:06,543: ROS Slave URI: [http://ubuntu:36274/]
[rospy.impl.masterslave][INFO] 2016-10-13 16:30:06,543: _ready: http://ubuntu:36274/
[rospy.registration][INFO] 2016-10-13 16:30:06,545: Registering with master node http://localhost:11311
[xmlrpc][INFO] 2016-10-13 16:30:06,545: xml rpc node: starting XML-RPC server
[rospy.init][INFO] 2016-10-13 16:30:06,648: registered with master
[rospy.rosout][INFO] 2016-10-13 16:30:06,649: initializing /rosout core topic
[rospy.rosout][INFO] 2016-10-13 16:30:06,653: connected to core topic /rosout
[rospy.simtime][INFO] 2016-10-13 16:30:06,656: /use_sim_time is not set, will not subscribe to simulated time [/clock] topic
[rosout][DEBUG] 2016-10-13 16:30:06,656: init_node, name[/arduino], pid[5348]
[rosout][DEBUG] 2016-10-13 16:30:06,657: binding to 0.0.0.0 0
[rosout][DEBUG] 2016-10-13 16:30:06,657: bound to 0.0.0.0 60373
[rosout][DEBUG] 2016-10-13 16:30:06,664: ... service URL is rosrpc://ubuntu:60373
[rosout][DEBUG] 2016-10-13 16:30:06,664: [/arduino/get_loggers]: new Service instance
[rosout][DEBUG] 2016-10-13 16:30:06,668: ... service URL is rosrpc://ubuntu:60373
[rosout][DEBUG] 2016-10-13 16:30:06,668: [/arduino/set_logger_level]: new Service instance
[rosout][DEBUG] 2016-10-13 16:30:06,708: ... service URL is rosrpc://ubuntu:60373
[rosout][DEBUG] 2016-10-13 16:30:06,709: [/arduino/servo_write]: new Service instance
[rosout][DEBUG] 2016-10-13 16:30:06,711: ... service URL is rosrpc://ubuntu:60373
[rosout][DEBUG] 2016-10-13 16:30:06,712: [/arduino/servo_read]: new Service instance
[rosout][DEBUG] 2016-10-13 16:30:06,720: ... service URL is rosrpc://ubuntu:60373
[rosout][DEBUG] 2016-10-13 16:30:06,721: [/arduino/digital_set_direction]: new Service instance
[rosout][DEBUG] 2016-10-13 16:30:06,724: ... service URL is rosrpc://ubuntu:60373
[rosout][DEBUG] 2016-10-13 16:30:06,724: [/arduino/digital_write]: new Service instance
[rosout][DEBUG] 2016-10-13 16:30:06,727: ... service URL is rosrpc://ubuntu:60373
[rosout][DEBUG] 2016-10-13 16:30:06,727: [/arduino/analog_write]: new Service instance
[rospy.internal][INFO] 2016-10-13 16:30:06,797: topic[/rosout] adding connection to [/rosout], count 0
[rospy.internal][INFO] 2016-10-13 16:30:07,593: topic[/cmd_vel] adding connection to [/rosserial_server], count 0
[rospy.core][INFO] 2016-10-13 16:30:13,949: signal_shutdown [atexit]
[rosout][INFO] 2016-10-13 16:30:13,949: Stopping the robot...
[rosout][INFO] 2016-10-13 16:30:13,951: Shutting down Arduino Node...
[rospy.internal][INFO] 2016-10-13 16:30:13,958: topic[/rosout] removing connection to /rosout
[rospy.internal][INFO] 2016-10-13 16:30:13,959: topic[/cmd_vel] removing connection to /rosserial_server
[rospy.impl.masterslave][INFO] 2016-10-13 16:30:13,959: atexit

Asked by anonymous26353 on 2016-10-14 05:21:50 UTC

Comments

Can you please let us know what version of ROS you are using (e.g. Hydro, Indigo) and which branch of ros_arduino_bridge you are using (e.g. hydro-devel, indigo-devel).

Asked by Pi Robot on 2016-10-14 07:49:10 UTC

Hi, sorry i forgot to mention it.

Ros Distro : Jade
Branch : indigo-devel

Asked by anonymous26353 on 2016-10-14 11:34:07 UTC

I haven't tested the package with Jade, but try doing a "git pull" in your ros_arduino_bridge directory to get the latest indigo-devel updates. I pushed an update a few months ago that puts a try-except block around the get_baud() function.

Asked by Pi Robot on 2016-10-14 12:56:38 UTC

Answers