JetRacer ROS AI Kit Advanced Tutorial V: Install ROS System on Jetson Nano & Environment Configuration
Introduction
This guide provides comprehensive instructions for installing the ROS system and configuring the environment on a Jetson Nano. While using the pre-configured image provided is recommended, these steps will help you set up the system manually. Ensure a stable internet connection throughout the installation and configuration process. The tutorial uses Ubuntu 18.04 and ROS Melodic.
Step 1: Jetson Nano Programming System
-
Download Jetbot Image:
- Jetbot website: Jetbot GitHub
- 4G image version:
jetcard_nano-4gb-jp451.zip
-
Prepare SD Card:
- Use an SD card with at least 64GB capacity.
- Insert the SD card into the Jetson Nano.
- Connect the power to enable the device.
-
Network Configuration:
-
Connect the network cable and log in via SSH.
-
Scan available WiFi networks:
sudo nmcli device wifi list
-
Connect to WiFi:
sudo nmcli device wifi connect <ssid_name> password <password>
-
Query the IP of wlan0 on the WiFi interface:
ifconfig
-
Step 2: Configure ROS Software Repository
-
Add ROS repository:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
-
Add repository keys:
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Step 3: Install ROS Melodic
-
Update source list:
sudo apt-get update
-
Install Desktop-Full version of ROS:
sudo apt install ros-melodic-desktop-full
Step 4: Add Environment Variables and Install ROS Dependencies
-
Add environment variables:
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc
-
Install dependencies:
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
Step 5: Initialize rosdep
-
Install
rosdep
:sudo apt install python-rosdep
-
Initialize and update
rosdep
:sudo rosdep init rosdep update
Step 6: Verify the ROS Environment
-
Start ROS Master:
roscore
Step 7: Set up Workspace
-
Create and compile catkin workspace:
mkdir -p ~/catkin_ws/src cd ~/catkin_ws catkin_make sudo sh -c 'echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc' source ~/.bashrc
Step 8: Download & Compile JetRacer ROS
-
Clone JetRacer ROS repository and compile:
cd ~/catkin_ws/src git clone https://github.com/waveshare/jetracer_ros.git cd ~/catkin_ws catkin_make source ~/catkin_ws/devel/setup.bash
Step 9: Install Dependency Libraries
-
Install various ROS libraries:
sudo apt-get install ros-melodic-robot-pose-ekf ros-melodic-gmapping ros-melodic-hector-slam ros-melodic-slam-karto ros-melodic-cartographer-ros ros-melodic-navigation ros-melodic-teb-local-planner ros-melodic-audio-common
Step 10: Install Camera Function Package
-
Install GStreamer and related packages:
sudo apt-get install gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev
-
Clone camera repositories and compile:
cd ~/catkin_ws/src git clone https://github.com/peter-moran/jetson_csi_cam.git git clone https://github.com/ros-drivers/gscam.git cd gscam sed -e "s/EXTRA_CMAKE_FLAGS = -DUSE_ROSBUILD:BOOL=1$/EXTRA_CMAKE_FLAGS = -DUSE_ROSBUILD:BOOL=1 -DGSTREAMER_VERSION_1_x=On/" -i Makefile cd ~/catkin_ws catkin_make source ~/catkin_ws/devel/setup.bash
-
Adjust camera settings if the image is too red:
wget https://files.waveshare.com/upload/e/eb/Camera_overrides.tar.gz tar zxvf Camera_overrides.tar.gz sudo cp camera_overrides.isp /var/nvidia/nvcam/settings/ sudo chmod 664 /var/nvidia/nvcam/settings/camera_overrides.isp sudo chown root:root /var/nvidia/nvcam/settings/camera_overrides.isp
Step 11: Install the Lidar Function Package
-
Clone Lidar repository and compile:
cd ~/catkin_ws/src git clone https://github.com/Slamtec/rplidar_ros.git cd ~/catkin_ws catkin_make source ~/catkin_ws/devel/setup.bash
By now, the ROS environment of the Jetbot robot should be mostly completed. If you need an intelligent voice function, additional settings will be required.
Hardware
PCB Design
1. Audio Amplifier
- Function: This section of the PCB drives the output to the onboard speaker (22). It takes low-power audio signals and amplifies them to drive the speaker effectively.
- Key Components:
- IC: Likely a Class D or Class AB audio amplifier IC such as the MAX98357 or TPA3110, which are common choices for compact, efficient audio amplification.
- Passive Components: Capacitors for filtering, resistors for gain control, and inductors (if using Class D) to smooth output.
- Considerations: High efficiency and low distortion are critical for portable applications. If a Class D amplifier is used, it provides low power dissipation with minimal heat generation.
2. USB Sound Card
- Function: Allows for audio I/O over a USB interface. This is commonly used to interface with external devices for sound recording or playback.
- Key Components:
- IC: A common USB audio codec, such as the PCM2900 or CM108B, which supports USB audio class.
- Crystals: A 12 MHz crystal for USB clock generation.
- Passives: Decoupling capacitors and resistors for proper signal integrity on the USB differential pairs (D+/D-).
- Considerations: Proper grounding and USB data line routing are essential to prevent noise from affecting audio quality.
3. Battery Protection Circuit
- Function: Protects the lithium-ion battery from overcharge, over-discharge, overcurrent, and short-circuit conditions.
- Key Components:
- IC: A battery protection IC such as BQ29700 for 1S or BQ76930 for 2-3 cell configurations.
- MOSFETs: Used to control the disconnection of the battery in case of overvoltage or short-circuit.
- Resistors and Capacitors: Sensing resistors for current detection, capacitors for noise filtering.
- Considerations: Ensure the battery protection IC matches the chemistry and cell count of the battery pack (18650 cells). Low Rds(on) MOSFETs are selected to minimize voltage drop and heat.
4. Equalizing Charge
- Function: Balances the charge between the cells of the battery pack (if more than one 18650 cell is used), ensuring that all cells charge to the same voltage.
- Key Components:
- IC: A battery balancer IC such as BQ29209 for cell balancing.
- Shunt Resistors: Used to discharge cells that are overcharged relative to others.
- Considerations: Critical for maintaining battery health and maximizing the lifespan of multi-cell battery packs.
5. Motherboard Power Supply (5A Maximum)
- Function: Supplies regulated power (likely 5V, 3.3V) to all the components on the PCB. Supports up to 5A, which indicates high current loads, possibly from motors and other power-hungry components.
- Key Components:
- IC: Buck or boost converter IC such as LM2675 or TPS54331 for efficient power conversion.
- Inductor: Used in switching power supplies for energy storage and filtering.
- Capacitors: Electrolytic and ceramic capacitors for input/output voltage smoothing.
- Diodes: Schottky diodes to handle the flyback in switch-mode power supplies.
- Considerations: Ensure that thermal dissipation is well-managed. Use low ESR capacitors for stability and noise reduction. A heat sink might be required for high-load applications.
6. IMU Attitude Sensor
- Function: Measures the 3D orientation, acceleration, and angular velocity of the system, crucial for motion tracking, stabilization, and navigation.
- Key Components:
- IC: Common IMUs include MPU-6050, ICM-20948, or LSM6DS3, which are six-axis (gyro + accelerometer) or nine-axis (gyro + accelerometer + magnetometer) sensors.
- Crystals: May use a crystal for timing or rely on the system clock.
- Resistors: Pull-up resistors on I2C lines for communication.
- Considerations: Proper placement and vibration damping are important to ensure accurate measurements. Shielding might be necessary to avoid electromagnetic interference (EMI).
7. USB Hub
- Function: Expands the USB capability by providing multiple USB ports to connect additional peripherals.
- Key Components:
- IC: A typical USB hub controller, such as FE1.1s or TUSB4041, which can handle multiple downstream USB ports.
- Passives: Decoupling capacitors and termination resistors for signal integrity.
- Considerations: Ensure proper routing of USB differential pairs, maintain impedance matching, and keep traces short to prevent signal degradation.
8. Raspberry Pi RP2040 Microcontroller
- Function: Serves as the main processing unit of the PCB, handling data processing, control, and communication between various peripherals.
- Key Components:
- RP2040 SoC: Dual-core ARM Cortex-M0+ processors running at 133 MHz, with 264KB SRAM and a wide range of GPIO pins.
- External Flash Memory: Typically, an 8MB QSPI flash for storing firmware and program data.
- Decoupling Capacitors: Placed near the power pins to reduce noise and ensure stable operation.
- Considerations: Adequate cooling and bypassing are essential. RP2040 supports a wide range of interfaces (I2C, SPI, UART) for easy expansion.
9. Motor Driver
- Function: Controls the motors connected to the motor ports (23), allowing for speed, direction, and torque control.
- Key Components:
- IC: H-bridge motor driver IC such as L298N or more compact options like DRV8833.
- MOSFETs: High-current MOSFETs might be used for switching high currents in PWM mode.
- Diodes: Flyback diodes to protect the circuit from voltage spikes generated by inductive loads (the motor).
- Considerations: Proper heat dissipation and current sensing for motor feedback are critical for robust operation.
10. Battery Voltage and Current Monitoring
- Function: Monitors the voltage and current from the 18650 battery pack to ensure proper charging and discharging cycles.
- Key Components:
- IC: Battery monitoring IC such as INA219 for high-accuracy current and voltage sensing.
- Shunt Resistors: Used for current sensing with minimal voltage drop.
- Analog-to-Digital Converter (ADC): Converts the analog voltage/current values to digital signals for processing.
- Considerations: Ensure the sense resistors are low enough to minimize power loss but still provide accurate measurements.
11. Dual MEMS Silicon Microphone
- Function: Captures audio from the environment, typically for voice recognition or sound sensing.
- Key Components:
- IC: MEMS microphones such as SPH0645LM4H or ICS-43432, which convert sound waves into electrical signals.
- Amplifiers: Pre-amplification might be required before sending the signal to the microcontroller or USB sound card.
- Considerations: Placement of microphones is critical for noise isolation. Shielding from high-frequency signals will prevent interference.
12. Lidar Interface
- Function: Interfaces with an external LIDAR sensor for distance measurement or object detection.
- Key Components:
- Connector: Likely a serial (UART, I2C) or SPI interface to communicate with the LIDAR sensor.
- Resistors and Capacitors: Pull-ups for I2C lines, decoupling capacitors for noise reduction.
- Considerations: Ensure the interface supports the specific communication protocol of the LIDAR sensor being used.
13. Lidar Power Switch
- Function: Switches the power to the LIDAR sensor, allowing it to be turned on or off as needed to save power.
- Key Components:
- MOSFET: A low Rds(on) MOSFET for switching the LIDAR’s power supply.
- Control Logic: Controlled by GPIO from the microcontroller or a dedicated power management IC.
- Considerations: Ensure the MOSFET can handle the LIDAR’s power consumption and is efficient to minimize heat generation.
14. Charging Port
- Function: Provides a charging interface for the onboard 18650 battery pack.
- Key Components:
- Connector: USB Type-C or Micro-USB for external power input.
- IC: Battery charger IC, such as BQ24079, which supports lithium-ion charging.
- Inductors and Capacitors: Used in conjunction with the charging IC to ensure stable
current and voltage regulation.
- Considerations: The charging circuit should handle overvoltage protection and current limiting to safely charge the battery.
15. OLED Display
- Function: Displays system information such as battery levels, status updates, or user interaction data.
- Key Components:
- Display Module: OLED screen with typical sizes of 128x64 pixels. Common driver ICs are SSD1306.
- Interface: I2C or SPI for communication with the microcontroller.
- Resistors: Pull-ups for the I2C lines if required.
- Considerations: Ensure the display’s power consumption is managed, as OLED displays can draw significant current.
16. Pogo Pin
- Function: Provides a temporary connection point for development, testing, or external modules.
- Key Components: Pogo pin headers with spring-loaded connectors.
- Considerations: Ensure strong mechanical stability and reliable contact for testing or programming.
17. Power Switch
- Function: Powers the entire system on or off.
- Key Components:
- Switch: SPST (Single Pole Single Throw) or DPST switch for high-current loads.
- MOSFET: Could be used in conjunction with a soft-start circuit to avoid inrush current.
- Considerations: Rated for the total system power draw.
18. Reset Button
- Function: Resets the microcontroller (RP2040) or the entire system.
- Key Components: Momentary push-button connected to the reset line of the microcontroller.
- Considerations: Debouncing the reset button to prevent accidental multiple resets.
19. Download Button
- Function: Used to trigger the bootloader mode for firmware updates on the RP2040.
- Key Components: Momentary switch tied to a GPIO or the BOOTSEL pin of the RP2040.
- Considerations: Ensure proper pull-down resistors to avoid false triggering.
20. Type-C Connector
- Function: Provides a modern USB interface for power and data transfer.
- Key Components: USB Type-C connector.
- Considerations: Ensure proper routing for the differential pairs (D+/D-) and use ESD protection diodes.
21. Speaker Volume Button
- Function: Adjusts the output volume of the audio amplifier (1).
- Key Components:
- Potentiometer: Analog volume control or a digital potentiometer IC like the MCP4018.
- Considerations: Ensure that it is accessible and well-calibrated to the audio amplifier’s input range.
22. Speaker
- Function: Outputs sound driven by the audio amplifier.
- Key Components: A small electromagnetic speaker or piezoelectric element.
- Considerations: Match the impedance with the amplifier’s output for optimal performance.
23. Motor Ports
- Function: Connects motors to the motor driver circuit.
- Key Components: JST or similar connectors to ensure a secure connection.
- Considerations: Ensure the motor driver IC can handle the voltage and current requirements of the connected motors.
24. 18650 Battery Holder
- Function: Holds two 18650 cells that power the entire PCB.
- Key Components: Spring-loaded battery holder.
- Considerations: Ensure proper connection and safety measures, such as fuses, to prevent shorts or thermal runaway.
Schematic
1. Power Supply and Management
-
Power Input (P1, P2, P3, P4):
- Headers for various power inputs (5V, 12V) and ground connections.
- Voltage regulators such as U20 (RT9193-1.8PB) to provide 1.8V and 3.3V outputs.
-
Capacitors:
- Various capacitors (C90, C91, C92, etc.) for filtering and stabilizing the power supply.
2. Microcontroller Unit (MCU)
- RP2040 (U19):
- The main microcontroller with GPIO pins for various I/O operations.
- Connected to an external flash memory (U17 - W25Qxx) for additional storage.
3. Communication Interfaces
-
I2C Bus:
- Multiple I2C devices connected to SDA and SCL lines.
- Includes a header (P5) for connecting external I2C devices.
-
SPI Bus:
- Used for high-speed communication with devices such as the MPU9250/ICM20948 (U21) sensor.
- Flash memory (U17) also communicates over SPI.
4. Sensors and Peripherals
-
INA219 (INA1):
- Current sensor for monitoring power consumption.
- Connected to I2C bus with address 0x41.
-
MPU9250/ICM20948 (U21):
- 9-axis IMU sensor for motion tracking, connected via I2C and SPI.
-
SSD1306 (U15):
- OLED display driver for a 128x32 pixel screen.
- Connected via I2C for displaying information.
5. Motor Drivers
- DRV8870 (DRV1, DRV2):
- Dual motor driver circuits for controlling the motors of the JetBot.
- Controlled via GPIO pins for direction and speed control.
- Includes current sensing for motor feedback.
6. Connectors and Headers
- GPIO Headers (H1, H2, P6):
- Headers for accessing GPIO pins for additional peripherals and debugging.
- Pins for SWD (Serial Wire Debug) for programming and debugging the MCU.
7. LEDs and Indicators
- LED1:
- Status LED controlled via GPIO.
8. Miscellaneous Components
- Resistors and Capacitors:
- Various resistors (R43, R44, R45, etc.) and capacitors (C78, C79, etc.) used for pull-up/down, filtering, and stabilization.
- Resistors in series with LEDs for current limiting.
Software
Tutorial
Vehicle Movement Control
Step 1: Add Serial User Group
-
Check Driver Board Connection Enter the command
ls /dev
on the Jetson Nano to check whether the driver board is connected to Jetson Nano normally and whether ttyACM0 and ttyACM1 devices are found.ttyACM0
is used to communicate with the microcontroller.ttyACM1
is used to communicate with the radar.
ls /dev
-
Add the Serial Port User Group Enter the following commands to add the serial port user group. If you are using a configured system with already added permissions, you can skip this step.
ls -l /dev/ttyACM* # View the serial port user group as dialout id -Gn # View the user groups that the current user belongs to, the first one is the current user sudo adduser jetbot dialout # Add the current user to the user group dialout where the serial port is located
-
Restart Jetson Nano Enter the command
sudo reboot
to restart. The password isjetson
.sudo reboot # Restart Jetson Nano
Note: The addition of the user to the dialout group takes effect only after restarting. Without serial port permissions, the robot chassis node will report an error after booting up.
Step 2: Start the Robot Chassis Control Node
-
Start the Robot Master Node Connect to the robot via SSH, open the terminal, and enter the following command to start the robot master node.
roscore # Start the robot master node
-
Start the Robot Chassis Node Enter the following command to start the robot chassis node. The command will also automatically start the master node if it’s not already running.
roslaunch jetracer jetracer.launch # Start the robot chassis node
-
Verify Multi-Machine Communication Open the Ubuntu virtual machine terminal and enter the following command to verify that the multi-machine communication connection is normal.
rostopic list
If the expected topics appear, multi-device communication is successful. If not, recheck the IP and hostname configurations and ensure they are connected to the same WiFi.
/cmd_vel
: Robot movement control topic./imu
: Robot IMU topic./motor/*
: Actual encoded speed and set speed of the left and right motors./odom
: Robot odometer./odom_combined
: Robot fusion odometer, combining encoded odometer with IMU data.
Step 3: Start Topic Publishing Node Control
-
Start the Topic Publishing Node Keep the robot chassis node running and place the car on the ground. Open a terminal in the Ubuntu virtual machine and enter the following command.
rosrun rqt_publisher rqt_publisher # Start topic publishing node
-
Publish a Topic In the pop-up window, select the topic
/cmd_vel
and click "+" to create a new topic. Configure the following:linear->x
: Linear speed of the robot (-1.2m/s to 1.2m/s)angular->z
: Steering angle of the robot’s front tires (-0.6 radians to 0.6 radians)
Change
linear.x
to 0.5, right-click, and select "Publish selected once" to make the robot move forward 0.5 meters. Settinglinear.x
to 0 andangular.z
to 0.6 will make the robot turn left.Note: Ensure to select the
Twist
type for/cmd_vel
. -
Close the Topic Publishing Node Press
Ctrl+C
to close the topic publishing node. -
View Topic Information Re-open a terminal on the robot side and enter the following command to view the topic information of the car movement.
rostopic echo /cmd_vel # Display /cmd_vel topic
Special Note:
angular->z
is the steering angle of the robot's tires, not the angular velocity.
Step 4: Control the Robot Movement with Keyboard
-
Open Keyboard Control Topic Node Press
Ctrl+Alt+t
on the Ubuntu virtual machine to open a new terminal and enter the following command.roslaunch jetracer keyboard.launch
-
Control the Robot Use the arrow keys to control the robot’s movement. The movement data can be viewed in the topics received by the robot terminal.
-
Interrupt Node Running Press
Ctrl+C
to stop the node.Note: The controls are only valid when the robot master node and the robot chassis node are activated. If the robot does not respond, check the node operation and multi-machine communication.
Step 5: Connect the Virtual Machine to the Gamepad Control
-
Check Gamepad Connection Connect the USB receiver of the gamepad to the computer. A box will pop up, select "Connect to Virtual Machine -> Ubuntu JetRacer."
-
Test Gamepad Connection Run the following command in the virtual machine to check if the gamepad is connected.
ls /dev/input/
js0
represents the game joystick handle. Run the following command to test the game handle.jstest /dev/input/js0
Press different buttons on the remote control handle to verify the corresponding button values change.
-
Start Gamepad Control Node Enter the following command in the virtual machine to start the gamepad control node.
roslaunch jetracer joy.launch
-
Control the Robot with Gamepad Turn on the power of the handle, press the HOME button, and a red light will turn on. Press and hold the L1 button while controlling the left joystick for steering and the right joystick for forward and backward movement. Release the L1 key to stop the robot.
Note: If the remote control fails, open the program file to adjust the values.
sudo nano ~/catkin_ws/src/jetracer_ros/scripts/teleop_joy.py # Open the remote control program file
Viewing Node Topics with ROS
This comprehensive tutorial will guide you through the process of viewing node topics with ROS using the JetRacer ROS AI Kit. The steps include checking node topics, displaying data waveforms, adjusting PID parameters, viewing robot odometer information, understanding coordinate relationships, and viewing IMU information.
Prerequisites
- Ensure you have completed the previous tutorials on assembling the JetRacer, installing the Jetson Nano image, installing the Ubuntu virtual image, configuring multi-machine communication, and controlling robot movement.
- Ensure your JetRacer and computer are connected to the same WiFi network.
Step 1: Check Node Topics
-
Start the Robot Chassis Node:
-
Connect to the JetRacer via SSH to open the terminal.
-
Enter the following command to start the robot chassis node:
roslaunch jetracer jetracer.launch
Note: The robot chassis node cannot be restarted repeatedly. If the previous chassis node is not closed, it does not need to be restarted.
-
-
View Chassis Node Topics:
-
Open the terminal in the Ubuntu virtual machine.
-
Enter the following command to view the topics of the chassis node:
rostopic list
If the topics are displayed correctly, it means that multi-device communication is successful. If not, check the IP and hostname configurations and ensure both devices are on the same WiFi network.
-
Step 2: Display Data Waveform via rqt_plot
-
Open
rqt_plot
:-
In the virtual machine terminal, run the following command to open the data waveform display tool:
rosrun rqt_plot rqt_plot
-
-
Add Motor Topics:
- Enter the motor topic (e.g.,
/motor/lset
or/motor/rset
) in the/Topic
field and click+
to add it. - Control the robot using the keyboard or remote control handle and observe the changes in the motor curve. This can help diagnose motor operation issues.
- Enter the motor topic (e.g.,
-
Adjust Display Settings:
- If the display speed is too fast, adjust the X-axis and Y-axis range settings by clicking the appropriate icon.
Step 3: Adjust PID Parameters via rqt_reconfigure
-
Start Dynamic Parameter Adjustment Interface:
-
Run the following command in the virtual machine terminal:
rosrun rqt_reconfigure rqt_reconfigure
-
-
Adjust PID Parameters:
- Select
JetRacer
and adjust the PID parameters as needed. Start withKi
, thenKp
, and finallyKd
(or setKd
to 0 initially). - Adjustments will only affect the current session. To make permanent changes, save the parameters to the configuration file (
jetracer/cfg/jetracer.cfg
).
Note: Non-professionals should avoid adjusting PID parameters to prevent abnormal robot behavior or damage.
- Select
Step 4: View Robot Odometer Information via RVIZ
-
Start RVIZ:
-
In the virtual machine terminal, run the following command:
rviz
-
-
Add TF Components:
- Add TF components and set the Fixed Frame to
odom
. You should see theodom
,base_footprint
, andbase_imu_link
coordinates. - Move the robot forward and observe the coordinate changes.
Note: If
base_footprint
rotates, restart the chassis master with the robot in a static state to recalibrate the IMU. - Add TF components and set the Fixed Frame to
Step 5: View Coordinate Relationship via TF Tree
-
Run TF Tree Command:
-
Re-open a terminal in the virtual machine and run the following command:
rosrun rqt_tf_tree rqt_tf_tree
-
-
Understand Coordinate Transformations:
- The
odom->base_footprint
transformation is issued by the/robot_pose_ekf
node. - The
base_footprint->base_imu_link
transformation is issued by the/base_footprint_to_imu
node.
- The
Step 6: View Robot IMU Information via RVIZ
-
Start RVIZ:
-
In the virtual machine terminal, run the following command:
rviz
-
-
Add IMU Component:
- Add the
rviz_plugin_tutorials/Imu
component and select the/imu
topic. - Enable the box and axes displays, and set the acceleration vector scale to 0.2.
- Add the
-
Observe IMU Data:
- Rotate or tilt the robot to observe changes in the IMU data displayed in RVIZ.
Note: Ensure the IMU is calibrated correctly by keeping the robot still and horizontal during startup. Restart the chassis node if necessary to recalibrate.
By following these steps, you can effectively view and analyze the node topics, data waveforms, PID parameters, odometer information, coordinate relationships, and IMU data for your JetRacer ROS AI Kit.
Robot Odometer Calibration
Introduction
The robot can output odometer information to track its traveled distance and turning angles. The default program may have inaccuracies, which can be corrected by calibrating the odometer. This guide will help you achieve higher accuracy, although initial operations can proceed without calibration if precision is not crucial.
Step 1: Calibrate the Linear Velocity
1. Enable the Chassis Node
-
Connect to the robot via SSH and open the terminal.
-
Enter the following command to enable the chassis node:
roslaunch jetracer jetracer.launch
Note: Ensure the chassis node is not enabled multiple times, as it may cause errors.
2. Enable Keyboard Control
-
Press
Ctrl + Alt + T
to open a new terminal. -
Enter the following command to enable keyboard control of the topic nodes:
roslaunch jetracer keyboard.launch
3. Control the Robot
- Press the
I
key on the keyboard to move the robot forward. - Observe if the robot moves in a straight line. If it does not, proceed to the next step to calibrate.
4. Use rqt_reconfigure for Calibration
-
Open a new terminal and run:
rosrun rqt_reconfigure rqt_reconfigure
-
Adjust the
servo_bias
parameter until the robot moves straight. -
Save the calibration:
vi ~/catkin_ws/src/jetracer_ros/cfg/jetracer.cfg
Modify the
servo_bias
line with the new value.
Step 2: Linear Velocity Calibration
1. Close Previous Chassis Node
- Ensure the previously started chassis node is closed while keeping the robot master node running.
2. Start Linear Velocity Calibration
-
Open a terminal in Jetson Nano and run:
roslaunch jetracer calibrate_linear.launch
Do not close this terminal to keep the calibration option visible.
3. Open Dynamic Parameter Configuration
-
In the virtual machine, run:
rosrun rqt_reconfigure rqt_reconfigure
-
Set the following parameters:
test_distance
: Default is 1m.speed
: Robot's linear speed.tolerance
: Error margin to reach the goal.odom_linear_scale_correction
: Adjust this based on test results.
4. Perform the Test
- Place the robot on the ground and mark its starting position.
- Check
start_test
to initiate calibration. - Measure the actual distance traveled and calculate the correction ratio.
- Adjust
odom_linear_scale_correction
by multiplying it with the ratio and repeat until the distance is accurate.
5. Save Calibration Parameters
-
Open the file to save the new parameters:
vi ~/catkin_ws/src/jetracer_ros/launch/jetracer.launch
-
Modify the
linear_correction
value.
Step 3: Angular Velocity Calibration
1. Initial Setup
-
Unplug the motor wire to keep the motor in a free state.
-
Modify the parameters to set servo control to
y = x
:vi ~/catkin_ws/src/jetracer_ros/cfg/jetracer.cfg
Set
servo_bias
to 0.vi ~/catkin_ws/src/jetracer_ros/launch/jetracer.launch
Set
coefficient_a
,coefficient_b
,coefficient_d
to 0, andcoefficient_c
to 1.
2. Enable the Chassis Node
-
Connect via SSH and run:
roslaunch jetracer jetracer.launch
3. Enable Topic Publishing
-
Run the following command:
rosrun rqt_publisher rqt_publisher
-
Add
/cmd_vel
topic information.
4. Measure Turning Diameter
- Set
/cmd_vel.angular.z
to-1
and gradually increase to1
, recording the turning diameter at each value.
5. Fit the Polynomial
-
Update the program with actual measurements:
vi ~/catkin_ws/src/jetracer_ros/scripts/servo_calibratin.py
-
Run the calibration script:
python ~/catkin_ws/src/jetracer_ros/scripts/servo_calibratin.py
6. Save Fitting Parameters
-
Open the launch file and save the new parameters:
vi ~/catkin_ws/src/jetracer_ros/launch/jetracer.launch
-
Convert scientific notation to floating-point numbers if necessary.
Conclusion
After successful calibration, the robot should move in a straight line and handle turns accurately. Adjust the servo_bias
or d
parameter if further fine-tuning is required.