Created
July 10, 2024 08:47
-
-
Save knmcguire/c5d276592a91a17c71e082cc1d172692 to your computer and use it in GitHub Desktop.
A ROS 2 launch file that works with the Crazyswarm2 ROS 2 crazyflie server and the ROS 2 merge mapping example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from ament_index_python.packages import get_package_share_directory | |
from launch import LaunchDescription | |
from launch_ros.actions import Node | |
import yaml | |
def generate_launch_description(): | |
# load crazyflies | |
crazyflies_yaml = os.path.join( | |
get_package_share_directory('crazyflie'), | |
'config', | |
'crazyflies.yaml') | |
with open(crazyflies_yaml, 'r') as ymlfile: | |
crazyflies = yaml.safe_load(ymlfile) | |
server_params = crazyflies | |
# robot description | |
urdf = os.path.join( | |
get_package_share_directory('crazyflie'), | |
'urdf', | |
'crazyflie_description.urdf') | |
with open(urdf, 'r') as f: | |
robot_desc = f.read() | |
server_params['robot_description'] = robot_desc | |
crazyflie_name = '/cf231' | |
return LaunchDescription([ | |
# These nodes need https://github.com/IMRCLab/crazyswarm2 | |
Node( | |
package='crazyflie', | |
executable='crazyflie_server.py', | |
name='crazyflie_server', | |
output='screen', | |
parameters=[server_params], | |
#remappings=[ | |
# ('/cf4/odom', '/cfcombi/odom'), | |
# ('/cf4/scan', '/cfcombi/scan'), | |
# ('/cf5/odom', '/cfcombi/odom'), | |
# ('/cf5/scan', '/cfcombi/scan'), | |
# ('/cf6/odom', '/cfcombi/odom'), | |
# ('/cf6/scan', '/cfcombi/scan'), | |
#] | |
), | |
Node( | |
package='crazyflie', | |
executable='vel_mux.py', | |
name='vel_mux', | |
output='screen', | |
parameters=[{'hover_height': 0.3}, | |
{'incoming_twist_topic': '/cmd_vel'}, | |
{'robot_prefix': 'cf4'}] | |
), | |
Node( | |
package='crazyflie', | |
executable='vel_mux.py', | |
name='vel_mux', | |
output='screen', | |
parameters=[{'hover_height': 0.4}, | |
{'incoming_twist_topic': '/cmd_vel'}, | |
{'robot_prefix': 'cf5'}] | |
), | |
Node( | |
package='crazyflie', | |
executable='vel_mux.py', | |
name='vel_mux', | |
output='screen', | |
parameters=[{'hover_height': 0.5}, | |
{'incoming_twist_topic': '/cmd_vel'}, | |
{'robot_prefix': 'cf6'}] | |
), | |
Node( | |
package='crazyflie', | |
executable='simple_mapper_multiranger.py', | |
name='simple_mapper_multiranger', | |
output='screen', | |
parameters=[ | |
{'robot_prefix': 'cf4'}] | |
), | |
Node( | |
package='crazyflie', | |
executable='simple_mapper_multiranger.py', | |
name='simple_mapper_multiranger', | |
output='screen', | |
parameters=[ | |
{'robot_prefix': 'cf5'}] | |
), | |
Node( | |
package='crazyflie', | |
executable='simple_mapper_multiranger.py', | |
name='simple_mapper_multiranger', | |
output='screen', | |
parameters=[ | |
{'robot_prefix': 'cf6'}] | |
), | |
# these node need: https://github.com/abdulkadrtr/mapMergeForMultiRobotMapping-ROS2 | |
Node( | |
package='merge_map', | |
executable='merge_map', | |
output='screen', | |
remappings=[ | |
("/map1", "/cf6/map"), | |
("/map2", "/cf5/map"), | |
("/merge_map", "/map12") | |
], | |
), | |
Node( | |
package='merge_map', | |
executable='merge_map', | |
output='screen', | |
remappings=[ | |
("/map1", "/map12"), | |
("/map2", "/cf4/map"), | |
], | |
), | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment