-
Allow the root user to access the running X server
xhost +local:root
- Pull the prebuild docker image. (For
non-Nvidia GPU)
docker run -it \
--rm \
--name rclpy_bot \
--privileged \
--net=host \
--env=DISPLAY \
--env=QT_X11_NO_MITSHM=1 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
ntklab/rclpy_bot \
/bin/bash
- For the
Nvidia GPU, use the following command instead.
docker run -it \
--rm \
--gpus all \
--name rclpy_bot \
--privileged \
--net=host \
--env=DISPLAY \
--env=QT_X11_NO_MITSHM=1 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
ntklab/rclpy_bot \
/bin/bash
- Start
rviz2. If it opens successfully, you can close it and move on to the next rocket example.
source /opt/ros/foxy/setup.sh
rviz2
- Run the rocket example. You should see a standing rocket.
source /opt/ros/foxy/setup.sh
python3 /rocketbot/rocketbot/rocketbot_node.py
- Open another terminal, then enter the new session.
docker exec -ti rclpy_bot bash
- Create
thrust_rv_ctr.py, then paste the following example.
vim /thrust_rv_ctr.py
import rclpy
import time
from rclpy.node import Node
from random import random
from geometry_msgs.msg import Vector3
rclpy.init()
node = Node('thrust_ctr')
thrust_pub = node.create_publisher(Vector3, 'thrust', 10)
thrust_msg = Vector3()
while True:
thrust_msg.x = random() * 25
thrust_msg.y = random() * 25
thrust_msg.z = random() * 25
thrust_pub.publish(thrust_msg)
time.sleep(0.5)- Run the example. You will see the rocket flying randomly.
source /opt/ros/foxy/setup.sh
python3 /thrust_rv_ctr.py