From 8e818ce7796b6ca104386073b6a661ef5841db8d Mon Sep 17 00:00:00 2001 From: marhcouto Date: Fri, 19 Apr 2024 18:24:59 +0100 Subject: [PATCH 01/21] feat: docker dev env and compose and short docs --- .devcontainer/.env.example | 7 +++ .devcontainer/.gitignore | 1 + .devcontainer/Dockerfile | 42 +++++++++++++++++ .devcontainer/devcontainer.json | 52 ++++++++++++++++++++++ .gitignore | 9 ++++ .vscode/c_cpp_properties.json | 18 ++++++++ .vscode/settings.json | 3 ++ README.md | 8 +++- cache/iron-ros-base-jammy/build/.gitkeep | 1 + cache/iron-ros-base-jammy/install/.gitkeep | 1 + cache/iron-ros-base-jammy/log/.gitkeep | 1 + doc/usage_tutorial.md | 31 +++++++++++++ docker-compose.yml | 38 ++++++++++++++++ entrypoint.sh | 9 ++++ track_editor/README.md | 14 ++++++ 15 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/.env.example create mode 100644 .devcontainer/.gitignore create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .gitignore create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/settings.json create mode 100644 cache/iron-ros-base-jammy/build/.gitkeep create mode 100644 cache/iron-ros-base-jammy/install/.gitkeep create mode 100644 cache/iron-ros-base-jammy/log/.gitkeep create mode 100644 doc/usage_tutorial.md create mode 100644 docker-compose.yml create mode 100755 entrypoint.sh create mode 100644 track_editor/README.md diff --git a/.devcontainer/.env.example b/.devcontainer/.env.example new file mode 100644 index 0000000..06fe735 --- /dev/null +++ b/.devcontainer/.env.example @@ -0,0 +1,7 @@ +# This files is meant to be used as an example for the .env file, +# which sets the username variable for the dev container +# You should duplicate this file, change the name of the copy to +# '.env' and edit the variable's value +# This might not be necessary for linux +USERNAME=your_username # Necessary for windows at least +# If it doesnt work, include "export USERNAME=your_username" in the Dockerfile diff --git a/.devcontainer/.gitignore b/.devcontainer/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.devcontainer/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..0e686f3 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,42 @@ +FROM ros:iron-ros-base-jammy +ARG USERNAME=USERNAME +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Create the user +RUN groupadd --gid "$USER_GID" "$USERNAME" \ + && useradd --uid "$USER_UID" --gid "$USER_GID" -m "$USERNAME" \ + # + # [Optional] Add sudo support. Omit if you don't need to install software after connecting. + && apt-get update \ + && apt-get install -y sudo \ + && echo "$USERNAME" ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/"$USERNAME" \ + && chmod 0440 /etc/sudoers.d/"$USERNAME" \ + && apt-get clean + +# Install dependencies +RUN apt update && apt upgrade -y \ + && apt install -y python3-pip \ + && apt install ros-"$ROS_DISTRO"-rviz2 -y \ + && apt install openssh-client -y \ + && apt install openssh-server -y \ + && apt install git -y \ + && apt install vim -y \ + && apt install python-is-python3 -y \ + && apt install clang-format -y \ + && apt install bear -y \ + && apt install curl -y \ + && curl -s https://deb.nodesource.com/setup_16.x | sudo bash \ + && apt install nodejs -y \ + && pip install black \ + && pip install rosbags \ + && pip install PyQT5 \ + && apt install ros-$ROS_DISTRO-xacro -y \ + && apt install ros-$ROS_DISTRO-foxglove-bridge -y \ + && apt clean + +RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> /home/"$USERNAME"/.bashrc +EXPOSE 8765 +ENV SHELL /bin/bash +USER $USERNAME +CMD ["/bin/bash"] \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..76c3f90 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,52 @@ +{ + "name": "ROS 2 Development Container", + "privileged": true, + "remoteUser": "${localEnv:USERNAME}", + "build": { + "dockerfile": "Dockerfile", + "args": { + "USERNAME": "${localEnv:USERNAME}" + } + }, + "features": { + "ghcr.io/itsmechlark/features/act:1": {}, + "ghcr.io/devcontainers/features/docker-in-docker:2": {} + }, + "workspaceFolder": "/home/ws", + "workspaceMount": "source=${localWorkspaceFolder},target=/home/ws,type=bind", + "customizations": { + "vscode": { + "extensions":[ + "ms-vscode.cpptools", + "ms-azuretools.vscode-docker", + "ms-vscode.cpptools-extension-pack", + "twxs.cmake", + "donjayamanne.python-extension-pack", + "eamodio.gitlens", + "ms-iot.vscode-ros", + "GitHub.vscode-github-actions" + ] + } + }, + "containerEnv": { + "DISPLAY": "unix:0", + "ROS_AUTOMATIC_DISCOVERY_RANGE": "LOCALHOST", + "ROS_DOMAIN_ID": "42" + }, + "runArgs": [ + "--net=host", + "--ipc=host", + "--pid=host", + "-e", "DISPLAY=${env:DISPLAY}", + "-p", "8765:8765" + ], + "mounts": [ + "source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached", + "source=/dev/dri,target=/dev/dri,type=bind,consistency=cached", + "source=${localWorkspaceFolder}/cache/iron-ros-base-jammy/build,target=/home/ws/build,type=bind", + "source=${localWorkspaceFolder}/cache/iron-ros-base-jammy/install,target=/home/ws/install,type=bind", + "source=${localWorkspaceFolder}/cache/iron-ros-base-jammy/log,target=/home/ws/log,type=bind" + ], + "postCreateCommand": "sudo apt update && rosdep update && rosdep install --from-paths src --ignore-src -y && sudo chown -R ${localEnv:USERNAME} /home/ws/", + "initializeCommand": "echo Initialize...." +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b844304 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +**/build/* +**/install/* +**/log/* +**/.vscode/* + + +!.gitkeep +!.vscode/settings.json +!.vscode/c_cpp_properties.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..d870c8f --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "/opt/ros/iron/include/**", + "/usr/include/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "c17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cad7657 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.configureOnOpen": false +} \ No newline at end of file diff --git a/README.md b/README.md index 8ceaf29..d716256 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,10 @@ Install dependencies: `sudo apt install ros-iron-desktop ros-iron-xacro` +## Docker Dev Container + +A [Dockerfile](./.devcontainer/Dockerfile) is configured that already contains all the dependencies. It can be used with a [dev container environment](./.devcontainer) or launched independently wiht the [docker-compose](./docker-compose.yml) file, which uses the same Docker image and executes the [entrypoint.sh script](./entrypoint.sh) at startup. + # How to get started To use PacSim with your autonomous system, you need to create a message converter node to match your own interfaces with the simulator. @@ -29,7 +33,9 @@ We provide an example launch file (example.launch.py) which shows an example of The sensors and vehicle model are configured using config files. Examples are provided the config folder. Things such as the discipline or the path of the track file or config files are defined using ros2 parameters. -The default vehicle model provided is rather simple and just meant to be a starting point. You are encouraged to integrate your own vehicle model by implementing the `IVehicleModel` class +The default vehicle model provided is rather simple and just meant to be a starting point. You are encouraged to integrate your own vehicle model by implementing the `IVehicleModel` class. + +More info in the [docs folder](./doc/usage_tutorial.md). # Contributing Contributions in any form (reports, feedback, requests, submissions) are welcome. Preferably create an Issue or Pull request for that. diff --git a/cache/iron-ros-base-jammy/build/.gitkeep b/cache/iron-ros-base-jammy/build/.gitkeep new file mode 100644 index 0000000..45ea04d --- /dev/null +++ b/cache/iron-ros-base-jammy/build/.gitkeep @@ -0,0 +1 @@ +DO NOT REMOVE \ No newline at end of file diff --git a/cache/iron-ros-base-jammy/install/.gitkeep b/cache/iron-ros-base-jammy/install/.gitkeep new file mode 100644 index 0000000..45ea04d --- /dev/null +++ b/cache/iron-ros-base-jammy/install/.gitkeep @@ -0,0 +1 @@ +DO NOT REMOVE \ No newline at end of file diff --git a/cache/iron-ros-base-jammy/log/.gitkeep b/cache/iron-ros-base-jammy/log/.gitkeep new file mode 100644 index 0000000..45ea04d --- /dev/null +++ b/cache/iron-ros-base-jammy/log/.gitkeep @@ -0,0 +1 @@ +DO NOT REMOVE \ No newline at end of file diff --git a/doc/usage_tutorial.md b/doc/usage_tutorial.md new file mode 100644 index 0000000..697bcfa --- /dev/null +++ b/doc/usage_tutorial.md @@ -0,0 +1,31 @@ +# How to use + +## Configuration + +To configurure parameters of the simulator: +- [perception.yaml](../config/perception.yaml) - configuration of cone models +- [sensors.yaml](../config/sensors.yaml) - configuration of imu, wheel encoders and other sensors +- [vehicleModel.yaml](../config/vehicleModel.yaml) - configuration of vehicle model +- [mainConfig.yaml](../config/mainConfig.yaml) - configuration of event timeouts and other competition features + +## Running the simulator + +To run the simulator, simply use one of the launch files present in the [launch folder](../launch/): + +```sh +colcon build # if you haven't compiled yet +source ./install/setup.bash # if you haven't already +ros2 launch pacsim example.launch.py +``` + +## Visualization + +Use Foxglove (or Rviz) for visualization purposes. TODO: create Foxglove dashboard for pacsim + +## Track Generation + +Checkout the track generator in the [track editor folder](../track_editor/). + +## Other tools + +[Scrips folder](../scripts/) contains a tool for track convertion from fssim format to this one, as well as a report evaluation tool. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..121fefd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,38 @@ +services: + ros2_dev: + container_name: ros2_development_container + build: + context: . + dockerfile: .devcontainer/Dockerfile + args: + USERNAME: "${USERNAME}" + environment: + DISPLAY: "${DISPLAY}" + ROS_AUTOMATIC_DISCOVERY_RANGE: "LOCALHOST" + ROS_DOMAIN_ID: "42" + volumes: + - type: bind + source: "./" + target: /home/ws + - type: bind + source: "/tmp/.X11-unix" + target: "/tmp/.X11-unix" + consistency: cached + - type: bind + source: "/dev/dri" + target: "/dev/dri" + consistency: cached + - type: bind + source: "./cache/iron-ros-base-jammy/build" + target: "/home/ws/build" + - type: bind + source: "./cache/iron-ros-base-jammy/install" + target: "/home/ws/install" + - type: bind + source: "./cache/iron-ros-base-jammy/log" + target: "/home/ws/log" + ports: + - "8765:8765" + network_mode: host + command: > + bash -c "cd home/ws/ && ./entrypoint.sh" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..dc6976e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,9 @@ +#! /bin/bash +sudo apt update && +rosdep update && +rosdep install --from-paths src --ignore-src -y && +colcon build && +source ./install/setup.bash && +ros2 launch pacsim example.launch.py & +source ./install/setup.bash && +ros2 launch foxglove_bridge foxglove_bridge_launch.xml # Foxglove bridge in parallel \ No newline at end of file diff --git a/track_editor/README.md b/track_editor/README.md new file mode 100644 index 0000000..a0dbd39 --- /dev/null +++ b/track_editor/README.md @@ -0,0 +1,14 @@ +# Track Generator + +## Dependencies + +- PyQT5 (```pip install PyQT5```) + +## Using + +To run the track generator: + +```sh +cd track_editor # if you are not in this folder already +python main.py +``` From d4522d2fe1e240960585ab26b3c7ecfcbc6653d1 Mon Sep 17 00:00:00 2001 From: marhcouto Date: Fri, 19 Apr 2024 18:26:03 +0100 Subject: [PATCH 02/21] fix: added db3 to ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b844304..0557b00 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ **/install/* **/log/* **/.vscode/* +*.db3 !.gitkeep From bc080dab69606f549796635bc1443049ce818491 Mon Sep 17 00:00:00 2001 From: lourenco31 Date: Mon, 22 Apr 2024 16:10:31 +0100 Subject: [PATCH 03/21] fix entrypoint.sh --- docker-compose.yml | 4 ++-- entrypoint.sh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 121fefd..595ecea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ services: - ros2_dev: + pacsim: container_name: ros2_development_container build: context: . @@ -35,4 +35,4 @@ services: - "8765:8765" network_mode: host command: > - bash -c "cd home/ws/ && ./entrypoint.sh" \ No newline at end of file + bash -c "cd /home/ws/ && ./entrypoint.sh" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index dc6976e..60843e0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,5 +5,6 @@ rosdep install --from-paths src --ignore-src -y && colcon build && source ./install/setup.bash && ros2 launch pacsim example.launch.py & +cd /home/ws/ && source ./install/setup.bash && ros2 launch foxglove_bridge foxglove_bridge_launch.xml # Foxglove bridge in parallel \ No newline at end of file From 474d6cc53fc3cd1060f0cf6bebdeb0f439706199 Mon Sep 17 00:00:00 2001 From: marhcouto Date: Fri, 26 Apr 2024 12:49:17 +0000 Subject: [PATCH 04/21] fix: fixed entrypoint script --- entrypoint.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 60843e0..54f9c9d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,20 @@ #! /bin/bash +echo "HOSTNAME OUTPUT:" +hostname -I + +echo "\n" + sudo apt update && rosdep update && rosdep install --from-paths src --ignore-src -y && -colcon build && +colcon build & + +wait $! + +cd /home/ws/ && source ./install/setup.bash && ros2 launch pacsim example.launch.py & + cd /home/ws/ && source ./install/setup.bash && -ros2 launch foxglove_bridge foxglove_bridge_launch.xml # Foxglove bridge in parallel \ No newline at end of file +ros2 launch foxglove_bridge foxglove_bridge_launch.xml # Foxglove bridge in parallel From deb91a963e244c2fe83a89b264a7ebc58ead76e2 Mon Sep 17 00:00:00 2001 From: marhcouto Date: Mon, 13 May 2024 18:05:03 +0000 Subject: [PATCH 05/21] fix: removed foxglove from entrypoint and fixed docker compose2 --- docker-compose.yml | 4 +++- entrypoint.sh | 11 +---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 595ecea..5841806 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: pacsim: - container_name: ros2_development_container + container_name: pacsim-container build: context: . dockerfile: .devcontainer/Dockerfile @@ -34,5 +34,7 @@ services: ports: - "8765:8765" network_mode: host + ipc: host + pid: host command: > bash -c "cd /home/ws/ && ./entrypoint.sh" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 54f9c9d..d0461fb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,9 +1,4 @@ #! /bin/bash -echo "HOSTNAME OUTPUT:" -hostname -I - -echo "\n" - sudo apt update && rosdep update && rosdep install --from-paths src --ignore-src -y && @@ -13,8 +8,4 @@ wait $! cd /home/ws/ && source ./install/setup.bash && -ros2 launch pacsim example.launch.py & - -cd /home/ws/ && -source ./install/setup.bash && -ros2 launch foxglove_bridge foxglove_bridge_launch.xml # Foxglove bridge in parallel +ros2 launch pacsim example.launch.py From e59d4f80b54fe16e695fb3cf7bcc9694791b1415 Mon Sep 17 00:00:00 2001 From: marhcouto Date: Wed, 22 May 2024 18:17:39 +0000 Subject: [PATCH 06/21] fix: increased timeout for start to not trigger error --- build/.gitkeep | 1 + config/mainConfig.yaml | 2 +- install/.gitkeep | 1 + log/.gitkeep | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 build/.gitkeep create mode 100644 install/.gitkeep create mode 100644 log/.gitkeep diff --git a/build/.gitkeep b/build/.gitkeep new file mode 100644 index 0000000..45ea04d --- /dev/null +++ b/build/.gitkeep @@ -0,0 +1 @@ +DO NOT REMOVE \ No newline at end of file diff --git a/config/mainConfig.yaml b/config/mainConfig.yaml index 33702a0..4c64e20 100644 --- a/config/mainConfig.yaml +++ b/config/mainConfig.yaml @@ -1,6 +1,6 @@ pacsim: timeouts: - start: 60 # time to trigger first timekeeping gate + start: 300 # time to trigger first timekeeping gate -> CREATES ERROR acceleration: 25 autocross: 300 skidpad: 90 diff --git a/install/.gitkeep b/install/.gitkeep new file mode 100644 index 0000000..45ea04d --- /dev/null +++ b/install/.gitkeep @@ -0,0 +1 @@ +DO NOT REMOVE \ No newline at end of file diff --git a/log/.gitkeep b/log/.gitkeep new file mode 100644 index 0000000..45ea04d --- /dev/null +++ b/log/.gitkeep @@ -0,0 +1 @@ +DO NOT REMOVE \ No newline at end of file From 7af3d35a5f4c68194ef7cdeeb705965cb1a560fc Mon Sep 17 00:00:00 2001 From: marhcouto Date: Fri, 24 May 2024 11:57:54 +0000 Subject: [PATCH 07/21] fix: removed .gitkeep --- .gitignore | 1 - build/.gitkeep | 1 - cache/iron-ros-base-jammy/build/.gitkeep | 1 - cache/iron-ros-base-jammy/install/.gitkeep | 1 - cache/iron-ros-base-jammy/log/.gitkeep | 1 - install/.gitkeep | 1 - log/.gitkeep | 1 - 7 files changed, 7 deletions(-) delete mode 100644 build/.gitkeep delete mode 100644 cache/iron-ros-base-jammy/build/.gitkeep delete mode 100644 cache/iron-ros-base-jammy/install/.gitkeep delete mode 100644 cache/iron-ros-base-jammy/log/.gitkeep delete mode 100644 install/.gitkeep delete mode 100644 log/.gitkeep diff --git a/.gitignore b/.gitignore index 0557b00..292644e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,5 @@ *.db3 -!.gitkeep !.vscode/settings.json !.vscode/c_cpp_properties.json diff --git a/build/.gitkeep b/build/.gitkeep deleted file mode 100644 index 45ea04d..0000000 --- a/build/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -DO NOT REMOVE \ No newline at end of file diff --git a/cache/iron-ros-base-jammy/build/.gitkeep b/cache/iron-ros-base-jammy/build/.gitkeep deleted file mode 100644 index 45ea04d..0000000 --- a/cache/iron-ros-base-jammy/build/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -DO NOT REMOVE \ No newline at end of file diff --git a/cache/iron-ros-base-jammy/install/.gitkeep b/cache/iron-ros-base-jammy/install/.gitkeep deleted file mode 100644 index 45ea04d..0000000 --- a/cache/iron-ros-base-jammy/install/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -DO NOT REMOVE \ No newline at end of file diff --git a/cache/iron-ros-base-jammy/log/.gitkeep b/cache/iron-ros-base-jammy/log/.gitkeep deleted file mode 100644 index 45ea04d..0000000 --- a/cache/iron-ros-base-jammy/log/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -DO NOT REMOVE \ No newline at end of file diff --git a/install/.gitkeep b/install/.gitkeep deleted file mode 100644 index 45ea04d..0000000 --- a/install/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -DO NOT REMOVE \ No newline at end of file diff --git a/log/.gitkeep b/log/.gitkeep deleted file mode 100644 index 45ea04d..0000000 --- a/log/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -DO NOT REMOVE \ No newline at end of file From d97829aae4b6a6cafb39e35c3cf9bdc82de95f3f Mon Sep 17 00:00:00 2001 From: Yves Bonneau Date: Fri, 24 May 2024 16:40:38 +0000 Subject: [PATCH 08/21] added script to fix launch --- environment_setup.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 environment_setup.sh diff --git a/environment_setup.sh b/environment_setup.sh new file mode 100755 index 0000000..aa20f49 --- /dev/null +++ b/environment_setup.sh @@ -0,0 +1,4 @@ +#!/bin/sh +mkdir -p ./cache/iron-ros-base-jammy/build +mkdir -p ./cache/iron-ros-base-jammy/install +mkdir -p ./cache/iron-ros-base-jammy/log \ No newline at end of file From c96cc5f1150323ccaf176e0e9f7f97e6ea48fdb4 Mon Sep 17 00:00:00 2001 From: BrunoDias201907828 Date: Thu, 30 May 2024 11:26:04 +0100 Subject: [PATCH 09/21] (refactor): removed ports mapping and simplified overall --- .devcontainer/Dockerfile | 2 -- .devcontainer/devcontainer.json | 3 +-- docker-compose.yml | 3 +-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0e686f3..0fb55eb 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -32,11 +32,9 @@ RUN apt update && apt upgrade -y \ && pip install rosbags \ && pip install PyQT5 \ && apt install ros-$ROS_DISTRO-xacro -y \ - && apt install ros-$ROS_DISTRO-foxglove-bridge -y \ && apt clean RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> /home/"$USERNAME"/.bashrc -EXPOSE 8765 ENV SHELL /bin/bash USER $USERNAME CMD ["/bin/bash"] \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 76c3f90..b7f114a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -37,8 +37,7 @@ "--net=host", "--ipc=host", "--pid=host", - "-e", "DISPLAY=${env:DISPLAY}", - "-p", "8765:8765" + "-e", "DISPLAY=${env:DISPLAY}" ], "mounts": [ "source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached", diff --git a/docker-compose.yml b/docker-compose.yml index 5841806..046c51d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ services: pacsim: container_name: pacsim-container + image: pacsim-pacsim build: context: . dockerfile: .devcontainer/Dockerfile @@ -31,8 +32,6 @@ services: - type: bind source: "./cache/iron-ros-base-jammy/log" target: "/home/ws/log" - ports: - - "8765:8765" network_mode: host ipc: host pid: host From 1c38549982401e1d55b136cd46a8a88ed2d44515 Mon Sep 17 00:00:00 2001 From: BrunoDias201907828 Date: Mon, 3 Jun 2024 19:38:28 +0100 Subject: [PATCH 10/21] (docs): added more to usage_tutorial --- README.md | 2 +- doc/usage_tutorial.md | 21 +++++++++++++++++---- docker-compose.yml | 4 +++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d716256..b3aade4 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ The sensors and vehicle model are configured using config files. Examples are pr The default vehicle model provided is rather simple and just meant to be a starting point. You are encouraged to integrate your own vehicle model by implementing the `IVehicleModel` class. -More info in the [docs folder](./doc/usage_tutorial.md). +For more info on some funcionalities and how to run the simulator, check the [docs folder](./doc/usage_tutorial.md). # Contributing Contributions in any form (reports, feedback, requests, submissions) are welcome. Preferably create an Issue or Pull request for that. diff --git a/doc/usage_tutorial.md b/doc/usage_tutorial.md index 697bcfa..91fe22a 100644 --- a/doc/usage_tutorial.md +++ b/doc/usage_tutorial.md @@ -10,7 +10,15 @@ To configurure parameters of the simulator: ## Running the simulator -To run the simulator, simply use one of the launch files present in the [launch folder](../launch/): +The simulator is inside a docker container, which by running it, the simulator will also be launched. To do this, run the following command on your terminal: + +```bash +docker compose up +``` + +In case you want to do some work inside the container, by using the Dev Containers extension in VSCode the process becomes very simple, since the system is already setup for that. + +Inside the devcontainer, in order to run the simulator, simply use one of the launch files present in the [launch folder](../launch/): ```sh colcon build # if you haven't compiled yet @@ -20,12 +28,17 @@ ros2 launch pacsim example.launch.py ## Visualization -Use Foxglove (or Rviz) for visualization purposes. TODO: create Foxglove dashboard for pacsim +For visualization, either Rviz or Foxglove can be used, the later needing to run the foxglove bridge in order to work. -## Track Generation +## Track + +The simulator already has comes with some tracks, used in different events of the competitions (acceleration, skidpad...). + +### Track generator Checkout the track generator in the [track editor folder](../track_editor/). -## Other tools + +### Other tools [Scrips folder](../scripts/) contains a tool for track convertion from fssim format to this one, as well as a report evaluation tool. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 046c51d..305c036 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,4 +36,6 @@ services: ipc: host pid: host command: > - bash -c "cd /home/ws/ && ./entrypoint.sh" \ No newline at end of file + bash -c "cd /home/ws/ && ./entrypoint.sh" + + From 73db3540bb939d67bd461e9fcfe4132ef903ec58 Mon Sep 17 00:00:00 2001 From: BrunoDias201907828 Date: Tue, 4 Jun 2024 16:12:05 +0100 Subject: [PATCH 11/21] (docs): fix made --- README.md | 2 +- doc/docker_usage.md | 13 +++++++++++++ doc/usage_tutorial.md | 44 ------------------------------------------- 3 files changed, 14 insertions(+), 45 deletions(-) create mode 100644 doc/docker_usage.md delete mode 100644 doc/usage_tutorial.md diff --git a/README.md b/README.md index b3aade4..d6da169 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ The sensors and vehicle model are configured using config files. Examples are pr The default vehicle model provided is rather simple and just meant to be a starting point. You are encouraged to integrate your own vehicle model by implementing the `IVehicleModel` class. -For more info on some funcionalities and how to run the simulator, check the [docs folder](./doc/usage_tutorial.md). +For info on how to run the docker container and how to develop code around it, check the [docs folder](./doc/docker_usage.md). # Contributing Contributions in any form (reports, feedback, requests, submissions) are welcome. Preferably create an Issue or Pull request for that. diff --git a/doc/docker_usage.md b/doc/docker_usage.md new file mode 100644 index 0000000..105d479 --- /dev/null +++ b/doc/docker_usage.md @@ -0,0 +1,13 @@ +# How to use + +## Docker Compose + +The simulator is inside a docker container, which by running it, the simulator will also be launched. To do this, run the following command on your terminal: + +```bash +docker compose up +``` + +## Code Development - Dev Container + +In case you want to do some work inside the container, by using the Dev Containers extension in VSCode the process becomes very simple, since there is a .devcontainer which contains the configuration for a development container for that purpose. \ No newline at end of file diff --git a/doc/usage_tutorial.md b/doc/usage_tutorial.md deleted file mode 100644 index 91fe22a..0000000 --- a/doc/usage_tutorial.md +++ /dev/null @@ -1,44 +0,0 @@ -# How to use - -## Configuration - -To configurure parameters of the simulator: -- [perception.yaml](../config/perception.yaml) - configuration of cone models -- [sensors.yaml](../config/sensors.yaml) - configuration of imu, wheel encoders and other sensors -- [vehicleModel.yaml](../config/vehicleModel.yaml) - configuration of vehicle model -- [mainConfig.yaml](../config/mainConfig.yaml) - configuration of event timeouts and other competition features - -## Running the simulator - -The simulator is inside a docker container, which by running it, the simulator will also be launched. To do this, run the following command on your terminal: - -```bash -docker compose up -``` - -In case you want to do some work inside the container, by using the Dev Containers extension in VSCode the process becomes very simple, since the system is already setup for that. - -Inside the devcontainer, in order to run the simulator, simply use one of the launch files present in the [launch folder](../launch/): - -```sh -colcon build # if you haven't compiled yet -source ./install/setup.bash # if you haven't already -ros2 launch pacsim example.launch.py -``` - -## Visualization - -For visualization, either Rviz or Foxglove can be used, the later needing to run the foxglove bridge in order to work. - -## Track - -The simulator already has comes with some tracks, used in different events of the competitions (acceleration, skidpad...). - -### Track generator - -Checkout the track generator in the [track editor folder](../track_editor/). - - -### Other tools - -[Scrips folder](../scripts/) contains a tool for track convertion from fssim format to this one, as well as a report evaluation tool. \ No newline at end of file From 985477fbdafa0754477d88ec7dd0e1d30647bfde Mon Sep 17 00:00:00 2001 From: BrunoDias201907828 Date: Tue, 4 Jun 2024 16:27:07 +0100 Subject: [PATCH 12/21] (docs): added dev container part --- doc/docker_usage.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/docker_usage.md b/doc/docker_usage.md index 105d479..3859734 100644 --- a/doc/docker_usage.md +++ b/doc/docker_usage.md @@ -10,4 +10,18 @@ docker compose up ## Code Development - Dev Container -In case you want to do some work inside the container, by using the Dev Containers extension in VSCode the process becomes very simple, since there is a .devcontainer which contains the configuration for a development container for that purpose. \ No newline at end of file +In case you want to do some work inside the container, by using the Dev Containers extension in VSCode the process becomes very simple, since there is a .devcontainer which contains the configuration for a development container for that purpose. + +In order to run this, first you need to install some extensions. You can get them through here [Remote Development Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack). +Then you need to create some cache folders. This can be done by running the following commands: + +```bash +mkdir cache +mkdir cache/iron-ros-base-jammy +mkdir cache/iron-ros-base-jammy/build +mkdir cache/iron-ros-base-jammy/install +mkdir cache/iron-ros-base-jammy/log +``` +Finally do Ctrl + Shift + P and choose the option: + +- Dev Containers: Rebuild and Reopen in container \ No newline at end of file From 9dc064d77a879cbd823333f069da6846261892dc Mon Sep 17 00:00:00 2001 From: Marcelo Couto Date: Fri, 14 Jun 2024 10:22:41 +0100 Subject: [PATCH 13/21] fix(docker): fixed tutorial --- doc/docker_usage.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/doc/docker_usage.md b/doc/docker_usage.md index 3859734..3cb2f11 100644 --- a/doc/docker_usage.md +++ b/doc/docker_usage.md @@ -12,16 +12,12 @@ docker compose up In case you want to do some work inside the container, by using the Dev Containers extension in VSCode the process becomes very simple, since there is a .devcontainer which contains the configuration for a development container for that purpose. -In order to run this, first you need to install some extensions. You can get them through here [Remote Development Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack). +To run this, first you need to install some extensions. You can get them through here [Remote Development Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack). Then you need to create some cache folders. This can be done by running the following commands: ```bash -mkdir cache -mkdir cache/iron-ros-base-jammy -mkdir cache/iron-ros-base-jammy/build -mkdir cache/iron-ros-base-jammy/install -mkdir cache/iron-ros-base-jammy/log +./environment_setup.sh ``` Finally do Ctrl + Shift + P and choose the option: -- Dev Containers: Rebuild and Reopen in container \ No newline at end of file +- Dev Containers: Rebuild and Reopen in container From 399af4441df36ab65a6edebf3fcb415738540653 Mon Sep 17 00:00:00 2001 From: Marcelo Couto Date: Fri, 14 Jun 2024 10:25:42 +0100 Subject: [PATCH 14/21] fix(README): organized README --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d6da169..b0da4ef 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,6 @@ Install dependencies: `sudo apt install ros-iron-desktop ros-iron-xacro` -## Docker Dev Container - -A [Dockerfile](./.devcontainer/Dockerfile) is configured that already contains all the dependencies. It can be used with a [dev container environment](./.devcontainer) or launched independently wiht the [docker-compose](./docker-compose.yml) file, which uses the same Docker image and executes the [entrypoint.sh script](./entrypoint.sh) at startup. - # How to get started To use PacSim with your autonomous system, you need to create a message converter node to match your own interfaces with the simulator. @@ -35,7 +31,9 @@ The sensors and vehicle model are configured using config files. Examples are pr The default vehicle model provided is rather simple and just meant to be a starting point. You are encouraged to integrate your own vehicle model by implementing the `IVehicleModel` class. -For info on how to run the docker container and how to develop code around it, check the [docs folder](./doc/docker_usage.md). +## Docker Dev Container + +A [Dockerfile](./.devcontainer/Dockerfile) is configured that already contains all the dependencies. It can be used with a [dev container environment](./.devcontainer) or launched independently wiht the [docker-compose](./docker-compose.yml) file. For more info, check the [docs folder](./doc/docker_usage.md). # Contributing Contributions in any form (reports, feedback, requests, submissions) are welcome. Preferably create an Issue or Pull request for that. @@ -45,4 +43,4 @@ The initial version was developed at Elbflorace by: * Alexander Phieler (Main development) * Niklas Leukroth (Track and Config file parser) * Sergio Antuna (Artwork) -* Tim Hanel (3d car model integration) \ No newline at end of file +* Tim Hanel (3d car model integration) From dbdef3010f7c51eca5f4640fd04d184c54297969 Mon Sep 17 00:00:00 2001 From: Marcelo Couto Date: Fri, 14 Jun 2024 10:25:57 +0100 Subject: [PATCH 15/21] fix(docker): moved information to tutorial --- doc/docker_usage.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/docker_usage.md b/doc/docker_usage.md index 3cb2f11..c8d3891 100644 --- a/doc/docker_usage.md +++ b/doc/docker_usage.md @@ -8,6 +8,8 @@ The simulator is inside a docker container, which by running it, the simulator w docker compose up ``` +The *docker-compose.yml* file uses the same Docker image as the development container (Image in [.devcontainer folder](../.devcontainer)) and executes the [entrypoint.sh script](./entrypoint.sh) at startup. + ## Code Development - Dev Container In case you want to do some work inside the container, by using the Dev Containers extension in VSCode the process becomes very simple, since there is a .devcontainer which contains the configuration for a development container for that purpose. From 325dcdec9ba7e1285bba7c4f4415e2107d3c6828 Mon Sep 17 00:00:00 2001 From: Marcelo Couto Date: Fri, 14 Jun 2024 10:27:20 +0100 Subject: [PATCH 16/21] fix(config): reset config --- config/mainConfig.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/mainConfig.yaml b/config/mainConfig.yaml index 4c64e20..7e4460c 100644 --- a/config/mainConfig.yaml +++ b/config/mainConfig.yaml @@ -1,6 +1,6 @@ pacsim: timeouts: - start: 300 # time to trigger first timekeeping gate -> CREATES ERROR + start: 60 # time to trigger first timekeeping gate acceleration: 25 autocross: 300 skidpad: 90 @@ -9,4 +9,4 @@ pacsim: oc_detect: true doo_detect: true uss_detect: true - finish_validate: true \ No newline at end of file + finish_validate: true From a4b7e1bf6b161c239335ebef3960ec3c1d408ea2 Mon Sep 17 00:00:00 2001 From: Marcelo Couto Date: Fri, 14 Jun 2024 10:34:28 +0100 Subject: [PATCH 17/21] fix(docker-tutorial): note on communication settings --- doc/docker_usage.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/docker_usage.md b/doc/docker_usage.md index c8d3891..f6212c3 100644 --- a/doc/docker_usage.md +++ b/doc/docker_usage.md @@ -23,3 +23,10 @@ Then you need to create some cache folders. This can be done by running the foll Finally do Ctrl + Shift + P and choose the option: - Dev Containers: Rebuild and Reopen in container + +## General Notes + +For the simulator to communicate with your system, make sure to set the ROS Domain ID to the same value in both systems: +```sh +export ROS_DOMAIN_ID=42 +``` From bcea3b39f20e22353f22c3bbf64eb96cc2318628 Mon Sep 17 00:00:00 2001 From: marhcouto Date: Sun, 16 Jun 2024 14:02:47 +0000 Subject: [PATCH 18/21] fix: fixed car showing up weird in Foxglove and steering being in the actuator --- config/mainConfig.yaml | 2 +- src/VehicleModel/VehicleModelBicycle.cpp | 8 ++++---- urdf/separate_model.xacro | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/config/mainConfig.yaml b/config/mainConfig.yaml index 70b7c3f..daf9f76 100644 --- a/config/mainConfig.yaml +++ b/config/mainConfig.yaml @@ -1,6 +1,6 @@ pacsim: timeouts: - start: 60 # time to trigger first timekeeping gate + start: 300 # time to trigger first timekeeping gate acceleration: 25 autocross: 300 skidpad: 90 diff --git a/src/VehicleModel/VehicleModelBicycle.cpp b/src/VehicleModel/VehicleModelBicycle.cpp index 8491a3a..df4bd87 100644 --- a/src/VehicleModel/VehicleModelBicycle.cpp +++ b/src/VehicleModel/VehicleModelBicycle.cpp @@ -92,13 +92,13 @@ class VehicleModelBicycle : public IVehicleModel double avgRatio = 0.5 * (this->innerSteeringRatio + this->outerSteeringRatio); if (in > 0) { - this->steeringAngles.FL = this->innerSteeringRatio * in; - this->steeringAngles.FR = this->outerSteeringRatio * in; + this->steeringAngles.FL = this->innerSteeringRatio * in / avgRatio; + this->steeringAngles.FR = this->outerSteeringRatio * in / avgRatio; } else { - this->steeringAngles.FL = this->outerSteeringRatio * in; - this->steeringAngles.FR = this->innerSteeringRatio * in; + this->steeringAngles.FL = this->outerSteeringRatio * in / avgRatio; + this->steeringAngles.FR = this->innerSteeringRatio * in / avgRatio; } return; } diff --git a/urdf/separate_model.xacro b/urdf/separate_model.xacro index 7f3f89c..8e0f397 100644 --- a/urdf/separate_model.xacro +++ b/urdf/separate_model.xacro @@ -10,7 +10,7 @@ - + @@ -19,7 +19,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -52,7 +52,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -76,7 +76,7 @@ - + From b96517cf6fb1bee86f831fb32caddb46cc892223 Mon Sep 17 00:00:00 2001 From: marhcouto Date: Mon, 24 Jun 2024 15:29:57 +0000 Subject: [PATCH 19/21] fix(vehicle-model): adjusted vehicle model to not use gear ratio --- src/VehicleModel/VehicleModelBicycle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VehicleModel/VehicleModelBicycle.cpp b/src/VehicleModel/VehicleModelBicycle.cpp index df4bd87..a224b2a 100644 --- a/src/VehicleModel/VehicleModelBicycle.cpp +++ b/src/VehicleModel/VehicleModelBicycle.cpp @@ -147,7 +147,7 @@ class VehicleModelBicycle : public IVehicleModel Eigen::Vector3d vFront = vCog + omega.cross(rFront); Eigen::Vector3d vRear = vCog + omega.cross(rRear); - double rpm2ms = this->wheelRadius * 2.0 * M_PI / (this->gearRatio * 60.0); + double rpm2ms = this->wheelRadius * 2.0 * M_PI / 60; bool stillstand = (vCog.norm() < 0.1) && (std::abs(this->angularVelocity.z()) < 0.001); From 072cae436a4fef82e7e70ab765114e117328268b Mon Sep 17 00:00:00 2001 From: marhcouto Date: Sat, 29 Jun 2024 19:04:07 +0000 Subject: [PATCH 20/21] fix(config): fixed perception sensors not showing up and adjusted params --- config/mainConfig.yaml | 2 +- config/perception.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/mainConfig.yaml b/config/mainConfig.yaml index daf9f76..72d72d7 100644 --- a/config/mainConfig.yaml +++ b/config/mainConfig.yaml @@ -10,5 +10,5 @@ pacsim: doo_detect: true uss_detect: true finish_validate: true - cog_frame_id_pipeline: "cog" # name of the cog frame in the autnomous pipeline + cog_frame_id_pipeline: "car" # name of the cog frame in the autnomous pipeline broadcast_sensors_tf2: true diff --git a/config/perception.yaml b/config/perception.yaml index 464ef70..e904d3c 100644 --- a/config/perception.yaml +++ b/config/perception.yaml @@ -10,7 +10,7 @@ perception_sensors: orientation: [0.0,0.0,0.0] observation: min_range: 1 - max_range: 45 + max_range: 20 min_angle_horizontal: -1.0472 max_angle_horizontal: 1.0472 min_angle_vertical: -0.2181662 @@ -18,8 +18,8 @@ perception_sensors: detection: prob_min_dist: 0.99 - prob_decrease_dist_linear: 0.01 - prob_decrease_dist_quadratic: 0.00012 + prob_decrease_dist_linear: 0.001 + prob_decrease_dist_quadratic: 0.000012 min_prob: 0.1 classification: From 8e7b7a40083a0bfb41299b21c7678327c50a6939 Mon Sep 17 00:00:00 2001 From: Davide64-dev Date: Mon, 7 Oct 2024 13:11:06 +0100 Subject: [PATCH 21/21] fix: solved a part of the launch file --- launch/example.launch.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/launch/example.launch.py b/launch/example.launch.py index 709d314..335ca02 100644 --- a/launch/example.launch.py +++ b/launch/example.launch.py @@ -52,8 +52,6 @@ def generate_launch_description(): executable='robot_state_publisher', name='robot_state_publisher', output='screen', - parameters=[{'use_sim_time':True}, {'publish_frequency':float(1000), - 'robot_description': Command(['xacro',' ',xacro_path]) - }], + parameters=[{'use_sim_time':True}, {'publish_frequency':float(1000),}], arguments=[xacro_path]) return LaunchDescription([nodePacsim, nodePacsimShutdownEventHandler, robot_state_publisher]) \ No newline at end of file