Another couple of devices that will be needed for upcoming projects on the Jetson TX1 Development Kit are an IMU and a PWM driver for servo control. These devices can be interfaced over I2C. Looky here:
We have covered using the Bosch IMU BNO055 under ROS and the PWM/Servo Driver is based on a PCA9685 Breakout Board in earlier articles. This is just a short recap to discuss the differences between the earlier articles and this demonstration.
The parts used in the demonstration:
- Adafruit BNO055 IMU Breakout Board
- Adafruit 16-Channel 12-bit PWM/Servo Driver – I2C interface – PCA9685
- SparkFun USB Type A Female Breakout
- SparkFun microB USB Breakout
- Robot Geek Pan and Tilt Kit w/ Servos – Available from Trossen Robotics (This kit was used in the video. Your application will determine which analog servos you wish to use).
- Power Jack Adapter (In the video, A female DC Power Jack 5.5mm x 2.1mm CCTV Power Jack Adapter
- Power Adapter for Servo(s) (In the video, a 6V 1A AC Adapter To DC Power Adapter 5.5/2.1mm
was used). Note: The selection of the power adapter is dependent on the servos being used. You will need to select something that provides enough power at the correct voltage for your application. This is very important! For example, if this were a “real” application rather than a demo, I would have probably used a 2A adapter.
Both of these devices can interface with the Jetson TX1 using I2C. We have covered using I2C with the Jetson in an earlier article. In this demonstration, we use the same I2C pins as in the previous article, the Jetson TX1 J21 pins 27 (SDA) and 28 (SCL). These are I2C_GP1_DAT and I2C_GP1_CLK respectively, on I2C bus 1. Both the PCA9685 and BNO055 are wired from these signals, and both use the 3.3V supply from J21 Pin 1, and GND from J21 Pin 6.
Note: Here is the Jetson TX1 J21 header pinout for reference. The GPIO numbers have not been verified by a third party, so use those at your own risk, but the signals should be correct.
The wiring is straightforward. The 3.3V goes to VCC on both the BNO055 and PCA9685, as does GND. SDA from the Jetson goes to both breakout boards, as does SCL. In the demonstration both of the devices were placed on separate prototyping boards, and a USB cable was connected to connect the two. A USB A breakout board and micro USB B female breakout board were used to carry the I2C signal from one breadboard to the next. On the USB breakout boards, 3.3V is wired to VCC, GND is wired to GND, SDA is wired to D+, SCL is wired to D-. On the micro USB B breakout, the remaining signal (ID) is not used. The cable used is the Jetson programming cable.
Note that this is for demonstration purposes only, for an actual application some calculations should be done to find an appropriate wiring solution.
The demonstration software is available in the JetsonHacks Github RTIMULib repository. RTIMULib is originally from from richards-tech LLC. Here is an article which gives a deeper talk about IMU stuff on that website.
To install the demonstration:
git clone https://github.com/jetsonhacks/RTIMULib.git
then open a file browser and navigate to ‘./RTIMULib/Linux/JetsonTX1DemoGL’. Then open the file ‘JetsonTX1DemoGL.pro’ with Qt Creator and compile the demo. Here’s an article we did a while ago on how to install Qt Creator.
After the file is finished building, go to where the executable file resides (this is dependent on how Qt Creator is configured) and execute the demo using ‘sudo’. For example:
$ sudo ./JetsonTX1DemoGL
At that point the demonstration should begin with the IMU orientation being displayed in a GUI, and the servos being positioned by the orientation of the IMU. Remember that this demonstration uses only two servos and is therefore a 2 Degree of Freedom (2 DOF) rig. That means that only two of the three axes will change the servo settings. In the demonstration the yaw (Z axis) and the roll change the servos.
Camera gimbals are typically controlled using input from an IMU, at which this demonstration begins to hint. Typically there is a known orientation where the user would like to point the camera. The IMU is mounted on the camera gimbal itself and reports back to a micro controller a pose. The micro controller then calculates the desired pose from the IMU pose, and positions the servos motors accordingly. Note that other types of motors can be used, such as the now more common gimbal motors, but the idea behind both are the same.
This type of servo setup can also be used for face tracking, though no IMU is needed in that case. A camera is mounted on the pan and tilt head. The camera takes a video feed and sends it to the Jetson which can then use a program such as OpenCV to detect faces in the image. Using this information, the Jetson can then position the servos so that the camera centers itself on the face that has been detected.