How to access GPIO with ROS-MELODIC?

JetPack 4.3


I have a Jetson Nano and Adafruit Motor Shield v3. After looking over the documentation for the Motor Shield it appear that you can talk to it with 3/5V I2C. So I thought about going down the rabbit hole to try and access the GPIO from a ROS package.

Is there a file that I can include like a header file (e.g. gpio.h) that would facilitate such an endeavor?

I think it would be neat to send commands directly instead of using ROS Serial and an arduino with a shield installed.



hello CoachAllen,

you might refer to Topic 1030443 for tutorials showing how to use GPIO.
please access L4T sources via download center. you should check the gpio definition as below.
for example,


I’m newbie at Ubuntu and ROS. I’m trying to use Jetson Nano 's GPIO within a ROS subscriber node. But I’m getting this error:

File “/home/hostr/hostr_ws/src/motor_controller/script/”, line 3, in
import Jetson.GPIO as GPIO
ImportError: No module named Jetson.GPIO

and this is the code:

#!/usr/bin/env python

import rospy
import Jetson.GPIO as GPIO
from geometry_msgs.msg import Twist

def setupGPIO(pENA,pENB,pIN1):
GPIO.setup(ENA, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(IN1, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(IN2, GPIO.OUT, initial=GPIO.LOW)

def callback(data):

def listener():

rospy.init_node('motor_controllerpy', anonymous=True)
rospy.Subscriber("cmd_vel", Twist, callback)

if name == ‘main’:
ENA = 33
IN1 = 35
IN2 = 37

I looked to the link has given but i understand nothing. If someone can help me, I’ll be glad.


Hi infohost.robotic,

Please help to open a new topic for your issue. Thanks