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
22 changes: 22 additions & 0 deletions src/scenic/simulators/gazebo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Scenic-Gazebo Interface
This is the code for the Scenic-Gazebo interface.

## Requirements and Installation
- Gazebo Harmonic
- ROS 2 Jazzy
### ROS Packages
- ros-gz
- simulation-interfaces
- ros2launch
- libsdformat14
- python3-sdformat14

## Instructions
This interface requires a running Gazebo simulation with the /gzserver endpoint up, which is launched with a ROS launch file. combined_launch.py is provided as a simple example of one. To use the interface, run:
- ros2 launch combined_launch.py
- scenic *some_scenario.scenic* -S

The interface can spawn, delete, get object states, and pause, unpause, and reset the simulation. Any robot-specific code isn't included.

## Notes
- python3-sdformat14 is a system package, to use it in a venv add include-system-site-packages = true to your venv config file
36 changes: 36 additions & 0 deletions src/scenic/simulators/gazebo/combined_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# mostly copied from gz_server.launch.py in ros_gz_sim
"""Launch gz_server in a component container, and also launch the Gazebo GUI client."""

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess
from launch.substitutions import LaunchConfiguration, TextSubstitution
from ros_gz_sim.actions import GzServer


def generate_launch_description():

declare_world_sdf_file_cmd = DeclareLaunchArgument(
'world_sdf_file', default_value=TextSubstitution(text='empty.sdf'),
description='Path to the SDF world file')

#starts server
gz_server_action = GzServer(
world_sdf_file=LaunchConfiguration('world_sdf_file'),
)

#starts gui
gz_sim_action = ExecuteProcess(
cmd=['gz', 'sim', '-r', LaunchConfiguration('world_sdf_file')],
output='screen'
)

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

# Declare the launch options
ld.add_action(declare_world_sdf_file_cmd)
# Add the gz_server action
ld.add_action(gz_server_action)
ld.add_action(gz_sim_action)

return ld
34 changes: 34 additions & 0 deletions src/scenic/simulators/gazebo/model.scenic
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import math
from scenic.simulators.gazebo.simulator import GazeboSimulator, GazeboSimulation
import os

simulator GazeboSimulator()
object_prefix = '/mnt/l/scenic/src/scenic/simulators/gazebo/'# placeholder, put the path to the folder storing the Gazebo models you want to spawn
default_file_name = "model.sdf"
get_sdf_dir = lambda s: object_prefix + s + "/" + default_file_name

class Robot:
name: 'robot'
object_type: 'robot'

class GazeboObject:
"""
Superclass for non-agent objects
"""
name: 'gazebo_object'
object_type: 'gazebo_object'
description_file: ''
description_file_type: 'sdf'
width: 1
length: 1
height: 1
positionOffset:(0, 0, 0)

class SDFObject:
"""
Used for SDF parsing to make Scenic aware of predefined objects in the world
"""
name: 'sdf_object'
object_type: 'sdf_object'
description_file: ''
description_file_type: 'sdf'
Loading