In the ninth part of the Jetson RACECAR build, we install the Sparkfun Razor IMU ROS package. Looky here:
Background
After installing the Sparkfun Razor IMU on the Jetson RACECAR, we’re ready to prepare the driver software packages which enable the IMU to communicate with ROS.
The ROS wiki page for the Razor IMU 9DOF provides excellent instructions for installing the razor_imu_9dof package. There are also instructions on how to calibrate the IMU which we will visit at a later time.
The Sparkfun Razor IMU 10736 that we are using in this project has a built-in micro controller. The micro controller is programmed using Arduino software. For this ROS application, an AHRS Ardunio sketch will be uploaded to the IMU micro controller. Here is a great read about how the sketch actually works.
Installation
The Razor IMU interfaces with the Jetson using a FTDI serial to USB converter. This article assumes that the kernel supports FTDI, and that ROS is installed on the Jetson. Here is an article which covers how to build the kernel with FTDI support and install ROS.
The installRazorIMUROS repository on the JetsonHacks Github account contains helper scripts for the install process. First clone the repository and switch to the repository directory:
$ git clone https://github.com/jetsonhacks/installRazorIMUROS.git
$ cd installRazorIMUROS
If you have not already built a Catkin Workspace for the project, you may run the script:
$ ./setupCatkinWorkspace.sh jetsonbot
which will setup a Catkin Workspace named ‘jetsonbot’ in the ~/ directory. You may name the workspace with whatever you feel comfortable with. If you leave the name off of the command line the script is running from, then a default ‘catkin_ws’ directory will be created.
The setupCatkinWorkspace shell file modifies the .bashrc file in ~/ to include the some extra information about the ROS environment. You will want to review that information to make sure that it matches your installation.
Install the Razor IMU ROS Package
Next, we’re ready to install the razor_imu_9dof ROS package. There is a convenience script:
$ ./installRazor.sh
Let’s take a look at it:
#!/bin/sh
# Install the Razor IMU ROS package
sudo apt-get install ros-indigo-razor-imu-9dof -y
# For visualizing, you’ll need these python packages
sudo apt-get install python-visual python-wxgtk2.8 -y
# To put firmaware on the Razor, you’ll need the Arduino software
sudo apt-get install arduino arduino-core -y
The script first installs the ROS Indigo package razor_imu_9dof.
Next, the script installs a python visualization package. In the video, the demonstration uses the visualizer to show the orientation of the IMU and heading in a graphics environment. The visualizer is optional.
Finally the script installs the Arduino software, version 1.0. The Arduino software uploads compiled sketches to the Razor IMU.
Note: In the video I used the term ‘flash’ interchangeably with upload the sketch.
Uploading the Arduino Script
After installation, prepare to upload the AHRS script to the Razor IMU.
Switch to the Catkin Workspace, i.e.
$ cd ~/jetsonbot
# source the devel
$ source devel/setup.bash
Note: During development you may want to place the ‘source devel/setup.bash’ into your .bashrc file so you do not have to source it every time you open a new Terminal.
Next, copy the script to the Arduino sketchbook directory:
$ roscd razor_imu_9dof
$ cp -r src/Razor_AHRS ~/sketchbook/Razor_AHRS // Jetson TK1 uses Arduino 1.0 software
You can then use a file browser to navigate to the ~/sketchbook directory and open the Razor_AHRS folder. Double click on the Razor_AHRS.ino file, which will bring up the Arduino software.
In the sketch editor, find ‘Hardware Options’. Uncomment which device is being used, in this case the 10736. Save the sketch.
Now is the time to setup the Arduino software to talk with the IMU:
- Go to “Tools” → “Board” and select “Arduino Pro or Pro Mini (3.3v, 8mhz) w/ATmega328”. Note: in Aduino 1.5+, the board menu doesn’t allow selecting the voltage/frequency; go to the Processor menu after selecting “Arduino Pro or Pro Mini” and select “ATMega 328 (3.3V, 8Mhz)”
- Go to “Tools” → “Serial Port” and select the port used with the Razor.
- Go to “File” and hit “Upload”. After a short while at the bottom of the Arduino code window it should say “Done uploading”.
Once the sketch is done uploading, it’s ready to talk with ROS!
Demo
To run the demos, you should make a copy of the configuration data. In a Terminal, go to the jetsonbot directory and source the devel. Then:
$ roscd razor_imu_9dof/config
$ sudo cp razor.yaml my_razor.yaml
You can then go back to the jetsonbot directory. Then start roscore:
$ roscore
To publish the IMU data, open another Terminal, go to the jetsonbot directory, and source the devel. Then:
$ roslaunch razor_imu_9dof razor-pub.launch
You can then use the commands ‘rostopic list’ and ‘rostopic echo /imu’ to see the data being published.
In order to see the visualization, stop the razor-pub.launch process (CtrlC does nicely here) then:
$ roslaunch razor_imu_9dof razor-pub-and-dislay.launch
After a few moments, the IMU will begin publishing data and you will be able to change the orientation of the IMU sensor and see the results on a monitor.
Conclusion
Like most ROS packages, actually installing the Razor IMU ROS package is fairly easy. The one thing that’s a little different in this install is that the AHRS firmware needs uploading to the IMU before running the device. The ROS wiki instructions are very good, you should read them for further information.
The post Jetson RACECAR Part 9 – Razor IMU ROS Install appeared first on JetsonHacks.