ESC Control with PCA9685 on Jetson Nano (Jetson Hacks - RaceCar

Hi,

I am trying to build my own version of the Jetson Hacks RaceCar using a Jetson Nano instead of the board they use. I have the car physically built, and have control of the steering servo with the use of a PCA9685, but run into issues trying to control the ESC.
Following the Jetson Hacks tutorials, I set up the steering control as per their video ( Jetson RACECAR Part 2 - Steering Control - YouTube ), though I did run into an issue and get some errors when running the command ‘make’. This has been found and fixed on their GitHub repo, it was an issue using Ubuntu 18 and changes in the i2c libraries. The fixes were:

ADD
g++ servoExample.cpp …/src/JHPWMPCA9685.cpp -li2c -I…/src -o servoExample

to the makefile and

ADD
extern “C”
{
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
}
to ‘JHPWMPCA9685.h’ and this fixed the issue allowing me to run their steering example, great!

Fixes can be seen here ( Some changes to Makefile and src/JHPWMPCA9685.h by younjinjeong · Pull Request #2 · jetsonhacks/JHPWMDriver · GitHub )

Moving onto the throttle control, following this tutorial: Jetson RACECAR Part 3 - Motor ESC Control - YouTube
I run into an error:
‘undefined reference to i2c_smbus_read_byte_data’ and ‘undefined reference to i2c_smbus_write_byte_data’

My limited knowledge tells me this is likely to be the same issue as before, and I have added:
extern “C”
{
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
}
to ‘jetsonRACECAR/research/setThrottle/JHPWMPCA9685.h’

but assume I also need to edit the make file as before.

My issue is, what do I add and to where in these files? The repo I have cloned is: GitHub - jetsonhacks/jetsonRACECAR: Working area for the Jetson RACECAR Project

Sorry for the late response, is this still an issue to support? Thanks

It is, yeah please!

Hi C.Walker,

Thanks for reaching out!

The you error mentioned

undefined reference to i2c_smbus_read_byte_data’ and ‘undefined reference to i2c_smbus_write_byte_data

Means that the code being compiled references the functions i2c_smbus_read_byte_data and i2c_smbus_write_byte_data, but the implementation of those methods cannot be found.

These functions are likely defined in a shared library that you’ll need to link against.

Could you try linking against the i2c library and see if that helps? I think you have done this in the Makefile you shared for the servo example. (you have the flag -li2c).

Please let me know if this helps or you run into any issues.

Best,
John

Hi,
Thanks for the help. Where in the Makefile would I add this -li2c? It was straight forward to understand in the servo example as there was only one line of code in there to start with. I’m not so sure with this one.

Thanks

You are referring to an older library, which is for Ubuntu 16.04. The smbus libraries were moved around under 18.04. Here is an updated article on how to use the new library: Jetson Nano - Using I2C - JetsonHacks and the code is here: GitHub - JetsonHacksNano/ServoKit: Install the Adafruit ServoKit Circuit Python library on the NVIDIA Jetson Nano Developer Kit

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.