Simulation
This guide outlines the steps to run Software-In-The-Loop (SITL) simulation with ATMOS and PX4Space.
Running the Simulator
Before starting, make sure to have set up PX4Space on your local machine as outlined in PX4Space section. It is also useful to have QGroundControl for Spacecraft, outlined in Building QGroundControl for Spacecraft.
The FreeFlyers with PX4 controller can be simulated using Gazebo. Installation instructions for Gazebo can be found here.
With Gazebo installed, navigate to your local PX4Space directory and run the simulation:
make px4_sitl gz_spacecraft_2d
Optionally, to run with namespace:
PX4_UXRCE_DDS_NS=<namespace> make px4_sitl gz_spacecraft_2d
Running Micro-XRCE-DDS-Agent Locally
PX4 uses Micro-XRCE-DDS as middleware to allow its uORB messages to be published and subscribed to on a companion computer as though they were ROS 2 topics. The Micro-XRCE-DDS-Agent is already set up on the Jetson, however, we recommend also setting it up on your local machine for the simulation environment, and for testing and development.
Install Micro-XRCE-DDS-Agent from snap-store:
sudo snap install micro-xrce-dds-agent --edge
Once installed, connect to the PX4 by running:
- For Ethernet and Simulator connections:
micro-xrce-dds-agent udp4 -p 8888
- For Serial connections:
micro-xrce-dds-agent serial --dev <serial-port>
Subscribe to topics
Similarly to the hardware version, you should now see the SITL topics being published in ROS 2:
ros2 topic list
ros2 topic echo /fmu/out/vehicle_attitude
Make sure you have sourced the PX4-msgs before publishing and subscribing.
The hardware is now being mimicked in software!
Try Control
In the PX4-MPC repository, we made available a few nonlinear model predictive controller examples for the spacecraft model. We encourage you to follow the steps there provided and try controlling ATMOS!