A robot is equipped with an STM32 microcontroller and a Jetson Nano. The STM32 handles motor control and reads data from global positioning sensors, transmitting this information to the Jetson Nano. On the Nano, a node publishes global coordinates, while a subscriber node runs on a local computer to visualize the robot's movement path via RViz.
The local machine environment uses Windows 10 with Ubuntu 18.04 installed through WSL.
The Jetson Nano operates with its proprietary Ubuntu 18.04 (ARM64 architecture).
When attempting to run RViz on WSL, a segmentation fault occurred. The solution involved disabling the Native OpenGL option in XLaunch. Without this, OpenGL would load incorrect drivers, causing the software rasterizer (swrast) to fail and preventing RViz from launching.
Following the XLaunch configuration, execute:
LIBGL_ALWAYS_INDIRECT=
Then verify graphics libraries using:
glxinfo | grep "OpenGL version"
According to ROS documentation, hardware acceleration should be disabled. Therefore, set:
export LIBGL_ALWAYS_SOFTWARE=1
After these settings, launch RViz with:
rosrun rviz rviz
This approach successfully starts RViz.
Relevant references:
Results:
To display the trajectory, we publish a topic that can be visualized in RViz. Refer to the following link for guidance: https://blog.csdn.net/qq_43176116/article/details/88045741
A sample program to visualize the path and perform testing:
#include <ros/ros.h>
#include <ros/console.h>
#include <nav_msgs/Path.h>
#include <std_msgs/String.h>
#include <geometry_msgs/Quaternion.h>
#include <geometry_msgs/PoseStamped.h>
#include <tf/transform_broadcaster.h>
#include <tf/tf.h>
int main(int argc,char **argv)
{
ros::init(argc,argv,"showpath");
ros::NodeHandle nh;
ros::Publisher path_pub = nh.advertise<nav_msgs::Path>("trajectory",1,true);
ros::Time current_time,last_time;
current_time = ros::Time::now();
last_time = ros::Time::now();
nav_msgs::Path path;
path.header.stamp = current_time;
path.header.frame_id = "world";
double x = 0.0;
double y = 0.0;
double th = 0.0;
double vx = 0.1;
double vy = -0.1;
double vth = 0.1;
ros::Rate loop_rate(1);
while(ros::ok())
{
current_time = ros::Time::now();
double dt = (current_time - last_time).toSec();
double delta_x = (vx * cos(th) - vy * sin(th)) * dt;
double delta_y = (vx * sin(th) + vy * cos(th)) * dt;
double delta_th = vth * dt;
x += delta_x;
y += delta_y;
th += delta_th;
geometry_msgs::PoseStamped this_pose_stamped;
this_pose_stamped.pose.position.x = x;
this_pose_stamped.pose.position.y = y;
geometry_msgs::Quaternion goal_quat = tf::createQuaternionMsgFromYaw(th);
this_pose_stamped.pose.orientation.x = goal_quat.x;
this_pose_stamped.pose.orientation.y = goal_quat.y;
this_pose_stamped.pose.orientation.z = goal_quat.z;
this_pose_stamped.pose.orientation.w = goal_quat.w;
this_pose_stamped.header.stamp = current_time;
this_pose_stamped.header.frame_id = "world";
path.poses.push_back(this_pose_stamped);
path_pub.publish(path);
ros::spinOnce();
last_time = current_time;
loop_rate.sleep();
}
return 0;
}
Results: Check the /trajectory topic using rostopic.
RViz displays a circular trajectory.
With this setup, the upper computer portion is complete. Next, deploy ROS on the Jetson Nano and run the path visualization node.
Install ROS on Jetson Nano following this guide: https://blog.csdn.net/beckhans/article/details/90747828
Note that installing ARM64 ROS versions requires bypassing network restrictions (which is frustrating). If you need to use a proxy, solutions like SSR work. I used SSR with a custom server and configured it gllobally for terminal access. For detailed steps, see: https://samzong.me/2017/11/17/howto-use-ssr-on-linux-terminal/
The entire process took about two hours, nearly one and a half of which were spent on network issues. In China, internet access comes with limitations.
(Video quality is poor due to camera constraints)
Next step: Run the publishing node on Jetson Nano and subscribe from the Windows 10 PC. Multi-machine communication is covered in Chapter 4.12 of "ROS Introduction Examples (First Edition)".
First, connect both devices to the same Wi-Fi network or router. Verify connectivity by pinging hostnames (use hostname command to check). Interestingly, my PC doesn't require .local suffix when pinging the Nano.
PC:
ping satori-desktop
Nano:
ping LAPTOP-25LTIPRI.local
Once ping works both ways, configure environment variables.
Nano:
export ROS_HOSTNAME=satori-desktop
Start ROS:
roscore
PC:
export ROS_HOSTNAME=LAPTOP-25LTIPRI.local
export ROS_MASTER_URL=http://satori-desktop:11311
11311 is the default port. On the PC, run:
rostopic list
Should show:
/rosout
/rosout_agg
Indicating successful connection.
Run the trajectory node on Nano:
rosrun test test_node
Launch RViz on PC:
rosrun rviz rviz
Subscribe to /trajectory topic on PC.
Final result: Laptop running only RViz.
Jetson Nano running roscore and publsihing trajectory test_node.