Skip to content

Commit 78f22d8

Browse files
authored
Merge pull request #74 from peakyquest/crazyflie_description
adding a urdf of crazyflie
2 parents d5cb41f + 6ef08e5 commit 78f22d8

File tree

11 files changed

+1671
-0
lines changed

11 files changed

+1671
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(crazyflie_description)
3+
4+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5+
add_compile_options(-Wall -Wextra -Wpedantic)
6+
endif()
7+
8+
# find dependencies
9+
find_package(ament_cmake REQUIRED)
10+
11+
12+
if(BUILD_TESTING)
13+
find_package(ament_lint_auto REQUIRED)
14+
set(ament_cmake_copyright_FOUND TRUE)
15+
set(ament_cmake_cpplint_FOUND TRUE)
16+
ament_lint_auto_find_test_dependencies()
17+
endif()
18+
19+
# Install launch files
20+
install(DIRECTORY
21+
launch
22+
urdf
23+
meshes
24+
rviz
25+
config
26+
DESTINATION share/${PROJECT_NAME}/
27+
)
28+
29+
ament_package()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- ros_topic_name: "/cmd_vel"
3+
gz_topic_name: "/crazyflie/gazebo/command/twist"
4+
ros_type_name: "geometry_msgs/msg/Twist"
5+
gz_type_name: "ignition.msgs.Twist"
6+
direction: ROS_TO_GZ
7+
- ros_topic_name: "/clock"
8+
gz_topic_name: "/clock"
9+
ros_type_name: "rosgraph_msgs/msg/Clock"
10+
gz_type_name: "gz.msgs.Clock"
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from launch import LaunchDescription
2+
from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument
3+
from launch.launch_description_sources import PythonLaunchDescriptionSource
4+
from launch_ros.actions import Node
5+
from launch.substitutions import LaunchConfiguration
6+
from ament_index_python.packages import get_package_share_directory
7+
import os
8+
import xacro
9+
10+
11+
def generate_launch_description():
12+
# Package and xacro path
13+
pkg_share = get_package_share_directory("crazyflie_description")
14+
xacro_file = os.path.join(pkg_share, "urdf", "crazyflie_body.xacro")
15+
16+
# Process xacro → urdf
17+
robot_description_config = xacro.process_file(xacro_file).toxml()
18+
19+
# Launch argument for robot name
20+
robot_name_arg = DeclareLaunchArgument(
21+
"robot_name",
22+
default_value="crazyflie",
23+
description="Name of the robot"
24+
)
25+
26+
# Start Gazebo Harmonic (empty world)
27+
gazebo_launch = IncludeLaunchDescription(
28+
PythonLaunchDescriptionSource(
29+
os.path.join(
30+
get_package_share_directory("ros_gz_sim"), "launch", "gz_sim.launch.py"
31+
)
32+
),
33+
launch_arguments={"gz_args": "-r empty.sdf"}.items(),
34+
)
35+
36+
# Spawn robot in Gazebo
37+
spawn_robot = Node(
38+
package="ros_gz_sim",
39+
executable="create",
40+
arguments=[
41+
"-name", LaunchConfiguration("robot_name"),
42+
"-string", robot_description_config,
43+
"-x", "0.0", # X position
44+
"-y", "0.0", # Y position
45+
"-z", "0.5", # Z position (height)
46+
],
47+
output="screen",
48+
)
49+
50+
# ROS-Gazebo bridge
51+
bridge = Node(
52+
package="ros_gz_bridge",
53+
executable="parameter_bridge",
54+
parameters=[{
55+
"config_file": os.path.join(pkg_share, "config", "ros_gz_crazyflie_bridge.yaml"),
56+
}],
57+
output="screen",
58+
)
59+
60+
return LaunchDescription([
61+
robot_name_arg,
62+
gazebo_launch,
63+
spawn_robot,
64+
bridge,
65+
])
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
from ament_index_python.packages import get_package_share_directory
2+
3+
from launch import LaunchDescription
4+
from launch.actions import DeclareLaunchArgument
5+
from launch.substitutions import Command, PathJoinSubstitution
6+
from launch.substitutions.launch_configuration import LaunchConfiguration
7+
8+
from launch_ros.actions import Node
9+
10+
11+
ARGUMENTS = [
12+
DeclareLaunchArgument('use_sim_time', default_value='false',
13+
choices=['true', 'false'],
14+
description='Use simulation (Gazebo) clock if true'),
15+
DeclareLaunchArgument('robot_name', default_value='crazyflie',
16+
description='Robot name'),
17+
DeclareLaunchArgument('namespace', default_value=LaunchConfiguration('robot_name'),
18+
description='Robot namespace'),
19+
]
20+
21+
22+
def generate_launch_description():
23+
pkg_crazyflie_description = get_package_share_directory('crazyflie_description')
24+
25+
# Paths
26+
xacro_file = PathJoinSubstitution([pkg_crazyflie_description, 'urdf', 'crazyflie_body.xacro'])
27+
rviz_config_file = PathJoinSubstitution([pkg_crazyflie_description, 'rviz', 'crazyflie_body.rviz'])
28+
29+
namespace = LaunchConfiguration('namespace')
30+
31+
# Robot State Publisher
32+
robot_state_publisher = Node(
33+
package='robot_state_publisher',
34+
executable='robot_state_publisher',
35+
name='robot_state_publisher',
36+
output='screen',
37+
parameters=[
38+
{'use_sim_time': LaunchConfiguration('use_sim_time')},
39+
{'robot_description': Command(['xacro ', xacro_file])},
40+
],
41+
remappings=[
42+
('/tf', 'tf'),
43+
('/tf_static', 'tf_static')
44+
]
45+
)
46+
47+
# Joint State Publisher GUI (for revolute joints)
48+
joint_state_publisher_gui = Node(
49+
package='joint_state_publisher_gui',
50+
executable='joint_state_publisher_gui',
51+
name='joint_state_publisher_gui',
52+
output='screen',
53+
parameters=[{'use_sim_time': LaunchConfiguration('use_sim_time')}],
54+
remappings=[
55+
('/tf', 'tf'),
56+
('/tf_static', 'tf_static')
57+
]
58+
)
59+
60+
# RViz2
61+
rviz2 = Node(
62+
package='rviz2',
63+
executable='rviz2',
64+
name='rviz2',
65+
arguments=['-d', rviz_config_file],
66+
output='screen'
67+
)
68+
69+
# LaunchDescription
70+
ld = LaunchDescription(ARGUMENTS)
71+
ld.add_action(robot_state_publisher)
72+
ld.add_action(joint_state_publisher_gui)
73+
ld.add_action(rviz2)
74+
return ld

crazyflie_ws/src/crazyflie_description/meshes/collada_files/ccw_prop.dae

Lines changed: 116 additions & 0 deletions
Large diffs are not rendered by default.

crazyflie_ws/src/crazyflie_description/meshes/collada_files/cf2_assembly.dae

Lines changed: 398 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)