Rosanswers logo

There are plenty of articles online about the Jetson GPIO but there's not much about using it with ROS.

Is there a simple way to integrate Jetson GPIO with ROS or do you have to control everything manually through your ROS cpp program?

Originally posted by jacksonkr_ on ROS Answers with karma: 396 on 2016-06-26

Post score: 3


1 Answer 1


Rosanswers logo

You can do it both ways. You can directly access the pins from your program with C++. The other approach is to write a node that uses topics or services to access or set the pins. For reference you can look at these resources from the wiki:

Writing a Simple Service and Client (C++)

Writing a Simple Publisher and Subscriber (C++)

I don't know how you are managing permissions on your robot, but for me to access GPIO on my Beaglebone, I just made sudo passwordless and then when my node launched, I chmodded the /dev/class/gpio folder to allow my user to access it. Hope this helps! luketheduke

Originally posted by luketheduke with karma: 285 on 2016-06-26

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by jacksonkr_ on 2016-06-26:
Great info! I'm glad you brought up permissions. I think I'll take your passwordless sudo approach. I have wifi / ssh on this machine but sudo won't apply unless someone is logged in so I should be good.

Comment by luketheduke on 2016-06-26:
Also, another thing to note is that if you are using the robot_upstart package to launch your nodes on boot, then you want to modify the source code for it to use sudo -u USERNAME instead of the setuid that it uses itself. In the unmodified state, robot_upstart doesn't play nice with GPIO.

Comment by luketheduke on 2016-06-26:
If this answer answers your question, please mark it solved by pressing the button below the upvote/downvote buttons. This helps improve the ROS community. Thanks, luketheduke

Comment by CoachAllen on 2020-01-15:
Is there an include statement for GPIO in C++? Like #include /jetson/gpio

Comment by luketheduke on 2020-01-15:
There are several different approaches to controlling GPIO with the Jetson. Because C++ is such a low level language here is the recommended approach from the Nvidia forums: https://devtalk.nvidia.com/default/topic/1052379/jetson-nano/how-to-use-gpio-in-c-language/post/5342398/#5342398 You can also try this library: https://github.com/brgl/libgpiod

Comment by CoachAllen on 2020-01-26:
So you would merely make the gpio availble to any package calling it?

Comment by luketheduke on 2020-04-20:
It depends on what approach you want to take, you could either integrate GPIO into every package that needed it or make one package that handles all GPIO and communicates over a topic/service.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.