1,
sudo apt update && sudo apt install curl
curl http://repo.ros2.org/repos.key | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64,arm64] http://repo.ros2.org/ubuntu/main xenial main" > /etc/apt/sources.list.d/ros2-latest.list'
2,
sudo apt update
sudo apt install `apt list ros-ardent-* 2> /dev/null | grep "/" | awk -F/ '{print $1}' | grep -v -e ros-ardent-ros1-bridge -e ros-ardent-turtlebot2- | tr "\n" " "`
3,
source /opt/ros/ardent/setup.bash
4,测试
In one terminal, start a node (written in C++) that will publish messages on a topic.
ros2 run demo_nodes_cpp talker
In another terminal, start a second node (written in Python) that will subscribe to messages on the same topic.
ros2 run demo_nodes_py listener
You should see that these nodes discover each other automatically, and begin to exchange messages.