Skip to content

Commit

Permalink
using macros now
Browse files Browse the repository at this point in the history
  • Loading branch information
pwmarshall committed Dec 11, 2024
1 parent 7be8da7 commit cb05553
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 722 deletions.
4 changes: 0 additions & 4 deletions src/robot_description/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ install(
# Convert xarco to urdf on BUILD this is pretty bad but it works
add_custom_target(ConvertXacro ALL
COMMAND xacro ${CMAKE_CURRENT_SOURCE_DIR}/models/master_ASM/urdf/master_ASM.urdf.xacro > ${CMAKE_CURRENT_BINARY_DIR}/master_ASM.urdf
COMMAND xacro ${CMAKE_CURRENT_SOURCE_DIR}/models/master_ASM/urdf/robot.urdf.xacro > ${CMAKE_CURRENT_BINARY_DIR}/robot.urdf
COMMENT "Generating URDF from Xacro"
)

Expand All @@ -50,9 +49,6 @@ install(CODE "
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/master_ASM.urdf
${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/models/master_ASM/urdf/master_ASM.urdf)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/robot.urdf
${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/models/master_ASM/urdf/robot.urdf)
")

ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in")
Expand Down
2 changes: 1 addition & 1 deletion src/robot_description/launch/robot_description.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def generate_launch_description():
pkg_project_description = get_package_share_directory("robot_description")
# Load the SDF file from "description" package
xacro_path = PathJoinSubstitution(
[pkg_project_description, "models", "master_ASM", "urdf", "robot.urdf.xacro"]
[pkg_project_description, "models", "master_ASM", "urdf", "master_ASM.urdf.xacro"]
)

robot_state_publisher = Node(
Expand Down
2 changes: 1 addition & 1 deletion src/robot_description/models/master_ASM/model.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<model>
<name>master_ASM</name>
<version>1.0</version>
<sdf version='1.6'>urdf/robot.urdf</sdf>
<sdf version='1.6'>urdf/master_ASM.urdf</sdf>
</model>
57 changes: 54 additions & 3 deletions src/robot_description/models/master_ASM/urdf/macros.urdf.xacro
Original file line number Diff line number Diff line change
@@ -1,9 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>

<robot name="macros" xmlns:xacro="http://www.ros.org/wiki/xacro">
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

<xacro:macro name="wheel" params="name">
<xacro:macro name="wheel_link" params="name pretty:=^|true wheelRadius:=^ wheelWidth:=^ wheelMass:=^ *origin">

<link name="${name}">
<inertial>
<xacro:insert_block name="origin" />
<mass value="${wheelMass}" />
<inertia
ixx="0.0059462"
ixy="0"
ixz="0"
iyy="0.0059468"
iyz="0"
izz="0.0072591" />
</inertial>

<visual>
<xacro:insert_block name="origin" />

</xacro:macro>
<geometry>
<xacro:if value="${pretty}">
<mesh
filename="$(find robot_description)/models/master_ASM/meshes/wheel_Link.STL" />
</xacro:if>
<xacro:unless value="${pretty}">
<cylinder radius="${wheelRadius}" length="${wheelWidth}" />
</xacro:unless>
</geometry>
<material name="grey" />
</visual>

<collision>
<xacro:insert_block name="origin" />
<geometry>
<cylinder radius="${wheelRadius}" length="${wheelWidth}" />
</geometry>
</collision>
</link>


</xacro:macro>

<xacro:macro name="wheel_joint" params="wheel x y z">
<joint
name="${str(wheel) + '_joint'}"
type="continuous">
<origin
xyz="${x} ${y} -${z}"
rpy="${pi/2} 0 ${pi/2}" />
<parent link="frame_link" />
<child link="${str(wheel) + '_link'}" />
<axis
xyz="0 0 -1" />
</joint>
</xacro:macro>

</robot>
Loading

0 comments on commit cb05553

Please sign in to comment.