Remote I/O error with jetbot

hey everyone,

I’m trying to test out my recently built sparkfun jetbot kit for the first time. I installed and cloned all the repo’s etc but hit a snag when i input:

“rosrun jetbot_ros jetbot motors.py”

and got this error:

Traceback (most recent call last):
File “/home/turkey/catkin_ws/src/jetbot_ros/scripts/jetbot_motors.py”, line 75, in
motor_driver = Adafruit_MotorHAT(i2c_bus=1)
File “/home/turkey/.local/lib/python2.7/site-packages/Adafruit_MotorHAT/Adafruit_MotorHAT_Motors.py”, line 231, in init
self._pwm = PWM(addr, debug=False, i2c=i2c, i2c_bus=i2c_bus)
File “/home/turkey/.local/lib/python2.7/site-packages/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py”, line 59, in init
self.setAllPWM(0, 0)
File “/home/turkey/.local/lib/python2.7/site-packages/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py”, line 95, in setAllPWM
self.i2c.write8(self.__ALL_LED_ON_L, on & 0xFF)
File “/home/turkey/.local/lib/python2.7/site-packages/Adafruit_GPIO/I2C.py”, line 114, in write8
self._bus.write_byte_data(self._address, register, value)
File “/home/turkey/.local/lib/python2.7/site-packages/Adafruit_PureIO/smbus.py”, line 268, in write_byte_data
self._device.write(data)
IOError: [Errno 121] Remote I/O error

Is this a connection problem? I have a micro-usb to usb connectiong the jetbot to the nano and qwic pHat on the IO pins of the nano. The motor driver and other proper connections are made according to sparkfun’s assembly documentation.

Anyone got any ideas? Thanks!

hello nbarrow85,

you may also share the python code to show which line cause the Remote I/O error.
however, it seems there’s i2c access.
could you please enable a standard linux tools to verify the node, i.e. i2cget ;
you may also have a try to add some delay before reading the content through I2C.
thanks

Hey Jerry,

Thanks for responding. Bear with me because I’m a newb. I input:

cd ~

and then input:

i2cget

within the command line and got this output:

Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]
I2CBUS is an integer or an I2C bus name
ADDRESS is an integer (0x03 - 0x77)
MODE is one of:
b (read byte data, default)
w (read word data)
c (write byte/read byte)
Append p for SMBus PEC

I should also point out I’m now trying to execute the same commands that I was having trouble with earlier when I posted, however I’m attempting it once more via ssh now. Instead I’m getting a slightly different error when I input:
“rosrun jetbot_ros
jetbot_motors.py”

The error I now get is:

Traceback (most recent call last):
File “/home/turkey/catkin_ws/src/jetbot_ros/scripts/jetbot_motors.py”, line 75, in
motor_driver = Adafruit_MotorHAT(i2c_bus=1)
File “/home/turkey/.local/lib/python2.7/site-packages/Adafruit_MotorHAT/Adafruit_MotorHAT_Motors.py”, line 231, in init
self._pwm = PWM(addr, debug=False, i2c=i2c, i2c_bus=i2c_bus)
File “/home/turkey/.local/lib/python2.7/site-packages/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py”, line 59, in init
self.setAllPWM(0, 0)
File “/home/turkey/.local/lib/python2.7/site-packages/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py”, line 95, in setAllPWM
self.i2c.write8(self.__ALL_LED_ON_L, on & 0xFF)
File “/home/turkey/.local/lib/python2.7/site-packages/Adafruit_GPIO/I2C.py”, line 114, in write8
self._bus.write_byte_data(self._address, register, value)
File “/home/turkey/.local/lib/python2.7/site-packages/Adafruit_PureIO/smbus.py”, line 268, in write_byte_data
self._device.write(data)
IOError: [Errno 110] Connection timed out

I can’t seem to use gedit to access the script-is this because I’m using ssh to run headless?

hello nbarrow85,

please assign the i2c bus and also register address behind i2cget to access your register content.
you may also google it around for the samples of the usage.

you should note that there’re graphic UIs of gedit editor; it could not enabled via ssh.
please have a try with vi or vim editor.
thanks

Hey,

So I hooked my nano up to a monitor and keyboard and used gedit to look at the jetbot_ros.py script and the various lines mentioned. I’m new to programming but I found it strange that the file only had a total number of 98 lines while the error mentions line ‘112’, ‘231’ and ‘268’. So although I wasn’t sure how to account for those lines I did check out the other lines. I’ve included the entire script below for you to look at:

"#!/usr/bin/env python
import rospy
import time

from Adafruit_MotorHAT import Adafruit_MotorHAT
from std_msgs.msg import String

sets motor speed between [-1.0, 1.0]

def set_speed(motor_ID, value):
max_pwm = 115.0
speed = int(min(max(abs(value * max_pwm), 0), max_pwm))

if motor_ID == 1:
	motor = motor_left
elif motor_ID == 2:
	motor = motor_right
else:
	rospy.logerror('set_speed(%d, %f) -> invalid motor_ID=%d', motor_ID, value, motor_ID)
	return

motor.setSpeed(speed)

if value > 0:
	motor.run(Adafruit_MotorHAT.FORWARD)
else:
	motor.run(Adafruit_MotorHAT.BACKWARD)

stops all motors

def all_stop():
motor_left.setSpeed(0)
motor_right.setSpeed(0)

motor_left.run(Adafruit_MotorHAT.RELEASE)
motor_right.run(Adafruit_MotorHAT.RELEASE)

directional commands (degree, speed)

def on_cmd_dir(msg):
rospy.loginfo(rospy.get_caller_id() + ’ cmd_dir=%s’, msg.data)

raw L/R motor commands (speed, speed)

def on_cmd_raw(msg):
rospy.loginfo(rospy.get_caller_id() + ’ cmd_raw=%s’, msg.data)

simple string commands (left/right/forward/backward/stop)

def on_cmd_str(msg):
rospy.loginfo(rospy.get_caller_id() + ’ cmd_str=%s’, msg.data)

if msg.data.lower() == "left":
	set_speed(motor_left_ID,  -1.0)
	set_speed(motor_right_ID,  1.0) 
elif msg.data.lower() == "right":
	set_speed(motor_left_ID,   1.0)
	set_speed(motor_right_ID, -1.0) 
elif msg.data.lower() == "forward":
	set_speed(motor_left_ID,   1.0)
	set_speed(motor_right_ID,  1.0)
elif msg.data.lower() == "backward":
	set_speed(motor_left_ID,  -1.0)
	set_speed(motor_right_ID, -1.0)  
elif msg.data.lower() == "stop":
	all_stop()
else:
	rospy.logerror(rospy.get_caller_id() + ' invalid cmd_str=%s', msg.data)

initialization

if name == ‘main’:

# setup motor controller
motor_driver = Adafruit_MotorHAT(i2c_bus=1)

motor_left_ID = 1
motor_right_ID = 2

motor_left = motor_driver.getMotor(motor_left_ID)
motor_right = motor_driver.getMotor(motor_right_ID)

# stop the motors as precaution
all_stop()

# setup ros node
rospy.init_node('jetbot_motors')

rospy.Subscriber('~cmd_dir', String, on_cmd_dir)
rospy.Subscriber('~cmd_raw', String, on_cmd_raw)
rospy.Subscriber('~cmd_str', String, on_cmd_str)

# start running
rospy.spin()

# stop motors before exiting
all_stop()

"

Perhaps most interesting to me is that line 75 makes explicit reference to an Adafruit product-a motorhat. My jetbot is not being driven by any adafruit products however. I am instead using a Sparkfun kit. Is this the source of the error?

hello nbarrow85,

please check Jetbot_ROS for the README.md,
please ensure you’d complete all prerequisites before testing JetBot.
thanks

hey,

So I cloned in the sparkfun repo’s for their jetson nano compatible boards (‘QWIC’) but doesn’t the jetbot_motors.py need to modified so that it can accommodate the non-adafruit hardware?

hello nbarrow85,

why don’t you clone Jetbot_ROS, it shows the steps to work NVIDIA JetBot with Jetson Nano.

Yeah, I think there’s some miscommunication. I believe the NVIDIA jetbot makes use of Adafruit hardware-such as a motorhat and a driver. I own the Sparkfun jetbot which uses it’s own motor controlling boards. The jetbot_ros repo incorporates the adafruit libraries, but not any of sparkfun’s…

I found one thread on Sparkfun’s site that addressed this:
https://forum.sparkfun.com/viewtopic.php?f=107&t=54647

Within this forum, someone said that they found success via a sparkfun repo for their hardware here:

I cloned this repo into my ~/catkin_ws/src as well as all necessary dependencies and then input catkin_make. It seemned to be successful. I then input:
“source ~/catkin_ws/devel/setup.bash”

I tried mnodifying the rosrun command from the jetbot_ros repo to accommodate the sparkfun package and .py script but then I received this error:
“[rospack] Error: package ‘Qwiic_SCMD_Py’ not found”

I found this strange since I thought I had properly sourced my dev space. I tried inputting “rospack jetbot_ros” and verified that rospack is working. So now I’m confused. Why can’t rospack find this package? When I cd to ~/catkin_ws/src and input “ls” the package appears to be there. I may just ask for a request on the repo for code that can accommodate the sparkfun hardware…

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

hello nbarrow85,

it looks Jetson Nano is one of supported platforms,
had you also complete the installation for dependency package, for example, qwiic I2C driver: Qwiic_I2C_Py.
thanks