Skip to content

Commit

Permalink
Example ros_gz package in support of presentation (#1)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <michael@openrobotics.org>
Signed-off-by: Dharini Dutia <dharini@openrobotics.org>
Co-authored-by: Michael Carroll <michael@openrobotics.org>
  • Loading branch information
quarkytale and mjcarroll committed Oct 19, 2022
1 parent f05f87a commit d0528fd
Show file tree
Hide file tree
Showing 22 changed files with 1,153 additions and 0 deletions.
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,78 @@
# ros_gz_project_template
A template project integrating ROS and Gazebo simulator

## Included packages

* `ros_gz_example_description` - holds the sdf description of the simulated system and any other assets

* `ros_gz_example_gazebo` - holds gazebo specific code and configurations. Namely this is where systems end up.

* `ros_gz_example_application` - holds ros2 specific code and configurations

* `ros_gz_example_bringup` - holds launch files and high level utilities


## Install
### Use as template
Directly `Use this template` and create your project repository on github.

### On Host System
##### Requirements
On Ubuntu Jammy

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 ~/template_ws/src
cd ~/template_ws/src
```
1. Clone the template:
```
git clone
wget https://raw.githubusercontent.com/gazebosim/ros_gz_project_template/main/template_workspace.yaml
vcs import < template_workspace.yaml
cd ~/template_ws
```
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 ~/template_ws
colcon build --cmake-args -DBUILD_TESTING=ON
```
##### Run
1. Source the workspace
`. ~/template_ws/install/setup.sh`
1. Launch the simulation
`ros2 launch ros_gz_example_bringup example.launch.py`
34 changes: 34 additions & 0 deletions ros_gz_example_bringup/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cmake_minimum_required(VERSION 3.5)

project(ros_gz_example_bringup)

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})

# Install project launch files
install(
DIRECTORY
launch/
DESTINATION share/${PROJECT_NAME}/launch
)

# Install project configuration files
install(
DIRECTORY
config/
DESTINATION share/${PROJECT_NAME}/config
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
17 changes: 17 additions & 0 deletions ros_gz_example_bringup/config/ros_gz_example_bridge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- 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: "/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

70 changes: 70 additions & 0 deletions ros_gz_example_bringup/launch/diff_drive.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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.

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, PathJoinSubstitution

from launch_ros.actions import Node


def generate_launch_description():
pkg_project_bringup = get_package_share_directory('ros_gz_example_bringup')
pkg_project_gazebo = get_package_share_directory('ros_gz_example_gazebo')

pkg_ros_gz_sim = get_package_share_directory('ros_gz_sim')

gz_sim = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_ros_gz_sim, 'launch', 'gz_sim.launch.py')),
launch_arguments={'gz_args': PathJoinSubstitution([
pkg_project_gazebo,
'worlds',
'diff_drive.sdf'
])}.items(),
)

# RViz
rviz = Node(
package='rviz2',
executable='rviz2',
arguments=['-d', os.path.join(pkg_project_bringup, 'rviz', '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', 'ros_gz_example_bridge.yaml'),
'qos_overrides./model/diff_drive.subscriber.reliability': 'reliable',
}],
output='screen'
)

return LaunchDescription([
gz_sim,
DeclareLaunchArgument('rviz', default_value='true',
description='Open RViz.'),
bridge,
rviz
])
20 changes: 20 additions & 0 deletions ros_gz_example_bringup/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ros_gz_example_bringup</name>
<version>0.0.0</version>
<description>Contains launch files for the ros_gz_example project</description>
<maintainer email="michael@openrobotics.org">Michael Carroll</maintainer>
<license>Apache 2.0</license>
<author>Michael Carroll</author>
<author>Dharini Dutia</author>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>

169 changes: 169 additions & 0 deletions ros_gz_example_bringup/rviz/diff_drive.rviz
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
Panels:
- Class: rviz_common/Displays
Help Height: 78
Name: Displays
Property Tree Widget:
Expanded:
- /Global Options1
- /Status1
- /LaserScan1
- /LaserScan1/Status1
Splitter Ratio: 0.5
Tree Height: 1079
- 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: <Fixed Frame>
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: 0
Min Color: 0; 0; 0
Min Intensity: 0
Name: LaserScan
Position Transformer: XYZ
Selectable: true
Size (Pixels): 3
Size (m): 0.009999999776482582
Style: Points
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/lidar_link/gpu_lidar
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: 43.2213249206543
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: -0.38051652908325195
Y: -1.564827799797058
Z: 1.3577169179916382
Focal Shape Fixed Size: true
Focal Shape Size: 0.05000000074505806
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.009999999776482582
Pitch: 0.6403982639312744
Target Frame: <Fixed Frame>
Value: Orbit (rviz)
Yaw: 2.4303994178771973
Saved: ~
Window Geometry:
Displays:
collapsed: false
Height: 1376
Hide Left Dock: false
Hide Right Dock: false
QMainWindow State: 000000ff00000000fd000000040000000000000239000004c2fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d000004c2000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000004c2fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d000004c2000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e1000001970000000300000a000000003efc0100000002fb0000000800540069006d0065010000000000000a00000002fb00fffffffb0000000800540069006d00650100000000000004500000000000000000000006ac000004c200000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: false
Width: 2560
X: 1440
Y: 1147
Loading

0 comments on commit d0528fd

Please sign in to comment.