Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add crazyflie webots packages #872

Merged
merged 9 commits into from
Jan 3, 2024
Merged
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
72 changes: 72 additions & 0 deletions webots_ros2_crazyflie/launch/robot_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
#
# ........... ____ _ __
# | ,-^-, | / __ )(_) /_______________ _____ ___
# | ( O ) | / __ / / __/ ___/ ___/ __ `/_ / / _ \
# | / ,..´ | / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
# +....... /_____/_/\__/\___/_/ \__,_/ /___/\___/

# MIT License

# Copyright (c) 2023 Bitcraze


"""
file: robot_launch.py

Launch Webots Crazyflie ROS2 driver.

Author: Kimberly McGuire (Bitcraze AB)
"""


import os
import launch
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument
from launch.substitutions.path_join_substitution import PathJoinSubstitution
from launch import LaunchDescription
from ament_index_python.packages import get_package_share_directory
from webots_ros2_driver.webots_launcher import WebotsLauncher
from webots_ros2_driver.webots_controller import WebotsController


def generate_launch_description():
package_dir = get_package_share_directory('webots_ros2_crazyflie')
world = LaunchConfiguration('world')

webots = WebotsLauncher(
world=PathJoinSubstitution([package_dir, 'worlds', world]),
ros2_supervisor=True
)

robot_description_path = os.path.join(
package_dir, 'resource', 'crazyflie_webots.urdf')
crazyflie_driver = WebotsController(
robot_name='Crazyflie',
parameters=[
{'robot_description': robot_description_path},
],
respawn=True
)

return LaunchDescription([
DeclareLaunchArgument(
'world',
default_value='crazyflie_apartment.wbt',
description='Choose one of the world files from `/webots_ros2_crazyflie/worlds` directory'
),
webots,
webots._supervisor,
crazyflie_driver,

# 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())
],
)
)
])
22 changes: 22 additions & 0 deletions webots_ros2_crazyflie/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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>webots_ros2_crazyflie</name>
<version>2023.1.1</version>
<description>ROS2 package for Crazyflie webots simulator</description>
<maintainer email="[email protected]">Kimberly McGuire (Bitcraze AB)</maintainer>
<license>MIT</license>

<exec_depend>rclpy</exec_depend>
<exec_depend>builtin_interfaces</exec_depend>
<exec_depend>webots_ros2_driver</exec_depend>

<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
17 changes: 17 additions & 0 deletions webots_ros2_crazyflie/resource/crazyflie_webots.urdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" ?>
<robot name="Crazyflie Webots">
<webots>
<device reference="gps" type="GPS">
<ros>
<enabled>true</enabled>
<alwaysOn>true</alwaysOn>
</ros>
</device>
<device reference="camera" type="Camera">
<ros>
<topicName>/camera</topicName>
</ros>
</device>
<plugin type="webots_ros2_crazyflie.crazyflie_driver.CrazyflieDriver" />
</webots>
</robot>
Empty file.
4 changes: 4 additions & 0 deletions webots_ros2_crazyflie/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/webots_ros2_crazyflie
[install]
install_scripts=$base/lib/webots_ros2_crazyflie
32 changes: 32 additions & 0 deletions webots_ros2_crazyflie/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from setuptools import find_packages, setup

package_name = 'webots_ros2_crazyflie'
data_files = []
data_files.append(('share/ament_index/resource_index/packages', ['resource/' + package_name]))
data_files.append(('share/' + package_name + '/launch', ['launch/robot_launch.py']))
data_files.append(('share/' + package_name + '/worlds', [
'worlds/crazyflie_apartment.wbt', 'worlds/.crazyflie_apartment.wbproj',
]))
data_files.append(('share/' + package_name + '/resource', [
'resource/crazyflie_webots.urdf'
]))
data_files.append(('share/' + package_name, ['package.xml']))

setup(
name=package_name,
version='2023.1.1',
packages=find_packages(exclude=['test']),
data_files=data_files,
install_requires=['setuptools', 'launch'],
zip_safe=True,
maintainer='Kimberly McGuire (Bitcraze AB)',
maintainer_email='[email protected]',
description='ROS2 package for Crazyflie webots simulator',
license='MIT',
tests_require=['pytest'],
entry_points={
'console_scripts': [
'crazyflie_driver = webots_ros2_crazyflie.crazyflie_driver:main',
],
},
)
Empty file.
Loading
Loading