Hello,
I am currently working on a forklift in Gazebo. My specific question is, what would be the best way to simulate the chassis? I just created a Xacro macro to build the chassis, which consists of 3 parts. This is the URDF that is generated. It seems to simplify the model quite a bit, but my question is, how can I continue scaling this? How can I add the wheels and other structures that a forklift has? For example, in the case of the wheels, I can’t do it since I need space for them within collision_box2
and collision_box3
. What is the best solution for this if my goal is to ensure that the simulated model behaves as close to the real one as possible?
The reason I use Xacro macros is to easily change the dimensions of the chassis if needed. So I can scale this project.
<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from test.urdf.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<robot name="test">
<!-- Base Link -->
<link name="base_link">
<inertial>
<mass value="1.0"/>
<inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01"/>
</inertial>
<visual>
<geometry>
<box size="0.0001 0.0001 0.0001"/>
</geometry>
<material name="green"/>
</visual>
<collision>
<geometry>
<box size="0.0001 0.0001 0.0001"/>
</geometry>
</collision>
</link>
<!-- Collision Box 1 -->
<link name="collision_box_1">
<inertial>
<mass value="0.5"/>
<inertia ixx="0.005" ixy="0.0" ixz="0.0" iyy="0.005" iyz="0.0" izz="0.005"/>
</inertial>
<visual>
<geometry>
<box size="0.18 0.25 0.2"/>
</geometry>
<material name="red"/>
</visual>
<collision>
<geometry>
<box size="0.18 0.25 0.2"/>
</geometry>
</collision>
</link>
<!-- Collision Box 2 -->
<link name="collision_box_2">
<inertial>
<mass value="0.5"/>
<inertia ixx="0.002" ixy="0.0" ixz="0.0" iyy="0.002" iyz="0.0" izz="0.002"/>
</inertial>
<visual>
<geometry>
<box size="0.2 0.03 0.03"/>
</geometry>
<material name="blue"/>
</visual>
<collision>
<geometry>
<box size="0.2 0.03 0.03"/>
</geometry>
</collision>
</link>
<!-- Collision Box 3 -->
<link name="collision_box_3">
<inertial>
<mass value="0.5"/>
<inertia ixx="0.002" ixy="0.0" ixz="0.0" iyy="0.002" iyz="0.0" izz="0.002"/>
</inertial>
<visual>
<geometry>
<box size="0.2 0.03 0.03"/>
</geometry>
<material name="blue"/>
</visual>
<collision>
<geometry>
<box size="0.2 0.03 0.03"/>
</geometry>
</collision>
</link>
<!-- Joints -->
<joint name="fixed_joint_1" type="fixed">
<parent link="base_link"/>
<child link="collision_box_1"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
</joint>
<joint name="fixed_joint_2" type="fixed">
<parent link="base_link"/>
<child link="collision_box_2"/>
<origin rpy="0 0 0" xyz="0.19 0.11 -0.085"/>
</joint>
<joint name="fixed_joint_3" type="fixed">
<parent link="base_link"/>
<child link="collision_box_3"/>
<origin rpy="0 0 0" xyz="0.19 -0.11 -0.085"/>
</joint>
</robot>
This is the xacro:macro
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- Macro para crear la estructura escalable -->
<xacro:macro name="create_structure" params="base_props">
<!-- Cálculo de offset -->
<xacro:property name="offset_x_2_3" value="${ base_props['box1']['x'] /2 + base_props['box2']['x'] /2}"/>
<xacro:property name="offset_y_2_3" value="${(base_props['box1']['y'] / 2) - (base_props['box2']['y'] / 2)}"/>
<xacro:property name="offset_z_2_3" value="${(- base_props['box1']['z'] / 2) + (base_props['box2']['z'] / 2)}"/>
<!-- Base Link -->
<link name="base_link">
<inertial>
<mass value="1.0"/>
<inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01"/>
</inertial>
<visual>
<geometry>
<box size="0.0001 0.0001 0.0001"/>
</geometry>
<material name="green"/>
</visual>
<collision>
<geometry>
<box size="0.0001 0.0001 0.0001"/>
</geometry>
</collision>
</link>
<!-- Collision Box 1 -->
<link name="collision_box_1">
<inertial>
<mass value="0.5"/>
<inertia ixx="0.005" ixy="0.0" ixz="0.0" iyy="0.005" iyz="0.0" izz="0.005"/>
</inertial>
<visual>
<geometry>
<box size="${base_props['box1']['x']} ${base_props['box1']['y']} ${base_props['box1']['z']}"/>
</geometry>
<material name="red"/>
</visual>
<collision>
<geometry>
<box size="${base_props['box1']['x']} ${base_props['box1']['y']} ${base_props['box1']['z']}"/>
</geometry>
</collision>
</link>
<!-- Collision Box 2 -->
<link name="collision_box_2">
<inertial>
<mass value="0.5"/>
<inertia ixx="0.002" ixy="0.0" ixz="0.0" iyy="0.002" iyz="0.0" izz="0.002"/>
</inertial>
<visual>
<geometry>
<box size="${base_props['box2']['x']} ${base_props['box2']['y']} ${base_props['box2']['z']}"/>
</geometry>
<material name="blue"/>
</visual>
<collision>
<geometry>
<box size="${base_props['box2']['x']} ${base_props['box2']['y']} ${base_props['box2']['z']}"/>
</geometry>
</collision>
</link>
<!-- Collision Box 3 -->
<link name="collision_box_3">
<inertial>
<mass value="0.5"/>
<inertia ixx="0.002" ixy="0.0" ixz="0.0" iyy="0.002" iyz="0.0" izz="0.002"/>
</inertial>
<visual>
<geometry>
<box size="${base_props['box3']['x']} ${base_props['box3']['y']} ${base_props['box3']['z']}"/>
</geometry>
<material name="blue"/>
</visual>
<collision>
<geometry>
<box size="${base_props['box3']['x']} ${base_props['box3']['y']} ${base_props['box3']['z']}"/>
</geometry>
</collision>
</link>
<!-- Joints -->
<joint name="fixed_joint_1" type="fixed">
<parent link="base_link"/>
<child link="collision_box_1"/>
<origin xyz="0 0 0" rpy="0 0 0"/>
</joint>
<joint name="fixed_joint_2" type="fixed">
<parent link="base_link"/>
<child link="collision_box_2"/>
<origin xyz="${offset_x_2_3} ${offset_y_2_3} ${offset_z_2_3}" rpy="0 0 0"/>
</joint>
<joint name="fixed_joint_3" type="fixed">
<parent link="base_link"/>
<child link="collision_box_3"/>
<origin xyz="${offset_x_2_3} ${offset_y_2_3*-1} ${offset_z_2_3}" rpy="0 0 0"/>
</joint>
</xacro:macro>
</robot>