Connecting the Physical Twin with a Digital Twin
This example can be used to connect the PiCar-X’s phyiscal twin with a digital twin. The communication between both is established via MQTT. The MQTT server is part of the digital twin.
Start the Digital Twin
We assume at this point that the digital twin runs on a X64 Linux system (e.g. a server).
# Build and execute the Docker Containers
docker compose -f docker-compose-core.yml build
docker compose -f docker-compose-dtsim.yml build
docker compose -f docker-compose-dtsim.yml up
Start the Physical Twin
- arm32v7 (RPi3)
- arm64v8 (RPi4)
Send Commands from the Digital Twin to the Physical Twin
# SWITCH INTO THE CONTAINER
docker exec -it picar-x-ackermann_skill-dt-1 /bin/bash
# INSIDE CONTAINER
source /root/catkin_ws/devel/picarx_ackermann_drive/setup.bash
# PUBLISH A MESSAGE TO TURN RIGHT WITH 50 percent motor speed
rostopic pub /picarx/drive/command picarx_msgs/Drive "{speed: 50, angle: 20}"