Skip to content

Commit

Permalink
sdformat_urdf parser demo (#265)
Browse files Browse the repository at this point in the history
* parser compatible model and launch framework

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

* added ground plane, common gz plugins, demo commands and cleaned install paths

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

* unique collision names and cleared flake

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

* updating model config

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

* building parser from source

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

* fix flake and update deb dependency for garden

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

* Move packages and files to gz

Signed-off-by: methylDragon <methylDragon@gmail.com>

* feedback and ign->gz

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

* Support ros_ign migration

Clean up shared libraries, and tick-tock RosGzPointCloud
Tick-tock launch args
Hard-tock ign_ in sources
Migrate ign, ign_, IGN_ for sources, launch, and test files
Migrate IGN_XXX_VER, IGN_T, header guards
Migrate launchfile, launchfile args, and test source references
Migrate ros_ign_XXX and gz_gazebo -> gz_sim
Migrate ros_ign_XXX project names
Migrate Ign, ign-, IGN_DEPS, ign-gazebo
Migrate ignitionrobotics, ignitionrobotics/ros_ign, osrf/ros_ign
Migrate ignition-version, IGNITION_VERSION, Ignition <LIB>, ros_ign_ci

Signed-off-by: methylDragon <methylDragon@gmail.com>

* renaming and flake

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

* added ros commands

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

* gz-version

Signed-off-by: Louise Poubel <louise@openrobotics.org>

* feedback and ci trial

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

* removing garden condition

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>

Signed-off-by: Dharini Dutia <dharini@openrobotics.org>
Signed-off-by: Michael Carroll <michael@openrobotics.org>
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: Louise Poubel <louise@openrobotics.org>
Co-authored-by: Michael Carroll <michael@openrobotics.org>
Co-authored-by: methylDragon <methylDragon@gmail.com>
Co-authored-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
4 people committed Sep 22, 2022
1 parent f3fe69e commit 5d99c01
Show file tree
Hide file tree
Showing 10 changed files with 570 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ if [ "$GZ_VERSION" == "garden" ]; then
wget https://packages.osrfoundation.org/gazebo.key -O - | apt-key add -

GZ_DEPS="libgz-sim7-dev"

ROSDEP_ARGS="--skip-keys='sdformat-urdf'"
fi

# Fortress comes through rosdep for Focal and Jammy
Expand All @@ -31,7 +33,7 @@ apt-get install -y $GZ_DEPS \

rosdep init
rosdep update
rosdep install --from-paths ./ -i -y -r --rosdistro $ROS_DISTRO
rosdep install --from-paths ./ -i -y -r --rosdistro $ROS_DISTRO $ROSDEP_ARGS

# Build.
source /opt/ros/$ROS_DISTRO/setup.bash
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ros2-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ jobs:
DOCKER_IMAGE: ${{ matrix.docker-image }}
GZ_VERSION: ${{ matrix.gz-version }}
ROS_DISTRO: ${{ matrix.ros-distro }}
- name: Build sdformat_urdf from source
uses: actions/checkout@v2
if: ${{ matrix.gz-version }} == "garden"
with:
repository: ros/sdformat_urdf
ref: ros2
8 changes: 8 additions & 0 deletions ros_gz_sim_demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ install(
DESTINATION share/${PROJECT_NAME}/models
)

install(
DIRECTORY
worlds/
DESTINATION share/${PROJECT_NAME}/worlds
)

ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in")

ament_package()
1 change: 1 addition & 0 deletions ros_gz_sim_demos/hooks/ros_gz_sim_demos.dsv.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prepend-non-duplicate;IGN_GAZEBO_RESOURCE_PATH;@CMAKE_INSTALL_PREFIX@/share
109 changes: 109 additions & 0 deletions ros_gz_sim_demos/launch/sdf_parser.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Copyright 2022 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, 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_ros_gz_sim_demos = get_package_share_directory('ros_gz_sim_demos')
pkg_ros_gz_sim = get_package_share_directory('ros_gz_sim')

sdf_file = os.path.join(pkg_ros_gz_sim_demos, 'models', 'vehicle', 'model.sdf')

with open(sdf_file, 'r') as infp:
robot_desc = infp.read()

rviz_launch_arg = DeclareLaunchArgument(
'rviz', default_value='true',
description='Open RViz.'
)

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

# Bridge to forward tf and joint states to ros2
gz_topic = '/model/vehicle'
joint_state_gz_topic = '/world/demo' + gz_topic + '/joint_state'
link_pose_gz_topic = gz_topic + '/pose'
bridge = Node(
package='ros_gz_bridge',
executable='parameter_bridge',
arguments=[
# Clock (Gazebo -> ROS2)
'/clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock',
# Joint states (Gazebo -> ROS2)
joint_state_gz_topic + '@sensor_msgs/msg/JointState[ignition.msgs.Model',
# Link poses (Gazebo -> ROS2)
link_pose_gz_topic + '@tf2_msgs/msg/TFMessage[ignition.msgs.Pose_V',
link_pose_gz_topic + '_static@tf2_msgs/msg/TFMessage[ignition.msgs.Pose_V',
# Velocity and odometry (Gazebo -> ROS2)
gz_topic + '/cmd_vel@geometry_msgs/msg/Twist@ignition.msgs.Twist',
gz_topic + '/odometry@nav_msgs/msg/Odometry@ignition.msgs.Odometry',
],
remappings=[
(joint_state_gz_topic, 'joint_states'),
(link_pose_gz_topic, '/tf'),
(link_pose_gz_topic + '_static', '/tf_static'),
],
parameters=[{'qos_overrides./tf_static.publisher.durability': 'transient_local'}],
output='screen'
)

# Get the parser plugin convert sdf to urdf using robot_description topic
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},
]
)

# Launch rviz
rviz = Node(
package='rviz2',
executable='rviz2',
arguments=['-d', os.path.join(pkg_ros_gz_sim_demos, 'rviz', 'vehicle.rviz')],
condition=IfCondition(LaunchConfiguration('rviz')),
parameters=[
{'use_sim_time': True},
]
)

return LaunchDescription([
rviz_launch_arg,
gazebo,
bridge,
robot_state_publisher,
rviz
])
16 changes: 16 additions & 0 deletions ros_gz_sim_demos/models/vehicle/model.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<model>
<name>vehicle</name>
<version>1.0</version>
<sdf version="1.8">model.sdf</sdf>

<author>
<name>Dharini Dutia</name>
<email>dharini@openrobotics.org</email>
</author>

<description>
Parser plugin `sdformat_urdf` compatible differential drive vehicle model. Used to read
models described in SDFormat and outputs URDF C++ DOM structures.
</description>
</model>
188 changes: 188 additions & 0 deletions ros_gz_sim_demos/models/vehicle/model.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?xml version="1.0" ?>
<sdf version="1.8">
<model name='vehicle'>
<link name='chassis'>
<pose>-0.151427 -0 0.175 0 -0 0</pose>
<inertial>
<mass>1.14395</mass>
<inertia>
<ixx>0.126164</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.416519</iyy>
<iyz>0</iyz>
<izz>0.481014</izz>
</inertia>
</inertial>
<visual name='visual_chassis'>
<geometry>
<box>
<size>2.01142 1 0.568726</size>
</box>
</geometry>
<material>
<ambient>0.5 0.5 1.0 1</ambient>
<diffuse>0.5 0.5 1.0 1</diffuse>
<specular>0.0 0.0 1.0 1</specular>
</material>
</visual>
<collision name='collision_chassis'>
<geometry>
<box>
<size>2.01142 1 0.568726</size>
</box>
</geometry>
</collision>
</link>

<link name='left_wheel'>
<pose>0.554283 0.625029 -0.025 -1.5707 0 0</pose>
<inertial>
<mass>2</mass>
<inertia>
<ixx>0.145833</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.145833</iyy>
<iyz>0</iyz>
<izz>0.125</izz>
</inertia>
</inertial>
<visual name='visual_left_wheel'>
<geometry>
<sphere>
<radius>0.3</radius>
</sphere>
</geometry>
<material>
<ambient>0.2 0.2 0.2 1</ambient>
<diffuse>0.2 0.2 0.2 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
</material>
</visual>
<collision name='collision_left_wheel'>
<geometry>
<sphere>
<radius>0.3</radius>
</sphere>
</geometry>
</collision>
</link>

<link name='right_wheel'>
<pose>0.554282 -0.625029 -0.025 -1.5707 0 0</pose>
<inertial>
<mass>2</mass>
<inertia>
<ixx>0.145833</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.145833</iyy>
<iyz>0</iyz>
<izz>0.125</izz>
</inertia>
</inertial>
<visual name='visual_right_wheel'>
<geometry>
<sphere>
<radius>0.3</radius>
</sphere>
</geometry>
<material>
<ambient>0.2 0.2 0.2 1</ambient>
<diffuse>0.2 0.2 0.2 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
</material>
</visual>
<collision name='collision_right_wheel'>
<geometry>
<sphere>
<radius>0.3</radius>
</sphere>
</geometry>
</collision>
</link>

<link name='caster'>
<pose>-0.957138 -0 -0.125 0 -0 0</pose>
<inertial>
<mass>1</mass>
<inertia>
<ixx>0.1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.1</iyy>
<iyz>0</iyz>
<izz>0.1</izz>
</inertia>
</inertial>
<visual name='visual_caster'>
<geometry>
<sphere>
<radius>0.2</radius>
</sphere>
</geometry>
<material>
<ambient>0.2 0.2 0.2 1</ambient>
<diffuse>0.2 0.2 0.2 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
</material>
</visual>
<collision name='collision_caster'>
<geometry>
<sphere>
<radius>0.2</radius>
</sphere>
</geometry>
</collision>
</link>

<joint name='left_wheel_joint' type='revolute'>
<parent>chassis</parent>
<child>left_wheel</child>
<axis>
<xyz>0 0 1</xyz>
<limit>
<lower>-1.79769e+308</lower>
<upper>1.79769e+308</upper>
</limit>
</axis>
</joint>

<joint name='right_wheel_joint' type='revolute'>
<parent>chassis</parent>
<child>right_wheel</child>
<axis>
<xyz>0 0 1</xyz>
<limit>
<lower>-1.79769e+308</lower>
<upper>1.79769e+308</upper>
</limit>
</axis>
</joint>

<joint name='caster_wheel' type='ball'>
<parent>chassis</parent>
<child>caster</child>
</joint>

<plugin
filename="ignition-gazebo-diff-drive-system"
name="ignition::gazebo::systems::DiffDrive">
<left_joint>left_wheel_joint</left_joint>
<right_joint>right_wheel_joint</right_joint>
<wheel_separation>1.25</wheel_separation>
<wheel_radius>0.3</wheel_radius>
<odom_publish_frequency>1</odom_publish_frequency>
<max_linear_acceleration>1</max_linear_acceleration>
<min_linear_acceleration>-1</min_linear_acceleration>
<max_angular_acceleration>2</max_angular_acceleration>
<min_angular_acceleration>-2</min_angular_acceleration>
<max_linear_velocity>0.5</max_linear_velocity>
<min_linear_velocity>-0.5</min_linear_velocity>
<max_angular_velocity>1</max_angular_velocity>
<min_angular_velocity>-1</min_angular_velocity>
</plugin>

</model>
</sdf>
1 change: 1 addition & 0 deletions ros_gz_sim_demos/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<exec_depend>rqt_plot</exec_depend>
<exec_depend>rqt_topic</exec_depend>
<exec_depend>rviz2</exec_depend>
<exec_depend>sdformat_urdf</exec_depend>
<exec_depend>xacro</exec_depend>

<test_depend>ament_lint_auto</test_depend>
Expand Down
Loading

0 comments on commit 5d99c01

Please sign in to comment.