feat: add webots integration
This commit is contained in:
parent
a10ded747a
commit
033e14d80e
7 changed files with 524 additions and 243 deletions
55
launch/robot_world_launch.py
Normal file
55
launch/robot_world_launch.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 1996-2023 Cyberbotics Ltd.
|
||||
#
|
||||
# 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 Webots Universal Robot simulation world."""
|
||||
|
||||
import launch
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch.substitutions.path_join_substitution import PathJoinSubstitution
|
||||
from webots_ros2_driver.webots_launcher import WebotsLauncher
|
||||
|
||||
|
||||
PACKAGE_NAME = 'aubo_description'
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
package_dir = get_package_share_directory(PACKAGE_NAME)
|
||||
world = LaunchConfiguration('world')
|
||||
|
||||
# Starts Webots
|
||||
webots = WebotsLauncher(
|
||||
world=PathJoinSubstitution([package_dir, 'world', world]),
|
||||
ros2_supervisor=True
|
||||
)
|
||||
|
||||
return LaunchDescription([
|
||||
DeclareLaunchArgument(
|
||||
'world',
|
||||
default_value='aubo_robot.wbt',
|
||||
),
|
||||
webots,
|
||||
webots._supervisor,
|
||||
# This action will kill all nodes once the Webots simulation has exited
|
||||
launch.actions.RegisterEventHandler(
|
||||
event_handler=launch.event_handlers.OnProcessExit(
|
||||
target_action=webots,
|
||||
on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())],
|
||||
)
|
||||
)
|
||||
])
|
Loading…
Add table
Add a link
Reference in a new issue