rudra_deck setup on Jetson Nano (or NUC)
Once we go over the setup below, we will create a launch file called rudra_bringup which will start the rover with basic functionalities that will enable the user to move Rudra with /cmd_vel commands.
Once the rudra_bringup is launched, we can then write specific launch files that will add additional functionalities such as SLAM and Navigation.
SLAM and Navigation launch files will be associated with rudra_workstation.
mdkir rudra_wscd rudra_wsmkdir srccatkin buildcd srccatkin_create_pkg rudra_deck roscpp std_msgs geometry_msgs message_generation message_runtimecd ..catkin build
You should see no errors —
Since the build is successful, you’ll see a CMakeLists.txt and package.xml file in your rudra_deck package:
Let's inspect the package.xml file.
We should see the following dependencies in the file:
Make sure to add both <build_depend> and <exec_depend> for BOTH message_runtime & message_generation. Otherwise the package wont build.
We will set up our own Message called /joy_msg, which is why we needmessage_generation and message_runtime dependencies besides other typical dependencies listed above.
Now let's inspect CMakeLists.txt —
You should have the above packages at the minimum. Save and close.
Message creation /joy_msg
Now let's create our custom msg called /joy_msg. We will use joy_msg to send PS2 controller commands to move rudra_base.
The first step is to create a directory called msg and create a file named joy_msg.msg
cd rudra_deckmkdir msgcd msggedit joy_msg.msg
Add the following 6 lines and close.
The SELECT variable is a boolean that we will use to switch between ROS commands and PS2 commands. The SELECT variable will be mapped to the “mode” button on the PS2. Refer to the *.ino file to be flashed on Arduino Uno connected to PS2 receiver.
We have to make a few changes to the CMakelists.txt as below.
Below are the complete files if you prefer to copy-paste.
Save the file and close it.
cd ~/rudra_wscatkin build
If you do not get any error, you have successfully created /joy_msg for the PS2 controller connected to Arduino Uno.
However, there is one last step.
rm -rf ros_lib
rosrun rosserial_arduino make_libraries.py .
The above lines will ensure that the joy_msg.h header file is created in the Arduino libraries directory.
2. URFD and Robot_State_Publisher
To publish /tf from Static Joints in Rudra, we will use the URDF-RobotSatePublisher method. As discussed in the Coordinate Frame section of this article, the robot_state_publisher node takes in the URDF file and automatically publishes all the static transforms. This is awesome! We do not have to broadcast tf for our static joints. However, we should specify the frame_id correctly when publishing the sensor msgs to tie all the loose ends.
The first step then is to create a URDF file for RUDRA. You can model the entire robot using URDF or export the CAD from Solidworks, but here I’m just creating the coordinate frames for the links that matter for /tf.
The static joints in our robot are:
- base_link to laser
- base_link to imu_link
I took the best measurements of the RPlidar and the MPU6050 mounting locations from the center of the rudra_base, which is the location of the base_link coordinate frame.
It is possible to create the URDF file in the same rudra_deck package. Here I’m creating another package specific for URDF because I was aiming for code-portability.
cd ~/rudra_ws/srccatkin_create_pkg rudra_description joint_state_publisher robot_state_publisher urdfcd rudra_descriptionmkdir urdfcd urdfgedit rudra.urdf
Copy the following content into the rudra.urdf file
Keep track of the link names; these should be mentioned as frame_id when publishing the sensor msg. For example, we publish imu/data_raw msg from Teensy. You will notice that I have ensured that the frame_id is imu_link which is the name used in this URDF file.
If you had mentioned all the dependencies correctly, you do not have to edit the CMakeLists.txt and package.xml files.
You should not see any errors.
sudo apt install cmake pkg-configmkdir -p ~/lidar_ws/srccd ~/lidar_ws/srcgit clone https://github.com/AdarshGouda/YDLidar-SDK.gitcd YDLidar-SDK/cmakecmake ..makesudo make install
Install ROS Driver:
cd ~/rudra_ws/srcgit clone https://github.com/AdarshGouda/ydlidar_ros_driver.gitcd ..catkin buildecho "source ~/rudra_ws/devel/setup.bash" >> ~/.bashrcsource ~/.bashrc
GitHub - YDLIDAR/ydlidar_ros_driver: ydlidar driver package under ros
ydlidar_ros_driver is a new ros package, which is designed to gradually become the standard driver package for ydlidar…
Add a device alias /dev/ydlidar to the X4 serial port.
sudo chmod +x initenv.sh
sudo sh initenv.sh
The launch file of ydlidar publishes static transforms, by default. We should create a Rudra specific ydlidar launch file with no transforms so that the transforms in the urdf file of Rudra is being utilized.
cp G2.launch G2_rudra.launch
Edit the G2_rudra.launch file to the following:
Let’s now create two launch files. One with LIDAR and one without LIDAR—
cd ~/rudra_ws/srccd rudra_deckmkdir launchgedit rudra_bringup_noLIDAR.launch
Paste the following lines of code, save and close.
The G2_rudra.launch file is commented out. This launch file starts RUDRA with bare minimum nodes to be able to control the rover over the PS2 controller or with the teleop_key node from ROS.
you will have to ensure that you change the “port” for the two rosserial nodes. The Arduino UNO on my build is connected to ttyACM0, and Teensy is connected to the ttyACM1 port on my Jetson Nano.
You can use this launch file to play around with rover or simply do some calibration.
Let's create another launch file —
cd ~/rudra_ws/srccd rudra_deckmkdir launchgedit rudra_bringup_LIDAR.launch
Copy the following code into the launch file and save it.
This launch file starts the ydLidar as well.
We are all done with rudra_deck now!