Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# dingo_simulator
This is the ROS 2 simulation package for the Dingo robot

## Installation
Make sure you run rosdep from your workspace folder.
```
rosdep install --from-paths src --ignore-src -r -y
```

Then simply build the packages using colcon build
```
colcon build --symlink-install
```

Finally, add the following line to your .bashrc file
```
export DINGO_LASER_3D 1
```

## Using
In order to use the simulation, you will need to run the following launch file.
```
ros2 launch dingo_gazebo dingo_world.launch.py
```
Wait for Gazebo to fully start.
The Velodyne simulator can take up to 30 seconds to start, meaning the gazebo_ros spawner will take that long.
As a result, ros2_control is delayed by about 20 seconds.
This will ensure that the controllers don't time out while waiting to connect to the server started in the urdf.
28 changes: 18 additions & 10 deletions dingo_gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
cmake_minimum_required(VERSION 2.8.3)
################################################################################
# Set minimum required version of cmake, project name and compile options
################################################################################
cmake_minimum_required(VERSION 3.5)
project(dingo_gazebo)

find_package(catkin REQUIRED)
################################################################################
# Find ament packages and libraries for ament and system dependencies
################################################################################
find_package(ament_cmake REQUIRED)

catkin_package()

install(DIRECTORY config launch worlds
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
################################################################################
# Install
################################################################################
install(
DIRECTORY launch worlds
DESTINATION share/${PROJECT_NAME}
)

if(CATKIN_ENABLE_TESTING)
find_package(roslaunch REQUIRED)
roslaunch_add_file_check(launch/dingo_world.launch)
endif()
################################################################################
# Macro for ament package
################################################################################
ament_package()
4 changes: 0 additions & 4 deletions dingo_gazebo/config/gains_diff.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions dingo_gazebo/config/gains_omni.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions dingo_gazebo/launch/dingo_world.launch

This file was deleted.

95 changes: 95 additions & 0 deletions dingo_gazebo/launch/dingo_world.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.conditions import IfCondition
from launch.substitutions import LaunchConfiguration, PythonExpression


def generate_launch_description():
# Get the launch directory
this_directory = get_package_share_directory('dingo_gazebo')

# Launch configuration variables specific to simulation
headless = LaunchConfiguration('headless')
world = LaunchConfiguration('world')
x_pose = LaunchConfiguration('x_pose')
y_pose = LaunchConfiguration('y_pose')
z_pose = LaunchConfiguration('z_pose')
yaw = LaunchConfiguration('yaw')
config = LaunchConfiguration('config')

# Declare the launch arguments
declare_x_position_cmd = DeclareLaunchArgument(
'x_pose', default_value='0.0',
description='x_pose')

declare_y_position_cmd = DeclareLaunchArgument(
'y_pose', default_value='0.0',
description='y_pose')

declare_z_position_cmd = DeclareLaunchArgument(
'z_pose', default_value='0.1',
description='z_pose')

declare_yaw_cmd = DeclareLaunchArgument(
'yaw', default_value='0.0',
description='yaw')

declare_config_cmd = DeclareLaunchArgument(
'config',
default_value=os.getenv('DINGO_CONFIG', 'base'),
description='get the dingo configuration')

declare_headless_cmd = DeclareLaunchArgument(
'headless',
default_value='False',
description='Whether to execute gzclient)')

declare_world_cmd = DeclareLaunchArgument(
'world',
default_value=os.path.join(this_directory, 'worlds', 'dingo_race.world'),
description='Full path to world model file to load')

# Specify the actions
start_gazebo_server_cmd = ExecuteProcess(
cmd=['gzserver', '--verbose', '-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so', world],
cwd=[this_directory], output='screen')

start_gazebo_client_cmd = ExecuteProcess(
condition=IfCondition(PythonExpression(['not ', headless])),
cmd=['gzclient'],
cwd=[this_directory], output='screen')

spawn_dingo_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(this_directory, 'launch', 'spawn_dingo.launch.py')),
launch_arguments={
'config' : config,
'x_pose' : x_pose,
'y_pose' : y_pose,
'z_pose' : z_pose,
'yaw' : yaw
}.items()
)

# Create the launch description and populate
ld = LaunchDescription()

# Declare the launch options
ld.add_action(declare_headless_cmd)
ld.add_action(declare_world_cmd)
ld.add_action(declare_x_position_cmd)
ld.add_action(declare_y_position_cmd)
ld.add_action(declare_z_position_cmd)
ld.add_action(declare_yaw_cmd)
ld.add_action(declare_config_cmd)

# Add any conditioned actions
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)
ld.add_action(spawn_dingo_cmd)

return ld
34 changes: 0 additions & 34 deletions dingo_gazebo/launch/empty_world.launch

This file was deleted.

88 changes: 88 additions & 0 deletions dingo_gazebo/launch/empty_world.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.conditions import IfCondition
from launch.substitutions import LaunchConfiguration, PythonExpression


def generate_launch_description():
# Get the launch directory
this_directory = get_package_share_directory('dingo_gazebo')

# Launch configuration variables specific to simulation
headless = LaunchConfiguration('headless')
x_pose = LaunchConfiguration('x_pose')
y_pose = LaunchConfiguration('y_pose')
z_pose = LaunchConfiguration('z_pose')
yaw = LaunchConfiguration('yaw')
config = LaunchConfiguration('config')

# Declare the launch arguments
declare_x_position_cmd = DeclareLaunchArgument(
'x_pose', default_value='0.0',
description='x_pose')

declare_y_position_cmd = DeclareLaunchArgument(
'y_pose', default_value='0.0',
description='y_pose')

declare_z_position_cmd = DeclareLaunchArgument(
'z_pose', default_value='0.1',
description='z_pose')

declare_yaw_cmd = DeclareLaunchArgument(
'yaw', default_value='0.0',
description='yaw')

declare_config_cmd = DeclareLaunchArgument(
'config',
default_value=os.getenv('DINGO_CONFIG', 'base'),
description='get the dingo configuration')

declare_headless_cmd = DeclareLaunchArgument(
'headless',
default_value='False',
description='Whether to execute gzclient)')

# Specify the actions
start_gazebo_server_cmd = ExecuteProcess(
cmd=['gzserver', '--verbose', '-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so'],
cwd=[this_directory], output='screen')

start_gazebo_client_cmd = ExecuteProcess(
condition=IfCondition(PythonExpression(['not ', headless])),
cmd=['gzclient'],
cwd=[this_directory], output='screen')

spawn_dingo_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(this_directory, 'launch', 'spawn_dingo.launch.py')),
launch_arguments={
'config' : config,
'x_pose' : x_pose,
'y_pose' : y_pose,
'z_pose' : z_pose,
'yaw' : yaw
}.items()
)

# Create the launch description and populate
ld = LaunchDescription()

# Declare the launch options
ld.add_action(declare_headless_cmd)
ld.add_action(declare_x_position_cmd)
ld.add_action(declare_y_position_cmd)
ld.add_action(declare_z_position_cmd)
ld.add_action(declare_yaw_cmd)
ld.add_action(declare_config_cmd)

# Add any conditioned actions
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)
ld.add_action(spawn_dingo_cmd)

return ld
34 changes: 0 additions & 34 deletions dingo_gazebo/launch/spawn_dingo.launch

This file was deleted.

Loading