From c22df4c779686347caa2a7f46f04b7d15a5a4c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jirou=C5=A1ek=2C=20Martin?= Date: Tue, 28 May 2024 16:43:04 +0200 Subject: [PATCH] Add payload to the end of the suspended cable --- .../sdf/component_snippets.sdf.jinja | 14 ++++- .../sdf/generic_components.sdf.jinja | 51 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/ros_packages/mrs_uav_gazebo_simulation/models/mrs_robots_description/sdf/component_snippets.sdf.jinja b/ros_packages/mrs_uav_gazebo_simulation/models/mrs_robots_description/sdf/component_snippets.sdf.jinja index 8d1ee50..595f5bd 100644 --- a/ros_packages/mrs_uav_gazebo_simulation/models/mrs_robots_description/sdf/component_snippets.sdf.jinja +++ b/ros_packages/mrs_uav_gazebo_simulation/models/mrs_robots_description/sdf/component_snippets.sdf.jinja @@ -2645,12 +2645,14 @@ limitations under the License. {%- endmacro -%} {# #} + + {# pendulum_macro {--> #} {%- macro pendulum_macro(parent_link, x, y, z, spawner_args) -%} {%- set spawner_keyword = 'enable-pendulum' -%} {%- set spawner_description = 'Add a pendulum to the vehicle. Specify the length and mass of the whole chain. Length and mass is uniformly distributed between the links' -%} - {%- set spawner_default_args = {'chain_length': 3.0, 'chain_mass': 0.5, 'num_links': 30, 'radius': 0.01} -%} + {%- set spawner_default_args = {'chain_length': 2.0, 'chain_mass': 0.1, 'load_mass': 1.0, 'load_radius': 0.1, 'num_links': 15, 'radius': 0.01} -%} {%- if spawner_keyword in spawner_args.keys() -%} {{ generic.handle_spawner_args(spawner_keyword, spawner_default_args, spawner_args) }} @@ -2687,6 +2689,16 @@ limitations under the License. {%- endfor -%} + + {{ generic.load_pendulum_macro( + parent_link = 'pendulum_chain_' + (spawner_args[spawner_keyword]['num_links'] - 1)| string() + '_link', + link_length = spawner_args[spawner_keyword]['chain_length'] / spawner_args[spawner_keyword]['num_links'], + load_mass = spawner_args[spawner_keyword]['load_mass'], + load_radius = spawner_args[spawner_keyword]['load_radius'] + ) + }} + + {%- endif -%} {%- endmacro -%} diff --git a/ros_packages/mrs_uav_gazebo_simulation/models/mrs_robots_description/sdf/generic_components.sdf.jinja b/ros_packages/mrs_uav_gazebo_simulation/models/mrs_robots_description/sdf/generic_components.sdf.jinja index 63f8814..19f6960 100644 --- a/ros_packages/mrs_uav_gazebo_simulation/models/mrs_robots_description/sdf/generic_components.sdf.jinja +++ b/ros_packages/mrs_uav_gazebo_simulation/models/mrs_robots_description/sdf/generic_components.sdf.jinja @@ -164,6 +164,19 @@ limitations under the License. {%- endmacro -%} {# #} + +{%- macro ball_inertia(m, r) -%} + + {{ 2 * m * r * r / 5 }} + 0 + 0 + {{ 2 * m * r * r / 5 }} + 0 + {{ 2 * m * r * r / 5 }} + +{%- endmacro -%} + + {# single_chain_pendulum_macro {--> #} {%- macro single_chain_pendulum_macro(parent_link, id, link_mass, link_radius, link_length, joint_offset_x, joint_offset_y, joint_offset_z) -%} @@ -242,6 +255,44 @@ limitations under the License. {%- endmacro -%} {# #} +{# Macro to add pendulums load {--> #} +{%- macro load_pendulum_macro(parent_link, link_length, load_mass, load_radius) -%} + + 0 0 {{ -link_length/2 }} 0 0 0 + + {{ load_mass }} + {{ + ball_inertia( + m = load_mass, + r = load_radius, + ) + }} + + 1 + + 0 0 0 0 0 0 + + + {{ load_radius }} + + + + + + + + + + {{ parent_link }} + pendulum_load + 0 0 {{ -link_length/2 }} 0 0 0 + +{%- endmacro -%} + + {# ========================== visual blocks ========================= #} {# visual_mesh_macro {--> #}