Skip to content

Commit

Permalink
Merge pull request gazebosim#6 from wingtra/xacro_model
Browse files Browse the repository at this point in the history
Xacro model
  • Loading branch information
devbharat committed Oct 24, 2015
2 parents 5011ee8 + 18e8c4b commit c87eccf
Show file tree
Hide file tree
Showing 12 changed files with 1,566 additions and 11 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}/msgs
)

set(enable_mavlink_interface "true")
set(enable_ground_truth "false")
set(enable_logging "false")
set(rotors_description_dir "${CMAKE_SOURCE_DIR}/models/rotors_description")
add_custom_target(sdf
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND rm -f ${CMAKE_SOURCE_DIR}/models/iris/iris.sdf
COMMAND python xacro.py -o ${rotors_description_dir}/urdf/iris_base.urdf ${rotors_description_dir}/urdf/iris_base.xacro enable_mavlink_interface:=${enable_mavlink_interface} enable_ground_truth:=${enable_ground_truth} enable_logging:=${enable_logging} rotors_description_dir:=${rotors_description_dir}
COMMAND gz sdf -p ${rotors_description_dir}/urdf/iris_base.urdf >> ${CMAKE_SOURCE_DIR}/models/iris/iris.sdf
COMMAND rm -f ${rotors_description_dir}/urdf/iris_base.urdf
)

link_directories(${GAZEBO_LIBRARY_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/msgs)
add_subdirectory(msgs)

Expand Down
22 changes: 11 additions & 11 deletions models/iris/iris.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>model://iris/meshes/iris.dae</uri>
<uri>model://rotors_description/meshes/iris.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -118,7 +118,7 @@
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>model://iris/meshes/iris_prop_ccw.dae</uri>
<uri>model://rotors_description/meshes/iris_prop_ccw.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -184,7 +184,7 @@
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>model://iris/meshes/iris_prop_ccw.dae</uri>
<uri>model://rotors_description/meshes/iris_prop_ccw.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -250,7 +250,7 @@
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>model://iris/meshes/iris_prop_cw.dae</uri>
<uri>model://rotors_description/meshes/iris_prop_cw.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -316,7 +316,7 @@
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>model://iris/meshes/iris_prop_cw.dae</uri>
<uri>model://rotors_description/meshes/iris_prop_cw.dae</uri>
</mesh>
</geometry>
<material>
Expand Down Expand Up @@ -419,6 +419,12 @@
<motorSpeedPubTopic>motor_speed/3</motorSpeedPubTopic>
<rotorVelocitySlowdownSim>10</rotorVelocitySlowdownSim>
</plugin>
<plugin name='mavlink_interface' filename='librotors_gazebo_mavlink_interface.so'>
<robotNamespace>iris</robotNamespace>
<imuSubTopic>imu</imuSubTopic>
<motorSpeedCommandPubTopic>gazebo/command/motor_speed</motorSpeedCommandPubTopic>
</plugin>
<static>0</static>
<plugin name='rotors_gazebo_imu_plugin' filename='librotors_gazebo_imu_plugin.so'>
<robotNamespace>iris</robotNamespace>
<linkName>iris/imu_link</linkName>
Expand All @@ -432,11 +438,5 @@
<accelerometerBiasCorrelationTime>300.0</accelerometerBiasCorrelationTime>
<accelerometerTurnOnBiasSigma>0.196</accelerometerTurnOnBiasSigma>
</plugin>
<plugin name='mavlink_interface' filename='librotors_gazebo_mavlink_interface.so'>
<robotNamespace>iris</robotNamespace>
<imuSubTopic>imu</imuSubTopic>
<motorSpeedCommandPubTopic>gazebo/command/motor_speed</motorSpeedCommandPubTopic>
</plugin>
<static>0</static>
</model>
</sdf>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
454 changes: 454 additions & 0 deletions models/rotors_description/urdf/component_snippets.xacro

Large diffs are not rendered by default.

149 changes: 149 additions & 0 deletions models/rotors_description/urdf/iris.xacro
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?xml version="1.0"?>

<robot name="iris" xmlns:xacro="http://ros.org/wiki/xacro">
<!-- Properties -->
<xacro:property name="namespace" value="iris" />
<xacro:property name="rotor_velocity_slowdown_sim" value="10" />
<xacro:property name="mesh_file" value="iris.dae" />
<xacro:property name="mesh_scale" value="1 1 1"/>
<xacro:property name="mesh_scale_prop" value="1 1 1"/>
<xacro:property name="mass" value="1.5" /> <!-- [kg] -->
<xacro:property name="body_width" value="0.47" /> <!-- [m] -->
<xacro:property name="body_height" value="0.11" /> <!-- [m] -->
<xacro:property name="mass_rotor" value="0.005" /> <!-- [kg] -->
<xacro:property name="arm_length_front_x" value="0.13" /> <!-- [m] -->
<xacro:property name="arm_length_back_x" value="0.13" /> <!-- [m] -->
<xacro:property name="arm_length_front_y" value="0.22" /> <!-- [m] -->
<xacro:property name="arm_length_back_y" value="0.2" /> <!-- [m] -->
<xacro:property name="rotor_offset_top" value="0.023" /> <!-- [m] -->
<xacro:property name="radius_rotor" value="0.1" /> <!-- [m] -->
<xacro:property name="motor_constant" value="8.54858e-06" /> <!-- [kg.m/s^2] -->
<xacro:property name="moment_constant" value="0.16" /> <!-- [m] -->
<xacro:property name="time_constant_up" value="0.0125" /> <!-- [s] -->
<xacro:property name="time_constant_down" value="0.025" /> <!-- [s] -->
<xacro:property name="max_rot_velocity" value="838" /> <!-- [rad/s] -->
<xacro:property name="sin30" value="0.5" />
<xacro:property name="cos30" value="0.866025403784" />
<xacro:property name="sqrt2" value="1.4142135623730951" />
<xacro:property name="rotor_drag_coefficient" value="8.06428e-05" />
<xacro:property name="rolling_moment_coefficient" value="0.000001" />
<xacro:property name="color" value="DarkGrey" />

<!-- Property Blocks -->
<xacro:property name="body_inertia">
<inertia ixx="0.0347563" ixy="0.0" ixz="0.0" iyy="0.0458929" iyz="0.0" izz="0.0977" /> <!-- [kg.m^2] [kg.m^2] [kg.m^2] [kg.m^2] [kg.m^2] [kg.m^2] -->
</xacro:property>

<!-- inertia of a single rotor, assuming it is a cuboid. Height=3mm, width=15mm -->
<xacro:property name="rotor_inertia">
<inertia
ixx="${1/12 * mass_rotor * (0.015 * 0.015 + 0.003 * 0.003) * rotor_velocity_slowdown_sim}"
iyy="${1/12 * mass_rotor * (4 * radius_rotor * radius_rotor + 0.003 * 0.003) * rotor_velocity_slowdown_sim}"
izz="${1/12 * mass_rotor * (4 * radius_rotor * radius_rotor + 0.015 * 0.015) * rotor_velocity_slowdown_sim}"
ixy="0.0" ixz="0.0" iyz="0.0" /> <!-- [kg.m^2] [kg.m^2] [kg.m^2] [kg.m^2] [kg.m^2] [kg.m^2] -->
</xacro:property>

<!-- Included URDF Files -->
<xacro:include filename="$(arg rotors_description_dir)/urdf/multirotor_base.xacro" />

<!-- Instantiate multirotor_base_macro once -->
<xacro:multirotor_base_macro
robot_namespace="${namespace}"
mass="${mass}"
body_width="${body_width}"
body_height="${body_height}"
mesh_file="${mesh_file}"
mesh_scale="${mesh_scale}"
color="${color}"
>
<xacro:insert_block name="body_inertia" />
</xacro:multirotor_base_macro>

<!-- Instantiate rotors -->
<xacro:vertical_rotor
robot_namespace="${namespace}"
suffix="front_right"
direction="ccw"
motor_constant="${motor_constant}"
moment_constant="${moment_constant}"
parent="base_link"
mass_rotor="${mass_rotor}"
radius_rotor="${radius_rotor}"
time_constant_up="${time_constant_up}"
time_constant_down="${time_constant_down}"
max_rot_velocity="${max_rot_velocity}"
motor_number="0"
rotor_drag_coefficient="${rotor_drag_coefficient}"
rolling_moment_coefficient="${rolling_moment_coefficient}"
mesh="iris_prop"
mesh_scale="${mesh_scale_prop}"
color="Blue">
<origin xyz="${arm_length_front_x} -${arm_length_front_y} ${rotor_offset_top}" rpy="0 0 0" />
<xacro:insert_block name="rotor_inertia" />
</xacro:vertical_rotor>

<xacro:vertical_rotor
robot_namespace="${namespace}"
suffix="back_left"
direction="ccw"
motor_constant="${motor_constant}"
moment_constant="${moment_constant}"
parent="base_link"
mass_rotor="${mass_rotor}"
radius_rotor="${radius_rotor}"
time_constant_up="${time_constant_up}"
time_constant_down="${time_constant_down}"
max_rot_velocity="${max_rot_velocity}"
motor_number="1"
rotor_drag_coefficient="${rotor_drag_coefficient}"
rolling_moment_coefficient="${rolling_moment_coefficient}"
mesh="iris_prop"
mesh_scale="${mesh_scale_prop}"
color="DarkGrey">
<origin xyz="-${arm_length_back_x} ${arm_length_back_y} ${rotor_offset_top}" rpy="0 0 0" />
<xacro:insert_block name="rotor_inertia" />
</xacro:vertical_rotor>

<xacro:vertical_rotor robot_namespace="${namespace}"
suffix="front_left"
direction="cw"
motor_constant="${motor_constant}"
moment_constant="${moment_constant}"
parent="base_link"
mass_rotor="${mass_rotor}"
radius_rotor="${radius_rotor}"
time_constant_up="${time_constant_up}"
time_constant_down="${time_constant_down}"
max_rot_velocity="${max_rot_velocity}"
motor_number="2"
rotor_drag_coefficient="${rotor_drag_coefficient}"
rolling_moment_coefficient="${rolling_moment_coefficient}"
mesh="iris_prop"
mesh_scale="${mesh_scale_prop}"
color="Blue">
<origin xyz="${arm_length_front_x} ${arm_length_front_y} ${rotor_offset_top}" rpy="0 0 0" />
<xacro:insert_block name="rotor_inertia" />
</xacro:vertical_rotor>

<xacro:vertical_rotor robot_namespace="${namespace}"
suffix="back_right"
direction="cw"
motor_constant="${motor_constant}"
moment_constant="${moment_constant}"
parent="base_link"
mass_rotor="${mass_rotor}"
radius_rotor="${radius_rotor}"
time_constant_up="${time_constant_up}"
time_constant_down="${time_constant_down}"
max_rot_velocity="${max_rot_velocity}"
motor_number="3"
rotor_drag_coefficient="${rotor_drag_coefficient}"
rolling_moment_coefficient="${rolling_moment_coefficient}"
mesh="iris_prop"
mesh_scale="${mesh_scale_prop}"
color="DarkGrey">
<origin xyz="-${arm_length_back_x} -${arm_length_back_y} ${rotor_offset_top}" rpy="0 0 0" />
<xacro:insert_block name="rotor_inertia" />
</xacro:vertical_rotor>

</robot>
101 changes: 101 additions & 0 deletions models/rotors_description/urdf/iris_base.xacro
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0"?>

<robot name="iris" xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:include filename="$(arg rotors_description_dir)/urdf/component_snippets.xacro" />
<!-- Instantiate iris "mechanics" -->
<xacro:include filename="$(arg rotors_description_dir)/urdf/iris.xacro" />

<xacro:if value="$(arg enable_mavlink_interface)">
<!-- Instantiate mavlink telemetry interface. -->
<xacro:mavlink_interface_macro
namespace="${namespace}"
imu_sub_topic="imu"
>
</xacro:mavlink_interface_macro>
</xacro:if>

<!-- Mount an ADIS16448 IMU. -->
<xacro:imu_plugin_macro
namespace="${namespace}"
imu_suffix=""
parent_link="base_link"
imu_topic="imu"
mass_imu_sensor="0.015"
gyroscope_noise_density="0.0003394"
gyroscopoe_random_walk="0.000038785"
gyroscope_bias_correlation_time="1000.0"
gyroscope_turn_on_bias_sigma="0.0087"
accelerometer_noise_density="0.004"
accelerometer_random_walk="0.006"
accelerometer_bias_correlation_time="300.0"
accelerometer_turn_on_bias_sigma="0.1960"
>
<inertia ixx="0.00001" ixy="0.0" ixz="0.0" iyy="0.00001" iyz="0.0" izz="0.00001" />
<origin xyz="0 0 0" rpy="0 0 0" />
</xacro:imu_plugin_macro>

<xacro:if value="$(arg enable_ground_truth)">
<!-- Mount an IMU providing ground truth. -->
<xacro:imu_plugin_macro
namespace="${namespace}"
imu_suffix="gt"
parent_link="base_link"
imu_topic="ground_truth/imu"
mass_imu_sensor="0.00001"
gyroscope_noise_density="0.0"
gyroscopoe_random_walk="0.0"
gyroscope_bias_correlation_time="1000.0"
gyroscope_turn_on_bias_sigma="0.0"
accelerometer_noise_density="0.0"
accelerometer_random_walk="0.0"
accelerometer_bias_correlation_time="300.0"
accelerometer_turn_on_bias_sigma="0.0"
>
<inertia ixx="0.00001" ixy="0.0" ixz="0.0" iyy="0.00001" iyz="0.0" izz="0.00001" />
<origin xyz="0 0 0" rpy="0 0 0" />
</xacro:imu_plugin_macro>

<!-- Mount a generic odometry sensor providing ground truth. -->
<xacro:odometry_plugin_macro
namespace="${namespace}/ground_truth"
odometry_sensor_suffix="gt"
parent_link="base_link"
pose_topic="pose"
pose_with_covariance_topic="pose_with_covariance"
position_topic="position"
transform_topic="transform"
odometry_topic="odometry"
parent_frame_id="world"
mass_odometry_sensor="0.00001"
measurement_divisor="1"
measurement_delay="0"
unknown_delay="0.0"
noise_normal_position="0 0 0"
noise_normal_quaternion="0 0 0"
noise_normal_linear_velocity="0 0 0"
noise_normal_angular_velocity="0 0 0"
noise_uniform_position="0 0 0"
noise_uniform_quaternion="0 0 0"
noise_uniform_linear_velocity="0 0 0"
noise_uniform_angular_velocity="0 0 0"
enable_odometry_map="false"
odometry_map=""
image_scale=""
>
<inertia ixx="0.00001" ixy="0.0" ixz="0.0" iyy="0.00001" iyz="0.0" izz="0.00001" /> <!-- [kg.m^2] [kg.m^2] [kg.m^2] [kg.m^2] [kg.m^2] [kg.m^2] -->
<origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0" />
</xacro:odometry_plugin_macro>
</xacro:if>

<xacro:if value="$(arg enable_logging)">
<!-- Instantiate a logger -->
<xacro:bag_plugin_macro
namespace="${namespace}"
bag_file="$(arg log_file)"
rotor_velocity_slowdown_sim="${rotor_velocity_slowdown_sim}"
>
</xacro:bag_plugin_macro>
</xacro:if>

</robot>

Loading

0 comments on commit c87eccf

Please sign in to comment.