{#-------------------SDF generator for Tether Gazebo model--------------------#} {#--------------The parameters bellow are the ones to be tweaked--------------#} {#--------------------------:Tweakable parameters:----------------------------#} {%- set number_elements = 1 -%} {%- set last_elem = number_elements |int - 1 -%} {%- set cl = 0.17 -%} {#- cl: length of the element (meters) -#} {%- set cr = 0.001 -%} {#- cr: radius of the element (meters) -#} {%- set sr = 0.009 -%} {#- sr: element joint radius (sphere) (meters) -#} {%- set y_el = 0.2 -%} {#- y_el: length of the Y elements (meters) -#} {%- set y_tetha = 18 -%} {#- y_tetha: angle between the Y elements (degrees)-#} {%- set m = 0.03 * cl -%} {#- m: mass of the element (kg), given the length -#} {%- set damping = 0.05 -%} {%- set friction = 0.0 -%} {%- set spring_stiffness = 0.01 -%} {%- set spring_reference = 0.0 -%} {%- set element_color = 'White' -%} {%- set joint_color = 'Red' -%} {#----------------------------------------------------------------------------#} {%- macro cylinder(cl, cr) -%} {{cl}} {{cr}} {%- endmacro -%} {%- macro sphere(sr) -%} {{sr}} {%- endmacro -%} {%- macro inertial(m) -%} {#- A note about the inertial tensor matrix - It should be as bellow -#} {#- {%- set izz = m/2*cr**2 -%} -#} {#- {%- set ixx = m/12*cl**2 + m/4*cr**2 -%} -#} {#- {%- set iyy = m/12*cl**2 + m/4*cr**2 -%} -#} {#- but seems to segfault Gazebo when changing the values of the element specs -#} {%- set izz = 0.01 -%} {%- set ixx = 0.01 -%} {%- set iyy = 0.01 -%} {{m}} {{ixx}} 0 0 {{iyy}} 0 {{izz}} {%- endmacro -%} {%- macro collision(cl, cr) -%} 0.1 0 0 0 1.570790 0 {{ cylinder(cl, cr) }} 0.00005 1.0 1.0 {%- endmacro -%} {%- macro element_material(element_color) -%} {%- endmacro -%} {%- macro joint_material(joint_color) -%} {%- endmacro -%} {%- macro element_visual(cl, cr, element_color) -%} {%- set x = cl * 0.5 -%} {{x}} 0 0 0 1.570790 0 {{ cylinder(cl, cr) }} {{ element_material(element_color) }} {%- endmacro -%} {%- macro sphere_visual(sr, sphere_clor) -%} {{ sphere(sr) }} {{ joint_material(joint_color) }} {%- endmacro -%} {%- macro link(n, x, y, z, yaw, m, cl, cr, sr, element_color, joint_color) -%} true {{x}} {{y}} {{z}} 0.0 0.0 {{yaw}} {{ inertial(m) }} {%- if n != last_elem -%} {{ collision(cl, cr) }} {{ element_visual(cl, cr, element_color) }} {%- endif -%} {{ sphere_visual(sr, joint_color) }} {%- endmacro %} {%- macro joint(k, damping, friction, spring_stiffness, spring_reference) -%} {%- if k is number -%} {%- set link_n = k - 1 -%} link_{{k}} link_{{link_n}} {%- else -%} {%- set link_n = 0 -%} link_{{link_n}} link_{{k}} {%- endif %} 0 1 0 {{damping}} {{friction}} {{spring_stiffness}} {{spring_reference}} true 0 0 1 {{damping}} {{friction}} {{spring_stiffness}} {{spring_reference}} true 1 {%- endmacro -%} {%- macro lift_drag(n, cl, cr) -%} {%- set area = 2 * cr * cl -%} 0 0 1.2535816618911175 0 1.4326647564469914 0 0 0 {{area}} 1.2041 0 1 0 0 0 1 link_{{n}} {%- endmacro %} {%- macro y_element(cl, y_el, y_tetha) %} {%- set x_l = - cl / 2 -%} {%- set y_l = 0.0 -%} {%- set z_l = 0.0 -%} {%- set yaw_l = - y_tetha / 2 -%} {{ link("y_left", x_l, y_l, z_l, yaw_l, m, y_el, cr, sr, element_color, joint_color) }} {{ lift_drag("y_left", cl, cr) }} {%- set x_r = - cl / 2 -%} {%- set y_r = 0 -%} {%- set z_r = 0.0 -%} {%- set yaw_r = y_tetha / 2 %} {{ link("y_right", x_r, y_r, z_r, yaw_r, m, y_el, cr, sr, element_color, joint_color) }} {{ lift_drag("y_right", cl, cr) }} {{ joint("y_left", damping, friction, spring_stiffness, spring_reference) }} {{ joint("y_right", damping, friction, spring_stiffness, spring_reference) }} {%- endmacro -%} 0.0 0.0 0.0 0.0 0.0 0.0 {% for n in range(number_elements) -%} {%- set x = n * cl / 2 + ( n - 1) * cl / 2 -%} {%- set y = 0.0 -%} {%- set z = 0.0 -%} {%- set yaw = 0.0 -%} {{ link(n, x, y, z, yaw, m, cl, cr, sr, element_color, joint_color) }} {{ lift_drag(n, cl, cr) }} {% endfor -%} {{ y_element(cl, y_el, y_tetha) }} {% for k in range(1, number_elements) -%} {{ joint(k, damping, friction, spring_stiffness, spring_reference) }} {% endfor -%} link_{{last_elem}} world