Skip to content

Commit

Permalink
added a robot description factory
Browse files Browse the repository at this point in the history
  • Loading branch information
mhubii committed Jul 31, 2023
1 parent bf7d1ff commit 9418fe1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lbr_description/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_pytest REQUIRED)
find_package(ament_cmake_python REQUIRED)

# install
ament_python_install_package(${PROJECT_NAME})

install(
DIRECTORY config gazebo launch meshes ros2_control urdf
DESTINATION share/${PROJECT_NAME}
Expand Down
1 change: 1 addition & 0 deletions lbr_description/lbr_description/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .description_factory import description_factory
34 changes: 34 additions & 0 deletions lbr_description/lbr_description/description_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
from typing import Dict

import xacro
from ament_index_python import get_package_share_directory


def description_factory(
model: str = "iiwa7", robot_name: str = "lbr", sim: bool = True
) -> Dict[str, str]:
r"""Robot description factory for the LBR.
Args:
model (str): The LBR model in use. Defaults to "iiwa7". Choices are "iiwa7", "iiwa14", "med7", "med14".
robot_name (str): The name of the robot.
sim (bool): Whether to use the simulation or not.
Returns:
robot_description (Dict[str, str]): The robot description as a dictionary.
"""
robot_description = {
"robot_description": xacro.process(
os.path.join(
get_package_share_directory("lbr_description"),
f"urdf/{model}/{model}.urdf.xacro",
),
mappings={
"robot_name": robot_name,
"sim": "true" if sim else "false",
},
)
}

return robot_description
1 change: 1 addition & 0 deletions lbr_description/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_pytest</buildtool_depend>
<buildtool_depend>ament_cmake_python</buildtool_depend>

<exec_depend>xacro</exec_depend>
<exec_depend>joint_state_publisher_gui</exec_depend>
Expand Down

0 comments on commit 9418fe1

Please sign in to comment.