From 2e40090514a1653d2b871bb85b83a4c733213da6 Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Sun, 16 Apr 2023 10:39:47 +0100 Subject: [PATCH] Copter: add bring-up and launch for Iris (#1) * Launch Iris: initial version of ardupilot_gz - Adapted from https://github.com/gazebosim/ros_gz_project_template. - Change project names. - Update dependencies. - Update README. - Update launch for macOS (separate server and gui for Gazebo). - Update maintainer details. Signed-off-by: Rhys Mainwaring * Launch Iris: rename diff drive bridge yaml, remove extra clock entry Signed-off-by: Rhys Mainwaring * Launch Iris: add bringup for iris quadcopter - Shorten name in interface to iris. Signed-off-by: Rhys Mainwaring * Launch Iris: add lift-drag and ardupilot plugins to example Signed-off-by: Rhys Mainwaring * Launch Iris: enable static code checks - Enable static code checks in ardupilot_gz_gazebo - Enable static code checks in ardupilot_gz_description - Run all common linters. - Enable static code checks in ardupilot_gz_bringup - Apply flake8 extend-ignore. - Format launch files with black. - Apply common linters. Enable static code checks in ardupilot_gz_application Signed-off-by: Rhys Mainwaring * Launch Iris: add iris bringup launch - Compose the SITL and microROS agent launch with Gazebo and Rviz. Signed-off-by: Rhys Mainwaring * Launch Iris: update README Signed-off-by: Rhys Mainwaring * Launch Iris: move projects up to main directory Signed-off-by: Rhys Mainwaring --- README.md | 129 ++++++- ardupilot_gz_application/.flake8 | 10 + ardupilot_gz_application/CMakeLists.txt | 23 ++ ardupilot_gz_application/package.xml | 20 ++ ardupilot_gz_bringup/.flake8 | 10 + ardupilot_gz_bringup/CMakeLists.txt | 40 +++ ardupilot_gz_bringup/config/diff_drive.rviz | 257 ++++++++++++++ .../config/diff_drive_bridge.yaml | 37 ++ ardupilot_gz_bringup/config/iris.rviz | 228 ++++++++++++ ardupilot_gz_bringup/config/iris_bridge.yaml | 27 ++ .../launch/bringup_iris.launch.py | 126 +++++++ .../launch/diff_drive.launch.py | 109 ++++++ ardupilot_gz_bringup/launch/iris.launch.py | 127 +++++++ ardupilot_gz_bringup/package.xml | 25 ++ ardupilot_gz_description/.flake8 | 10 + ardupilot_gz_description/CMakeLists.txt | 38 ++ .../hooks/ardupilot_gz_description.dsv.in | 1 + .../hooks/ardupilot_gz_description.sh.in | 2 + .../models/diff_drive/model.config | 15 + .../models/diff_drive/model.sdf | 245 +++++++++++++ ardupilot_gz_description/package.xml | 19 + ardupilot_gz_gazebo/.flake8 | 10 + ardupilot_gz_gazebo/CMakeLists.txt | 80 +++++ .../hooks/ardupilot_gz_gazebo.dsv.in | 2 + .../hooks/ardupilot_gz_gazebo.sh.in | 2 + .../ardupilot_gz_gazebo/BasicSystem.hh | 42 +++ .../include/ardupilot_gz_gazebo/FullSystem.hh | 79 +++++ ardupilot_gz_gazebo/package.xml | 32 ++ ardupilot_gz_gazebo/src/BasicSystem.cc | 46 +++ ardupilot_gz_gazebo/src/FullSystem.cc | 82 +++++ ardupilot_gz_gazebo/worlds/diff_drive.sdf | 109 ++++++ ardupilot_gz_gazebo/worlds/iris.sdf | 325 ++++++++++++++++++ 32 files changed, 2306 insertions(+), 1 deletion(-) create mode 100644 ardupilot_gz_application/.flake8 create mode 100644 ardupilot_gz_application/CMakeLists.txt create mode 100644 ardupilot_gz_application/package.xml create mode 100644 ardupilot_gz_bringup/.flake8 create mode 100644 ardupilot_gz_bringup/CMakeLists.txt create mode 100644 ardupilot_gz_bringup/config/diff_drive.rviz create mode 100644 ardupilot_gz_bringup/config/diff_drive_bridge.yaml create mode 100644 ardupilot_gz_bringup/config/iris.rviz create mode 100644 ardupilot_gz_bringup/config/iris_bridge.yaml create mode 100644 ardupilot_gz_bringup/launch/bringup_iris.launch.py create mode 100644 ardupilot_gz_bringup/launch/diff_drive.launch.py create mode 100644 ardupilot_gz_bringup/launch/iris.launch.py create mode 100644 ardupilot_gz_bringup/package.xml create mode 100644 ardupilot_gz_description/.flake8 create mode 100644 ardupilot_gz_description/CMakeLists.txt create mode 100644 ardupilot_gz_description/hooks/ardupilot_gz_description.dsv.in create mode 100644 ardupilot_gz_description/hooks/ardupilot_gz_description.sh.in create mode 100644 ardupilot_gz_description/models/diff_drive/model.config create mode 100644 ardupilot_gz_description/models/diff_drive/model.sdf create mode 100644 ardupilot_gz_description/package.xml create mode 100644 ardupilot_gz_gazebo/.flake8 create mode 100644 ardupilot_gz_gazebo/CMakeLists.txt create mode 100644 ardupilot_gz_gazebo/hooks/ardupilot_gz_gazebo.dsv.in create mode 100644 ardupilot_gz_gazebo/hooks/ardupilot_gz_gazebo.sh.in create mode 100644 ardupilot_gz_gazebo/include/ardupilot_gz_gazebo/BasicSystem.hh create mode 100644 ardupilot_gz_gazebo/include/ardupilot_gz_gazebo/FullSystem.hh create mode 100644 ardupilot_gz_gazebo/package.xml create mode 100644 ardupilot_gz_gazebo/src/BasicSystem.cc create mode 100644 ardupilot_gz_gazebo/src/FullSystem.cc create mode 100644 ardupilot_gz_gazebo/worlds/diff_drive.sdf create mode 100755 ardupilot_gz_gazebo/worlds/iris.sdf diff --git a/README.md b/README.md index 2c9a032..4942aa9 100644 --- a/README.md +++ b/README.md @@ -1 +1,128 @@ -# ardupilot_gz \ No newline at end of file +# ardupilot_gz + +Adapted from the [`ros_gz_project_template`](https://github.com/gazebosim/ros_gz_project_template) project integrating ROS 2 and Gazebo. + +## Included packages + +* `ardupilot_gz_description` - Contains the sdf description of the simulated + system and any other assets. + +* `ardupilot_gz_gazebo` - Contains Gazebo specific code and configurations such + as system plugins. + +* `ardupilot_gz_application` - Contains ROS 2 specific code and configuration. + +* `ardupilot_gz_bringup` - Contains launch files and high level utilities. + + +## Install + +### Dependencies + +1. Install [ROS 2 Humble](https://docs.ros.org/en/humble/index.html) + +1. Install [Gazebo Garden](https://gazebosim.org/docs/garden) + +1. Install necessary tools + + `sudo apt install python3-vcstool python3-colcon-common-extensions git wget` + +### Usage + +1. Create a workspace, for example: + + ``` + mkdir -p ~/ros2_ws/src + cd ~/ros2_ws/src + ``` + +1. Clone the project: + + ``` + TBC + ``` + +1. Set the Gazebo version to Garden: + + ``` + export GZ_VERSION=garden + ``` + +1. Install ROS dependencies + + ``` + sudo rosdep init + rosdep update + rosdep install --from-paths src --ignore-src -r -y -i + ``` + +1. Build and install + + ``` + cd ~/ros2_ws + colcon build --cmake-args -DBUILD_TESTING=ON + ``` + +### Run + +1. Source the workspace + + `. ~/ros2_ws/install/setup.sh` + +1. Launch the simulation + + `ros2 launch ardupilot_gz_bringup bringup_iris.launch.py` + +1. Launch the a GCS + + `mavproxy.py --console --map` + +1. Inspect topics + + ```bash + $ ros2 topic list + /ROS2_BatteryState0 + /ROS2_NavSatFix0 + /ROS2_Time + /clicked_point + /clock + /goal_pose + /initialpose + /iris/odometry + /joint_states + /parameter_events + /robot_description + /rosout + /tf + /tf_static + ``` + + +## Notes + +1. Additional dependency + + `ros_gz` has a dependency on `gps_msgs` included in + + ```bash + git clone https://github.com/swri-robotics/gps_umd.git -b ros2-devel + ``` + + Add `COLCON_IGNORE` to `gpsd_client` as this package is not required and + will not build on macOS. + +1. sdformat_urdf + + On macOS the `robot_state_publisher` node cannot load the + `sdformat_urdf_plugin` plugin unless the + suffix is changed: + + ```bash + cd ./install/sdformat_urdf/lib + ln -s libsdformat_urdf_plugin.so libsdformat_urdf_plugin.dylib + ``` + +1. Model URIs + + The `` element must use the `package` prefix for resource to be located + by RViz. diff --git a/ardupilot_gz_application/.flake8 b/ardupilot_gz_application/.flake8 new file mode 100644 index 0000000..b79f25f --- /dev/null +++ b/ardupilot_gz_application/.flake8 @@ -0,0 +1,10 @@ +[flake8] +# Match black line length (default 88). +max-line-length = 88 +# Match black configuration where there are conflicts. +extend-ignore = + # Q000: Double quotes found but single quotes preferred + Q000, + # W503: Line break before binary operator + W503 + diff --git a/ardupilot_gz_application/CMakeLists.txt b/ardupilot_gz_application/CMakeLists.txt new file mode 100644 index 0000000..92f637c --- /dev/null +++ b/ardupilot_gz_application/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.5) +project(ardupilot_gz_application) + +# --------------------------------------------------------------------------- # +# Find dependencies. +find_package(ament_cmake REQUIRED) + +# --------------------------------------------------------------------------- # +# Build tests + +if(BUILD_TESTING) + # Override default flake8 configuration. + set(ament_cmake_flake8_CONFIG_FILE ${CMAKE_SOURCE_DIR}/.flake8) + + # Add linters. + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +# --------------------------------------------------------------------------- # +# Call last. + +ament_package() diff --git a/ardupilot_gz_application/package.xml b/ardupilot_gz_application/package.xml new file mode 100644 index 0000000..3509e05 --- /dev/null +++ b/ardupilot_gz_application/package.xml @@ -0,0 +1,20 @@ + + + + ardupilot_gz_application + 0.0.0 + Application code for `ardupilot_gz`. + Rhys Mainwaring + GPL-3.0 + + ament_cmake + + ament_lint_auto + ament_lint_auto + ament_lint_common + + + ament_cmake + + + diff --git a/ardupilot_gz_bringup/.flake8 b/ardupilot_gz_bringup/.flake8 new file mode 100644 index 0000000..b79f25f --- /dev/null +++ b/ardupilot_gz_bringup/.flake8 @@ -0,0 +1,10 @@ +[flake8] +# Match black line length (default 88). +max-line-length = 88 +# Match black configuration where there are conflicts. +extend-ignore = + # Q000: Double quotes found but single quotes preferred + Q000, + # W503: Line break before binary operator + W503 + diff --git a/ardupilot_gz_bringup/CMakeLists.txt b/ardupilot_gz_bringup/CMakeLists.txt new file mode 100644 index 0000000..2acf9fd --- /dev/null +++ b/ardupilot_gz_bringup/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.5) +project(ardupilot_gz_bringup) + +# --------------------------------------------------------------------------- # +# Find dependencies. +find_package(ament_cmake REQUIRED) + +# --------------------------------------------------------------------------- # +# Install. + +# Install project launch files. +install( + DIRECTORY + launch/ + DESTINATION share/${PROJECT_NAME}/launch +) + +# Install project configuration files. +install( + DIRECTORY + config/ + DESTINATION share/${PROJECT_NAME}/config +) + +# --------------------------------------------------------------------------- # +# Build tests. + +if(BUILD_TESTING) + # Override default flake8 configuration. + set(ament_cmake_flake8_CONFIG_FILE ${CMAKE_SOURCE_DIR}/.flake8) + + # Add linters. + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +# --------------------------------------------------------------------------- # +# Call last. + +ament_package() diff --git a/ardupilot_gz_bringup/config/diff_drive.rviz b/ardupilot_gz_bringup/config/diff_drive.rviz new file mode 100644 index 0000000..883ecee --- /dev/null +++ b/ardupilot_gz_bringup/config/diff_drive.rviz @@ -0,0 +1,257 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Status1 + Splitter Ratio: 0.5 + Tree Height: 719 + - Class: rviz_common/Selection + Name: Selection + - Class: rviz_common/Tool Properties + Expanded: + - /2D Goal Pose1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz_common/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz_common/Time + Experimental: false + Name: Time + SyncMode: 0 + SyncSource: LaserScan +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz_default_plugins/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 10 + Reference Frame: + Value: true + - Alpha: 1 + Class: rviz_default_plugins/RobotModel + Collision Enabled: false + Description File: "" + Description Source: Topic + Description Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /robot_description + Enabled: true + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + caster: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + chassis: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + left_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + lidar_link: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + right_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Mass Properties: + Inertia: false + Mass: false + Name: RobotModel + TF Prefix: diff_drive + Update Interval: 0 + Value: true + Visual Enabled: true + - Angle Tolerance: 0.10000000149011612 + Class: rviz_default_plugins/Odometry + Covariance: + Orientation: + Alpha: 0.5 + Color: 255; 255; 127 + Color Style: Unique + Frame: Local + Offset: 1 + Scale: 1 + Value: true + Position: + Alpha: 0.30000001192092896 + Color: 204; 51; 204 + Scale: 1 + Value: true + Value: true + Enabled: true + Keep: 100 + Name: Odometry + Position Tolerance: 0.10000000149011612 + Shape: + Alpha: 1 + Axes Length: 1 + Axes Radius: 0.10000000149011612 + Color: 255; 25; 0 + Head Length: 0.30000001192092896 + Head Radius: 0.10000000149011612 + Shaft Length: 1 + Shaft Radius: 0.05000000074505806 + Value: Arrow + Topic: + Depth: 5 + Durability Policy: Volatile + Filter size: 10 + History Policy: Keep Last + Reliability Policy: Reliable + Value: /diff_drive/odometry + Value: true + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz_default_plugins/LaserScan + Color: 255; 255; 255 + Color Transformer: Intensity + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Max Intensity: -999999 + Min Color: 0; 0; 0 + Min Intensity: 999999 + Name: LaserScan + Position Transformer: XYZ + Selectable: true + Size (Pixels): 3 + Size (m): 0.009999999776482582 + Style: Flat Squares + Topic: + Depth: 5 + Durability Policy: Volatile + Filter size: 10 + History Policy: Keep Last + Reliability Policy: Reliable + Value: /diff_drive/scan + Use Fixed Frame: true + Use rainbow: true + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Fixed Frame: diff_drive/odom + Frame Rate: 30 + Name: root + Tools: + - Class: rviz_default_plugins/Interact + Hide Inactive Objects: true + - Class: rviz_default_plugins/MoveCamera + - Class: rviz_default_plugins/Select + - Class: rviz_default_plugins/FocusCamera + - Class: rviz_default_plugins/Measure + Line color: 128; 128; 0 + - Class: rviz_default_plugins/SetInitialPose + Covariance x: 0.25 + Covariance y: 0.25 + Covariance yaw: 0.06853891909122467 + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /initialpose + - Class: rviz_default_plugins/SetGoal + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /goal_pose + - Class: rviz_default_plugins/PublishPoint + Single click: true + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /clicked_point + Transformation: + Current: + Class: rviz_default_plugins/TF + Value: true + Views: + Current: + Class: rviz_default_plugins/Orbit + Distance: 24.40549659729004 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: 0 + Y: 0 + Z: 0 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.785398006439209 + Target Frame: + Value: Orbit (rviz) + Yaw: 0.785398006439209 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 1016 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd0000000400000000000001560000035afc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d0000035a000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f0000035afc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d0000035a000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007360000003efc0100000002fb0000000800540069006d0065010000000000000736000002fb00fffffffb0000000800540069006d00650100000000000004500000000000000000000004c50000035a00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1846 + X: 74 + Y: 27 diff --git a/ardupilot_gz_bringup/config/diff_drive_bridge.yaml b/ardupilot_gz_bringup/config/diff_drive_bridge.yaml new file mode 100644 index 0000000..8896ebb --- /dev/null +++ b/ardupilot_gz_bringup/config/diff_drive_bridge.yaml @@ -0,0 +1,37 @@ +--- +- ros_topic_name: "/diff_drive/cmd_vel" + gz_topic_name: "/model/diff_drive/cmd_vel" + ros_type_name: "geometry_msgs/msg/Twist" + gz_type_name: "gz.msgs.Twist" + direction: ROS_TO_GZ +- ros_topic_name: "/clock" + gz_topic_name: "/clock" + ros_type_name: "rosgraph_msgs/msg/Clock" + gz_type_name: "gz.msgs.Clock" + direction: GZ_TO_ROS +- ros_topic_name: "/diff_drive/odometry" + gz_topic_name: "/model/diff_drive/odometry" + ros_type_name: "nav_msgs/msg/Odometry" + gz_type_name: "gz.msgs.Odometry" + direction: GZ_TO_ROS +- ros_topic_name: "/diff_drive/scan" + gz_topic_name: "/scan" + ros_type_name: "sensor_msgs/msg/LaserScan" + gz_type_name: "gz.msgs.LaserScan" + direction: GZ_TO_ROS +- ros_topic_name: "/joint_states" + gz_topic_name: "/world/demo/model/diff_drive/joint_state" + ros_type_name: "sensor_msgs/msg/JointState" + gz_type_name: "gz.msgs.Model" + direction: GZ_TO_ROS +- ros_topic_name: "/tf" + gz_topic_name: "/model/diff_drive/pose" + ros_type_name: "tf2_msgs/msg/TFMessage" + gz_type_name: "gz.msgs.Pose_V" + direction: GZ_TO_ROS +- ros_topic_name: "/tf_static" + gz_topic_name: "/model/diff_drive/pose_static" + ros_type_name: "tf2_msgs/msg/TFMessage" + gz_type_name: "gz.msgs.Pose_V" + direction: GZ_TO_ROS + diff --git a/ardupilot_gz_bringup/config/iris.rviz b/ardupilot_gz_bringup/config/iris.rviz new file mode 100644 index 0000000..cd01149 --- /dev/null +++ b/ardupilot_gz_bringup/config/iris.rviz @@ -0,0 +1,228 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /RobotModel1 + - /Odometry1 + Splitter Ratio: 0.5 + Tree Height: 510 + - Class: rviz_common/Selection + Name: Selection + - Class: rviz_common/Tool Properties + Expanded: + - /2D Goal Pose1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz_common/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz_common/Time + Experimental: false + Name: Time + SyncMode: 0 + SyncSource: "" +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz_default_plugins/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 10 + Reference Frame: + Value: true + - Alpha: 1 + Class: rviz_default_plugins/RobotModel + Collision Enabled: false + Description File: "" + Description Source: Topic + Description Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /robot_description + Enabled: true + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + base_link: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + imu_link: + Alpha: 1 + Show Axes: false + Show Trail: false + rotor_0: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + rotor_1: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + rotor_2: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + rotor_3: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Mass Properties: + Inertia: false + Mass: false + Name: RobotModel + TF Prefix: iris + Update Interval: 0 + Value: true + Visual Enabled: true + - Angle Tolerance: 0.10000000149011612 + Class: rviz_default_plugins/Odometry + Covariance: + Orientation: + Alpha: 0.5 + Color: 255; 255; 127 + Color Style: Unique + Frame: Local + Offset: 1 + Scale: 1 + Value: true + Position: + Alpha: 0.30000001192092896 + Color: 204; 51; 204 + Scale: 1 + Value: true + Value: true + Enabled: true + Keep: 100 + Name: Odometry + Position Tolerance: 0.10000000149011612 + Shape: + Alpha: 1 + Axes Length: 1 + Axes Radius: 0.10000000149011612 + Color: 255; 25; 0 + Head Length: 0.30000001192092896 + Head Radius: 0.10000000149011612 + Shaft Length: 1 + Shaft Radius: 0.05000000074505806 + Value: Arrow + Topic: + Depth: 5 + Durability Policy: Volatile + Filter size: 10 + History Policy: Keep Last + Reliability Policy: Reliable + Value: /iris/odometry + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Fixed Frame: iris/odom + Frame Rate: 30 + Name: root + Tools: + - Class: rviz_default_plugins/Interact + Hide Inactive Objects: true + - Class: rviz_default_plugins/MoveCamera + - Class: rviz_default_plugins/Select + - Class: rviz_default_plugins/FocusCamera + - Class: rviz_default_plugins/Measure + Line color: 128; 128; 0 + - Class: rviz_default_plugins/SetInitialPose + Covariance x: 0.25 + Covariance y: 0.25 + Covariance yaw: 0.06853891909122467 + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /initialpose + - Class: rviz_default_plugins/SetGoal + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /goal_pose + - Class: rviz_default_plugins/PublishPoint + Single click: true + Topic: + Depth: 5 + Durability Policy: Volatile + History Policy: Keep Last + Reliability Policy: Reliable + Value: /clicked_point + Transformation: + Current: + Class: rviz_default_plugins/TF + Value: true + Views: + Current: + Class: rviz_default_plugins/Orbit + Distance: 2.4529836177825928 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: 0.06576357781887054 + Y: -9.287148714065552e-05 + Z: -0.10587536543607712 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.44479674100875854 + Target Frame: + Value: Orbit (rviz) + Yaw: 0.8253980875015259 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 801 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd0000000400000000000001630000029bfc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006200fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000002c0000029b000000e300fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f0000029bfc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000002c0000029b000000c600fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004af0000003efc0100000002fb0000000800540069006d00650100000000000004af0000023d00fffffffb0000000800540069006d006501000000000000045000000000000000000000034b0000029b00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1199 + X: 3 + Y: 25 diff --git a/ardupilot_gz_bringup/config/iris_bridge.yaml b/ardupilot_gz_bringup/config/iris_bridge.yaml new file mode 100644 index 0000000..39c95bf --- /dev/null +++ b/ardupilot_gz_bringup/config/iris_bridge.yaml @@ -0,0 +1,27 @@ +--- +- ros_topic_name: "/clock" + gz_topic_name: "/clock" + ros_type_name: "rosgraph_msgs/msg/Clock" + gz_type_name: "gz.msgs.Clock" + direction: GZ_TO_ROS +- ros_topic_name: "/iris/odometry" + gz_topic_name: "/model/iris/odometry" + ros_type_name: "nav_msgs/msg/Odometry" + gz_type_name: "gz.msgs.Odometry" + direction: GZ_TO_ROS +- ros_topic_name: "/joint_states" + gz_topic_name: "/world/demo/model/iris/joint_state" + ros_type_name: "sensor_msgs/msg/JointState" + gz_type_name: "gz.msgs.Model" + direction: GZ_TO_ROS +- ros_topic_name: "/tf" + gz_topic_name: "/model/iris/pose" + ros_type_name: "tf2_msgs/msg/TFMessage" + gz_type_name: "gz.msgs.Pose_V" + direction: GZ_TO_ROS +- ros_topic_name: "/tf_static" + gz_topic_name: "/model/iris/pose_static" + ros_type_name: "tf2_msgs/msg/TFMessage" + gz_type_name: "gz.msgs.Pose_V" + direction: GZ_TO_ROS + diff --git a/ardupilot_gz_bringup/launch/bringup_iris.launch.py b/ardupilot_gz_bringup/launch/bringup_iris.launch.py new file mode 100644 index 0000000..ba1f1f5 --- /dev/null +++ b/ardupilot_gz_bringup/launch/bringup_iris.launch.py @@ -0,0 +1,126 @@ +# Copyright 2023 ArduPilot.org. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +Launch an iris quadcopter with ArduPilot and MAVProxy in Gazebo and Rviz. + +ros2 launch ardupilot_dds_tests bringup_sitl_dds.launch.py +tty0:=./dev/ttyROS0 +tty1:=./dev/ttyROS1 +refs:=$(ros2 pkg prefix ardupilot_sitl) + /share/ardupilot_sitl/config/dds_xrce_profile.xml +baudrate:=115200 device:=./dev/ttyROS0 +synthetic_clock:=True +wipe:=True +model:=json +speedup:=1 +slave:=0 +instance:=0 +uartC:=uart:./dev/ttyROS1 +defaults:=$(ros2 pkg prefix ardupilot_sitl) + /share/ardupilot_sitl/config/default_params/gazebo-iris.parm, + $(ros2 pkg prefix ardupilot_sitl) + /share/ardupilot_sitl/config/default_params/dds.parm +sim_address:=127.0.0.1 +master:=tcp:127.0.0.1:5760 +sitl:=127.0.0.1:5501 +""" +import os + +from ament_index_python.packages import get_package_share_directory + +from launch import LaunchDescription +from launch.actions import IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution + +from launch_ros.substitutions import FindPackageShare + + +def generate_launch_description(): + """Generate a launch description for a iris quadcopter.""" + pkg_ardupilot_sitl = get_package_share_directory("ardupilot_sitl") + + # Include component launch files. + iris_gz = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + [ + PathJoinSubstitution( + [ + FindPackageShare("ardupilot_gz_bringup"), + "launch", + "iris.launch.py", + ] + ), + ] + ) + ) + + bringup_sitl_dds = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + [ + PathJoinSubstitution( + [ + FindPackageShare("ardupilot_dds_tests"), + "launch", + "bringup_sitl_dds.launch.py", + ] + ), + ] + ), + launch_arguments={ + "tty0": "./dev/ttyROS0", + "tty1": "./dev/ttyROS1", + "refs": PathJoinSubstitution( + [ + FindPackageShare("ardupilot_sitl"), + "config", + "dds_xrce_profile.xml", + ] + ), + "baudrate": "115200", + "device": "./dev/ttyROS0", + "synthetic_clock": "True", + "wipe": "True", + "model": "json", + "speedup": "1", + "slave": "0", + "instance": "0", + "uartC": "uart:./dev/ttyROS1", + "defaults": os.path.join( + pkg_ardupilot_sitl, + "config", + "default_params", + "gazebo-iris.parm", + ) + + "," + + os.path.join( + pkg_ardupilot_sitl, + "config", + "default_params", + "dds.parm", + ), + "sim_address": "127.0.0.1", + "master": "tcp:127.0.0.1:5760", + "sitl": "127.0.0.1:5501", + }.items(), + ) + + return LaunchDescription( + [ + iris_gz, + bringup_sitl_dds, + ] + ) diff --git a/ardupilot_gz_bringup/launch/diff_drive.launch.py b/ardupilot_gz_bringup/launch/diff_drive.launch.py new file mode 100644 index 0000000..a3dcb4b --- /dev/null +++ b/ardupilot_gz_bringup/launch/diff_drive.launch.py @@ -0,0 +1,109 @@ +# Copyright 2019 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Launch a diff-drive robot in Gazebo and Rviz.""" +import os + +from ament_index_python.packages import get_package_share_directory + +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.actions import IncludeLaunchDescription +from launch.conditions import IfCondition +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import LaunchConfiguration + +from launch_ros.actions import Node + + +def generate_launch_description(): + """Generate a launch description for a diff-drive robot.""" + pkg_project_bringup = get_package_share_directory("ardupilot_gz_bringup") + pkg_project_gazebo = get_package_share_directory("ardupilot_gz_gazebo") + pkg_project_description = get_package_share_directory("ardupilot_gz_description") + pkg_ros_gz_sim = get_package_share_directory("ros_gz_sim") + + # Load the SDF file from "description" package + sdf_file = os.path.join( + pkg_project_description, "models", "diff_drive", "model.sdf" + ) + with open(sdf_file, "r") as infp: + robot_desc = infp.read() + + gz_sim_server = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_ros_gz_sim, "launch", "gz_sim.launch.py") + ), + launch_arguments={ + "gz_args": "-v4 -s -r " + + os.path.join(pkg_project_gazebo, "worlds", "diff_drive.sdf") + }.items(), + ) + + gz_sim_gui = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_ros_gz_sim, "launch", "gz_sim.launch.py") + ), + launch_arguments={"gz_args": "-v4 -g"}.items(), + ) + + robot_state_publisher = Node( + package="robot_state_publisher", + executable="robot_state_publisher", + name="robot_state_publisher", + output="both", + parameters=[ + {"use_sim_time": True}, + {"robot_description": robot_desc}, + ], + ) + + # RViz + rviz = Node( + package="rviz2", + executable="rviz2", + arguments=[ + "-d", + os.path.join(pkg_project_bringup, "config", "diff_drive.rviz"), + ], + condition=IfCondition(LaunchConfiguration("rviz")), + ) + + # Bridge + bridge = Node( + package="ros_gz_bridge", + executable="parameter_bridge", + parameters=[ + { + "config_file": os.path.join( + pkg_project_bringup, "config", "diff_drive_bridge.yaml" + ), + "qos_overrides./tf_static.publisher.durability": "transient_local", + } + ], + output="screen", + ) + + return LaunchDescription( + [ + DeclareLaunchArgument( + "rviz", default_value="true", description="Open RViz." + ), + robot_state_publisher, + bridge, + gz_sim_server, + gz_sim_gui, + rviz, + ] + ) diff --git a/ardupilot_gz_bringup/launch/iris.launch.py b/ardupilot_gz_bringup/launch/iris.launch.py new file mode 100644 index 0000000..7a894eb --- /dev/null +++ b/ardupilot_gz_bringup/launch/iris.launch.py @@ -0,0 +1,127 @@ +# Copyright 2023 ArduPilot.org. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Adapted from https://github.com/gazebosim/ros_gz_project_template +# +# Copyright 2019 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Launch an iris quadcopter in Gazebo and Rviz.""" +import os + +from ament_index_python.packages import get_package_share_directory + +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.actions import IncludeLaunchDescription +from launch.conditions import IfCondition +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import LaunchConfiguration + +from launch_ros.actions import Node + + +def generate_launch_description(): + """Generate a launch description for a iris quadcopter.""" + pkg_project_bringup = get_package_share_directory("ardupilot_gz_bringup") + pkg_project_gazebo = get_package_share_directory("ardupilot_gz_gazebo") + # pkg_project_description = get_package_share_directory( + # 'ardupilot_gz_description') + pkg_ros_gz_sim = get_package_share_directory("ros_gz_sim") + + pkg_ardupilot_gazebo = get_package_share_directory("ardupilot_gazebo") + + # Load the SDF file from "description" package + sdf_file = os.path.join( + pkg_ardupilot_gazebo, "models", "iris_with_standoffs", "model.sdf" + ) + with open(sdf_file, "r") as infp: + robot_desc = infp.read() + # print(robot_desc) + + gz_sim_server = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_ros_gz_sim, "launch", "gz_sim.launch.py") + ), + launch_arguments={ + "gz_args": "-v4 -s -r " + + os.path.join(pkg_project_gazebo, "worlds", "iris.sdf") + }.items(), + ) + + gz_sim_gui = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_ros_gz_sim, "launch", "gz_sim.launch.py") + ), + launch_arguments={"gz_args": "-v4 -g"}.items(), + ) + + robot_state_publisher = Node( + package="robot_state_publisher", + executable="robot_state_publisher", + name="robot_state_publisher", + output="both", + parameters=[ + {"use_sim_time": True}, + {"robot_description": robot_desc}, + ], + ) + + # RViz + rviz = Node( + package="rviz2", + executable="rviz2", + arguments=["-d", os.path.join(pkg_project_bringup, "config", "iris.rviz")], + condition=IfCondition(LaunchConfiguration("rviz")), + ) + + # Bridge + bridge = Node( + package="ros_gz_bridge", + executable="parameter_bridge", + parameters=[ + { + "config_file": os.path.join( + pkg_project_bringup, "config", "iris_bridge.yaml" + ), + "qos_overrides./tf_static.publisher.durability": "transient_local", + } + ], + output="screen", + ) + + return LaunchDescription( + [ + DeclareLaunchArgument( + "rviz", default_value="true", description="Open RViz." + ), + robot_state_publisher, + bridge, + gz_sim_server, + gz_sim_gui, + rviz, + ] + ) diff --git a/ardupilot_gz_bringup/package.xml b/ardupilot_gz_bringup/package.xml new file mode 100644 index 0000000..fbce3ee --- /dev/null +++ b/ardupilot_gz_bringup/package.xml @@ -0,0 +1,25 @@ + + + + ardupilot_gz_bringup + 0.0.0 + Launch files for `ardupilot_gz`. + Rhys Mainwaring + GPL-3.0 + + ament_cmake + ament_cmake_python + + ament_index_python + launch + launch_ros + + ament_cmake_pytest + ament_lint_auto + ament_lint_common + + + ament_cmake + + + diff --git a/ardupilot_gz_description/.flake8 b/ardupilot_gz_description/.flake8 new file mode 100644 index 0000000..b79f25f --- /dev/null +++ b/ardupilot_gz_description/.flake8 @@ -0,0 +1,10 @@ +[flake8] +# Match black line length (default 88). +max-line-length = 88 +# Match black configuration where there are conflicts. +extend-ignore = + # Q000: Double quotes found but single quotes preferred + Q000, + # W503: Line break before binary operator + W503 + diff --git a/ardupilot_gz_description/CMakeLists.txt b/ardupilot_gz_description/CMakeLists.txt new file mode 100644 index 0000000..140037f --- /dev/null +++ b/ardupilot_gz_description/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.5) +project(ardupilot_gz_description) + +# --------------------------------------------------------------------------- # +# Find dependencies. +find_package(ament_cmake REQUIRED) + +# --------------------------------------------------------------------------- # +# Install. + +install( + DIRECTORY + models/ + DESTINATION share/${PROJECT_NAME}/models +) + +# --------------------------------------------------------------------------- # +# Build tests. + +if(BUILD_TESTING) + # Override default flake8 configuration. + set(ament_cmake_flake8_CONFIG_FILE ${CMAKE_SOURCE_DIR}/.flake8) + + # Add linters. + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +# --------------------------------------------------------------------------- # +# Environment hooks. + +ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in") +ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.sh.in") + +# --------------------------------------------------------------------------- # +# Call last. + +ament_package() diff --git a/ardupilot_gz_description/hooks/ardupilot_gz_description.dsv.in b/ardupilot_gz_description/hooks/ardupilot_gz_description.dsv.in new file mode 100644 index 0000000..e798b99 --- /dev/null +++ b/ardupilot_gz_description/hooks/ardupilot_gz_description.dsv.in @@ -0,0 +1 @@ +prepend-non-duplicate;GZ_SIM_RESOURCE_PATH;share;@CMAKE_INSTALL_PREFIX@/share diff --git a/ardupilot_gz_description/hooks/ardupilot_gz_description.sh.in b/ardupilot_gz_description/hooks/ardupilot_gz_description.sh.in new file mode 100644 index 0000000..65671ff --- /dev/null +++ b/ardupilot_gz_description/hooks/ardupilot_gz_description.sh.in @@ -0,0 +1,2 @@ +ament_prepend_unique_value GZ_SIM_RESOURCE_PATH "$AMENT_CURRENT_PREFIX/share/@PROJECT_NAME@/models" + diff --git a/ardupilot_gz_description/models/diff_drive/model.config b/ardupilot_gz_description/models/diff_drive/model.config new file mode 100644 index 0000000..ad60097 --- /dev/null +++ b/ardupilot_gz_description/models/diff_drive/model.config @@ -0,0 +1,15 @@ + + + diff_drive + 1.0 + model.sdf + + + Dharini Dutia + dharini@openrobotics.org + + + + Example differential drive vehicle model. + + \ No newline at end of file diff --git a/ardupilot_gz_description/models/diff_drive/model.sdf b/ardupilot_gz_description/models/diff_drive/model.sdf new file mode 100644 index 0000000..d432336 --- /dev/null +++ b/ardupilot_gz_description/models/diff_drive/model.sdf @@ -0,0 +1,245 @@ + + + + + -0.151427 -0 0.175 0 -0 0 + + 1.14395 + + 0.126164 + 0 + 0 + 0.416519 + 0 + 0.481014 + + + + + + 2.01142 1 0.568726 + + + + 0.5 0.5 1.0 1 + 0.5 0.5 1.0 1 + 0.0 0.0 1.0 1 + + + + + + 2.01142 1 0.568726 + + + + + + + 0.554283 0.625029 -0.025 -1.5707 0 0 + + 2 + + 0.145833 + 0 + 0 + 0.145833 + 0 + 0.125 + + + + + + 0.3 + + + + 0.2 0.2 0.2 1 + 0.2 0.2 0.2 1 + 0.2 0.2 0.2 1 + + + + + + 0.3 + + + + + + + 0.554282 -0.625029 -0.025 -1.5707 0 0 + + 2 + + 0.145833 + 0 + 0 + 0.145833 + 0 + 0.125 + + + + + + 0.3 + + + + 0.2 0.2 0.2 1 + 0.2 0.2 0.2 1 + 0.2 0.2 0.2 1 + + + + + + 0.3 + + + + + + + -0.957138 -0 -0.125 0 -0 0 + + 1 + + 0.1 + 0 + 0 + 0.1 + 0 + 0.1 + + + + + + 0.2 + + + + 0.2 0.2 0.2 1 + 0.2 0.2 0.2 1 + 0.2 0.2 0.2 1 + + + + + + 0.2 + + + + + + + 0 0 0.5 0 0 0 + + 0.1 + + 0.000166667 + 0.000166667 + 0.000166667 + + + + + + 0.1 0.1 0.1 + + + + + + + 0.1 0.1 0.1 + + + + + 0 0 0 0 0 0 + scan + 10 + + + + 640 + 1 + -1.396263 + 1.396263 + + + 1 + 1 + 0.0 + 0.0 + + + + 0.08 + 10.0 + 0.01 + + + true + + + + + chassis + lidar_link + + + + chassis + left_wheel + + 0 0 1 + + -1.79769e+308 + 1.79769e+308 + + + + + + chassis + right_wheel + + 0 0 1 + + -1.79769e+308 + 1.79769e+308 + + + + + + chassis + caster + + + + left_wheel_joint + right_wheel_joint + 1.25 + 0.3 + 1 + 1 + -1 + 2 + -2 + 0.5 + -0.5 + 1 + -1 + + + diff --git a/ardupilot_gz_description/package.xml b/ardupilot_gz_description/package.xml new file mode 100644 index 0000000..0b02493 --- /dev/null +++ b/ardupilot_gz_description/package.xml @@ -0,0 +1,19 @@ + + + + ardupilot_gz_description + 0.0.0 + Model descriptions for `ardupilot_gz`. + Rhys Mainwaring + GPL-3.0 + + ament_cmake + + ament_lint_auto + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/ardupilot_gz_gazebo/.flake8 b/ardupilot_gz_gazebo/.flake8 new file mode 100644 index 0000000..b79f25f --- /dev/null +++ b/ardupilot_gz_gazebo/.flake8 @@ -0,0 +1,10 @@ +[flake8] +# Match black line length (default 88). +max-line-length = 88 +# Match black configuration where there are conflicts. +extend-ignore = + # Q000: Double quotes found but single quotes preferred + Q000, + # W503: Line break before binary operator + W503 + diff --git a/ardupilot_gz_gazebo/CMakeLists.txt b/ardupilot_gz_gazebo/CMakeLists.txt new file mode 100644 index 0000000..7b420dd --- /dev/null +++ b/ardupilot_gz_gazebo/CMakeLists.txt @@ -0,0 +1,80 @@ +cmake_minimum_required(VERSION 3.5) +project(ardupilot_gz_gazebo) + +# --------------------------------------------------------------------------- # +# Find dependencies. +find_package(ament_cmake REQUIRED) + +find_package(gz-cmake3 REQUIRED) + +find_package(gz-plugin2 REQUIRED COMPONENTS register) +set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR}) + +find_package(gz-common5 REQUIRED COMPONENTS profiler) +set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR}) + +find_package(gz-sim7 REQUIRED) +set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR}) + +# --------------------------------------------------------------------------- # +# Build. + +add_library(BasicSystem + SHARED + src/BasicSystem.cc +) + +target_include_directories( + BasicSystem PRIVATE include +) + +target_link_libraries(BasicSystem PRIVATE + gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}) + +add_library(FullSystem + SHARED + src/FullSystem.cc +) + +target_include_directories( + FullSystem PRIVATE include +) + +target_link_libraries(FullSystem PRIVATE + gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}) + +# --------------------------------------------------------------------------- # +# Install. + +install( + TARGETS BasicSystem FullSystem + DESTINATION lib/${PROJECT_NAME} +) + +install( + DIRECTORY worlds/ + DESTINATION share/${PROJECT_NAME}/worlds +) + +# --------------------------------------------------------------------------- # +# Build tests. + +if(BUILD_TESTING) + # Override default flake8 configuration. + set(ament_cmake_flake8_CONFIG_FILE ${CMAKE_SOURCE_DIR}/.flake8) + + # Add linters. + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +# --------------------------------------------------------------------------- # +# Environment hooks. + +ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in") +ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.sh.in") + +# --------------------------------------------------------------------------- # +# Call last. + +ament_package() diff --git a/ardupilot_gz_gazebo/hooks/ardupilot_gz_gazebo.dsv.in b/ardupilot_gz_gazebo/hooks/ardupilot_gz_gazebo.dsv.in new file mode 100644 index 0000000..20259a8 --- /dev/null +++ b/ardupilot_gz_gazebo/hooks/ardupilot_gz_gazebo.dsv.in @@ -0,0 +1,2 @@ +prepend-non-duplicate;GZ_SIM_RESOURCE_PATH;share/@PROJECT_NAME@/worlds +prepend-non-duplicate;GZ_SIM_SYSTEM_PLUGIN_PATH;lib/@PROJECT_NAME@/ diff --git a/ardupilot_gz_gazebo/hooks/ardupilot_gz_gazebo.sh.in b/ardupilot_gz_gazebo/hooks/ardupilot_gz_gazebo.sh.in new file mode 100644 index 0000000..28e9c54 --- /dev/null +++ b/ardupilot_gz_gazebo/hooks/ardupilot_gz_gazebo.sh.in @@ -0,0 +1,2 @@ +ament_prepend_unique_value GZ_SIM_RESOURCE_PATH "$AMENT_CURRENT_PREFIX/share/@PROJECT_NAME@/worlds" +ament_prepend_unique_value GZ_SIM_PLUGIn_PATH "$AMENT_CURRENT_PREFIX/lib/@PROJECT_NAME@" diff --git a/ardupilot_gz_gazebo/include/ardupilot_gz_gazebo/BasicSystem.hh b/ardupilot_gz_gazebo/include/ardupilot_gz_gazebo/BasicSystem.hh new file mode 100644 index 0000000..52fe298 --- /dev/null +++ b/ardupilot_gz_gazebo/include/ardupilot_gz_gazebo/BasicSystem.hh @@ -0,0 +1,42 @@ +// Copyright 2022 Open Source Robotics Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ARDUPILOT_GZ_GAZEBO__BASICSYSTEM_HH_ +#define ARDUPILOT_GZ_GAZEBO__BASICSYSTEM_HH_ + +// The only required include in the header is this one. +// All others will depend on what your plugin does. +#include + +namespace ardupilot_gz_gazebo +{ +// This is the main plugin's class. It must inherit from System and at least +// one other interface. +// Here we use `ISystemPostUpdate`, which is used to get results after +// physics runs. The opposite of that, `ISystemPreUpdate`, would be used by +// plugins that want to send commands. +class BasicSystem: + public gz::sim::System, + public gz::sim::ISystemPostUpdate +{ + // Plugins inheriting ISystemPostUpdate must implement the PostUpdate + // callback. This is called at every simulation iteration after the physics + // updates the world. The _info variable provides information such as time, + // while the _ecm provides an interface to all entities and components in + // simulation. + public: void PostUpdate(const gz::sim::UpdateInfo &_info, + const gz::sim::EntityComponentManager &_ecm) override; +}; +} // namespace ardupilot_gz_gazebo +#endif // ARDUPILOT_GZ_GAZEBO__BASICSYSTEM_HH_ diff --git a/ardupilot_gz_gazebo/include/ardupilot_gz_gazebo/FullSystem.hh b/ardupilot_gz_gazebo/include/ardupilot_gz_gazebo/FullSystem.hh new file mode 100644 index 0000000..12ea00f --- /dev/null +++ b/ardupilot_gz_gazebo/include/ardupilot_gz_gazebo/FullSystem.hh @@ -0,0 +1,79 @@ +// Copyright 2022 Open Source Robotics Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ARDUPILOT_GZ_GAZEBO__FULLSYSTEM_HH_ +#define ARDUPILOT_GZ_GAZEBO__FULLSYSTEM_HH_ + +#include +#include +#include + +namespace ardupilot_gz_gazebo +{ +// This is the main plugin's class. It must inherit from System and at least +// one other interface. +// Here we use `ISystemPostUpdate`, which is used to get results after +// physics runs. The opposite of that, `ISystemPreUpdate`, would be used by +// plugins that want to send commands. +class FullSystem: + public gz::sim::System, + public gz::sim::ISystemConfigure, + public gz::sim::ISystemPreUpdate, + public gz::sim::ISystemUpdate, + public gz::sim::ISystemPostUpdate, + public gz::sim::ISystemReset +{ + // Plugins inheriting ISystemConfigure must implement the Configure + // callback. This is called when a system is initially loaded. + // The _entity variable contains the entity that the system is attached to + // The _element variable contains the sdf Element with custom configuration + // The _ecm provides an interface to all entities and components + // The _eventManager provides a mechanism for registering internal signals + public: void Configure( + const gz::sim::Entity &_entity, + const std::shared_ptr &_element, + gz::sim::EntityComponentManager &_ecm, + gz::sim::EventManager &_eventManager) override; + + // Plugins inheriting ISystemPreUpdate must implement the PreUpdate + // callback. This is called at every simulation iteration before the physics + // updates the world. The _info variable provides information such as time, + // while the _ecm provides an interface to all entities and components in + // simulation. + public: void PreUpdate(const gz::sim::UpdateInfo &_info, + gz::sim::EntityComponentManager &_ecm) override; + + // Plugins inheriting ISystemUpdate must implement the Update + // callback. This is called at every simulation iteration before the physics + // updates the world. The _info variable provides information such as time, + // while the _ecm provides an interface to all entities and components in + // simulation. + public: void Update(const gz::sim::UpdateInfo &_info, + gz::sim::EntityComponentManager &_ecm) override; + + // Plugins inheriting ISystemPostUpdate must implement the PostUpdate + // callback. This is called at every simulation iteration after the physics + // updates the world. The _info variable provides information such as time, + // while the _ecm provides an interface to all entities and components in + // simulation. + public: void PostUpdate(const gz::sim::UpdateInfo &_info, + const gz::sim::EntityComponentManager &_ecm) override; + + // Plugins inheriting ISystemReset must implement the Reset callback. + // This is called when simulation is reset/rewound to initial conditions. + public: void Reset(const gz::sim::UpdateInfo &_info, + gz::sim::EntityComponentManager &_ecm) override; +}; +} // namespace ardupilot_gz_gazebo +#endif // ARDUPILOT_GZ_GAZEBO__FULLSYSTEM_HH_ diff --git a/ardupilot_gz_gazebo/package.xml b/ardupilot_gz_gazebo/package.xml new file mode 100644 index 0000000..3f7c97d --- /dev/null +++ b/ardupilot_gz_gazebo/package.xml @@ -0,0 +1,32 @@ + + + + ardupilot_gz_gazebo + 0.0.0 + Gazebo specific systems for `ardupilot_gz`. + Rhys Mainwaring + GPL-3.0 + + ament_cmake + + ament_lint_auto + + + + ament_cmake_copyright + ament_cmake_cppcheck + ament_cmake_cpplint + ament_cmake_flake8 + ament_cmake_lint_cmake + ament_cmake_mypy + ament_cmake_pclint + ament_cmake_pep257 + ament_cmake_pycodestyle + + ament_cmake_xmllint + + + ament_cmake + + + diff --git a/ardupilot_gz_gazebo/src/BasicSystem.cc b/ardupilot_gz_gazebo/src/BasicSystem.cc new file mode 100644 index 0000000..5197ce4 --- /dev/null +++ b/ardupilot_gz_gazebo/src/BasicSystem.cc @@ -0,0 +1,46 @@ +// Copyright 2022 Open Source Robotics Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// We'll use a string and the gzmsg command below for a brief example. +// Remove these includes if your plugin doesn't need them. +#include +#include + +// This header is required to register plugins. It's good practice to place it +// in the cc file, like it's done here. +#include + +// Don't forget to include the plugin's header. +#include "ardupilot_gz_gazebo/BasicSystem.hh" + +// This is required to register the plugin. Make sure the interfaces match +// what's in the header. +GZ_ADD_PLUGIN( + ardupilot_gz_gazebo::BasicSystem, + gz::sim::System, + ardupilot_gz_gazebo::BasicSystem::ISystemPostUpdate) + +namespace ardupilot_gz_gazebo +{ + +void BasicSystem::PostUpdate(const gz::sim::UpdateInfo &_info, + const gz::sim::EntityComponentManager &_ecm) +{ + if (!_info.paused && _info.iterations % 1000 == 0) + { + gzdbg << "ardupilot_gz_gazebo::BasicSystem::PostUpdate" << std::endl; + } +} + +} // namespace ardupilot_gz_gazebo diff --git a/ardupilot_gz_gazebo/src/FullSystem.cc b/ardupilot_gz_gazebo/src/FullSystem.cc new file mode 100644 index 0000000..b9a073f --- /dev/null +++ b/ardupilot_gz_gazebo/src/FullSystem.cc @@ -0,0 +1,82 @@ +// Copyright 2022 Open Source Robotics Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// We'll use a string and the gzmsg command below for a brief example. +// Remove these includes if your plugin doesn't need them. +#include +#include + +// This header is required to register plugins. It's good practice to place it +// in the cc file, like it's done here. +#include + +// Don't forget to include the plugin's header. +#include "ardupilot_gz_gazebo/FullSystem.hh" + +// This is required to register the plugin. Make sure the interfaces match +// what's in the header. +GZ_ADD_PLUGIN( + ardupilot_gz_gazebo::FullSystem, + gz::sim::System, + ardupilot_gz_gazebo::FullSystem::ISystemConfigure, + ardupilot_gz_gazebo::FullSystem::ISystemPreUpdate, + ardupilot_gz_gazebo::FullSystem::ISystemUpdate, + ardupilot_gz_gazebo::FullSystem::ISystemPostUpdate, + ardupilot_gz_gazebo::FullSystem::ISystemReset +) + +namespace ardupilot_gz_gazebo +{ + +void FullSystem::Configure(const gz::sim::Entity &_entity, + const std::shared_ptr &_element, + gz::sim::EntityComponentManager &_ecm, + gz::sim::EventManager &_eventManager) +{ + gzdbg << "ardupilot_gz_gazebo::FullSystem::Configure on entity: " << _entity << std::endl; +} + +void FullSystem::PreUpdate(const gz::sim::UpdateInfo &_info, + gz::sim::EntityComponentManager &_ecm) +{ + if (!_info.paused && _info.iterations % 1000 == 0) + { + gzdbg << "ardupilot_gz_gazebo::FullSystem::PreUpdate" << std::endl; + } +} + +void FullSystem::Update(const gz::sim::UpdateInfo &_info, + gz::sim::EntityComponentManager &_ecm) +{ + if (!_info.paused && _info.iterations % 1000 == 0) + { + gzdbg << "ardupilot_gz_gazebo::FullSystem::Update" << std::endl; + } +} + +void FullSystem::PostUpdate(const gz::sim::UpdateInfo &_info, + const gz::sim::EntityComponentManager &_ecm) +{ + if (!_info.paused && _info.iterations % 1000 == 0) + { + gzdbg << "ardupilot_gz_gazebo::FullSystem::PostUpdate" << std::endl; + } +} + +void FullSystem::Reset(const gz::sim::UpdateInfo &_info, + gz::sim::EntityComponentManager &_ecm) +{ + gzdbg << "ardupilot_gz_gazebo::FullSystem::Reset" << std::endl; +} +} // namespace ardupilot_gz_gazebo diff --git a/ardupilot_gz_gazebo/worlds/diff_drive.sdf b/ardupilot_gz_gazebo/worlds/diff_drive.sdf new file mode 100644 index 0000000..39e9b0d --- /dev/null +++ b/ardupilot_gz_gazebo/worlds/diff_drive.sdf @@ -0,0 +1,109 @@ + + + + + + + + ogre2 + + + + + + + + + + + + true + 0 0 10 0 0 0 + 0.8 0.8 0.8 1 + 0.2 0.2 0.2 1 + + 1000 + 0.9 + 0.01 + 0.001 + + -0.5 0.1 -0.9 + + + + true + + + + + 0 0 1 + 100 100 + + + + + + + 0 0 1 + 100 100 + + + + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + + + + + + + true + 0 0 0.35 0 0 0 + + package://ardupilot_gz_description/models/diff_drive + + + + + + + true + true + true + 1 + + + + diff_drive/odom + diff_drive + + + + + diff --git a/ardupilot_gz_gazebo/worlds/iris.sdf b/ardupilot_gz_gazebo/worlds/iris.sdf new file mode 100755 index 0000000..602c195 --- /dev/null +++ b/ardupilot_gz_gazebo/worlds/iris.sdf @@ -0,0 +1,325 @@ + + + + + 0.001 + 1.0 + + + + + + ogre2 + + + + + + + + + + 1.0 1.0 1.0 + 0.8 0.8 0.8 + + + + + true + 0 0 10 0 0 0 + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + + 1000 + 0.9 + 0.01 + 0.001 + + -0.5 0.1 -0.9 + + + + model://runway + + + + 0 0 0.194923 0 0 0 + + package://ardupilot_gazebo/models/iris_with_standoffs + iris + + + + + + + true + true + true + 1 + + + + iris/odom + iris + + + + 0.3 + 1.4 + 4.2500 + 0.10 + 0.00 + -0.025 + 0.0 + 0.0 + 0.002 + 1.2041 + 0.084 0 0 + 0 1 0 + 0 0 1 + rotor_0 + + + 0.3 + 1.4 + 4.2500 + 0.10 + 0.00 + -0.025 + 0.0 + 0.0 + 0.002 + 1.2041 + -0.084 0 0 + 0 -1 0 + 0 0 1 + rotor_0 + + + + 0.3 + 1.4 + 4.2500 + 0.10 + 0.00 + -0.025 + 0.0 + 0.0 + 0.002 + 1.2041 + 0.084 0 0 + 0 1 0 + 0 0 1 + rotor_1 + + + 0.3 + 1.4 + 4.2500 + 0.10 + 0.00 + -0.025 + 0.0 + 0.0 + 0.002 + 1.2041 + -0.084 0 0 + 0 -1 0 + 0 0 1 + rotor_1 + + + + 0.3 + 1.4 + 4.2500 + 0.10 + 0.00 + -0.025 + 0.0 + 0.0 + 0.002 + 1.2041 + 0.084 0 0 + 0 -1 0 + 0 0 1 + rotor_2 + + + 0.3 + 1.4 + 4.2500 + 0.10 + 0.00 + -0.025 + 0.0 + 0.0 + 0.002 + 1.2041 + -0.084 0 0 + 0 1 0 + 0 0 1 + rotor_2 + + + + 0.3 + 1.4 + 4.2500 + 0.10 + 0.00 + -0.025 + 0.0 + 0.0 + 0.002 + 1.2041 + 0.084 0 0 + 0 -1 0 + 0 0 1 + rotor_3 + + + 0.3 + 1.4 + 4.2500 + 0.10 + 0.00 + -0.025 + 0.0 + 0.0 + 0.002 + 1.2041 + -0.084 0 0 + 0 1 0 + 0 0 1 + rotor_3 + + + + rotor_0_joint + + + rotor_1_joint + + + rotor_2_joint + + + rotor_3_joint + + + + 127.0.0.1 + 9002 + 5 + 1 + 0 + + 0 0 0 3.141593 0 0 + 0 0 0 3.141593 0 0 + + imu_link::imu_sensor + + + rotor_0_joint + 1 + 838 + 0 + 1100 + 1900 + VELOCITY + 0.20 + 0 + 0 + 0 + 0 + 2.5 + -2.5 + 1 + + + + rotor_1_joint + 1 + 838 + 0 + 1100 + 1900 + VELOCITY + 0.20 + 0 + 0 + 0 + 0 + 2.5 + -2.5 + 1 + + + + rotor_2_joint + 1 + -838 + 0 + 1100 + 1900 + VELOCITY + 0.20 + 0 + 0 + 0 + 0 + 2.5 + -2.5 + 1 + + + + rotor_3_joint + 1 + -838 + 0 + 1100 + 1900 + VELOCITY + 0.20 + 0 + 0 + 0 + 0 + 2.5 + -2.5 + 1 + + + + + + +