108 lines
3.0 KiB
Markdown
108 lines
3.0 KiB
Markdown
## Build Image
|
|
|
|
ROS Jazzy + GZ Harmonic
|
|
|
|
```
|
|
docker buildx build -f gz_harmonic_sim_dev.dockerfile -t sim_dev:gz_harmonic .
|
|
```
|
|
|
|
## NOTICE
|
|
When you build code in container with error:
|
|
> fatal: detected dubious ownership in repository at '/code/PX4-Autopilot'
|
|
> To add an exception for this directory, call:
|
|
> git config --global --add safe.directory
|
|
|
|
you should run this command in container:
|
|
```
|
|
git config --global --add safe.directory '*'
|
|
```
|
|
|
|
## Ubuntu With GUI&GPU Support
|
|
|
|
1. Install nvidia-container-toolkit
|
|
```
|
|
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
|
|
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
|
|
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
|
|
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
|
|
|
|
sudo apt install -y nvidia-container-toolkit
|
|
sudo systemctl restart docker
|
|
```
|
|
|
|
2. Run container with docker compose
|
|
```
|
|
# in host bash
|
|
# x11 permission
|
|
xhost +local:root
|
|
# 修改 docker-compose-ubuntu.yml 中${HOST_WS} 为你主机上的工作空间的目录
|
|
docker compose -f docker-compose-ubuntu.yml up -d
|
|
docker exec -it sim_dev_container bash
|
|
|
|
# in container bash
|
|
git config --global --add safe.directory '*'
|
|
cd /simulation_ws
|
|
sudo apt update
|
|
rosdep install --from-paths src/autonomy --ignore-src -r -y
|
|
/simulation_ws/src/autonomy/drivers/mavros/mavros/scripts/install_geographiclib_datasets.sh
|
|
colcon build --symlink-install --packages-up-to mavlink mavros px4_bringup
|
|
```
|
|
## How to enter container again with bash
|
|
|
|
```
|
|
# get container id
|
|
docker container ls -a
|
|
|
|
# start container if not
|
|
docker container start [container id]
|
|
|
|
docker exec -it [container id] bash
|
|
```
|
|
|
|
|
|
## WSL2 With GUI&GPU Support
|
|
|
|
> NOTICE: replace `~/code` on your host
|
|
|
|
```
|
|
docker run -it \
|
|
-v ~/code:/code \
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
-v /mnt/wslg:/mnt/wslg \
|
|
-v /usr/lib/wsl:/usr/lib/wsl \
|
|
-e DISPLAY=$DISPLAY \
|
|
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
|
|
-e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
|
|
-e PULSE_SERVER=$PULSE_SERVER \
|
|
--device=/dev/dxg \
|
|
--device /dev/dri/card0 \
|
|
--device /dev/dri/renderD128 \
|
|
--gpus all sim_dev:gz_harmonic
|
|
```
|
|
|
|
docker-compose
|
|
```
|
|
docker compose -f docker-compose-wsl.yml up -d
|
|
docker exec -it sim_dev_container bash
|
|
cd /simulation_ws
|
|
sudo apt update
|
|
rosdep install --from-paths src/autonomy --ignore-src -r -y
|
|
/simulation_ws/src/autonomy/drivers/mavros/mavros/scripts/install_geographiclib_datasets.sh
|
|
colcon build --symlink-install --packages-up-to mavlink mavros px4_bringup
|
|
```
|
|
|
|
## Simulation
|
|
|
|
### build simulation worksapce
|
|
|
|
```bash
|
|
MAKEFLAGS="-j4" colcon build --symlink-install \
|
|
--packages-up-to \
|
|
mavlink mavros mavros_extras px4_bringup vins_estimator usb_cam \
|
|
--cmake-args \
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
|
-DCMAKE_CXX_STANDARD=17 \
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
```
|
|
|