Refactor openarm_description into separate package

This commit is contained in:
Thomason Zhou 2025-03-11 13:16:12 +09:00
parent 17b99f5342
commit bb8bff1b63
18 changed files with 144 additions and 66 deletions

View File

@ -1,54 +0,0 @@
import os
import launch
import launch_ros
import xacro
from launch.substitutions import LaunchConfiguration
from ament_index_python import get_package_share_directory
def get_package_file(package, file_path):
"""Get the location of a file installed in an ament package"""
package_path = get_package_share_directory(package)
absolute_file_path = os.path.join(package_path, file_path)
return absolute_file_path
def generate_launch_description():
xacro_file = get_package_file(
"openarm_bimanual_description", "urdf/openarm_bimanual.urdf.xacro"
)
urdf = xacro.process_file(xacro_file).toprettyxml(indent=" ")
default_rviz_config_path = get_package_file(
"openarm_bimanual_description", "rviz/robot_description.rviz"
)
return launch.LaunchDescription(
[
launch_ros.actions.Node(
name="robot_state_publisher",
package="robot_state_publisher",
executable="robot_state_publisher",
output="screen",
parameters=[{"robot_description": urdf}],
),
launch_ros.actions.Node(
name="joint_state_publisher_gui",
package="joint_state_publisher_gui",
executable="joint_state_publisher_gui",
output="screen",
),
launch.actions.DeclareLaunchArgument(
name="rvizconfig",
default_value=str(default_rviz_config_path),
description="Absolute path to rviz config file",
),
launch_ros.actions.Node(
name="rviz",
package="rviz2",
executable="rviz2",
output="screen",
arguments=["-d", LaunchConfiguration("rvizconfig")],
),
]
)

View File

@ -2,7 +2,7 @@
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="openarm_bimanual"> <robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="openarm_bimanual">
<link name="world"/> <link name="world"/>
<xacro:include filename="openarm.xacro"/> <xacro:include filename="$(find openarm_description)/urdf/openarm.urdf.xacro"/>
<xacro:include filename="openarm_pedestal.urdf"/> <xacro:include filename="openarm_pedestal.urdf"/>
<xacro:openarm prefix="right_" side="right"/> <xacro:openarm prefix="right_" side="right"/>
<xacro:openarm prefix="left_" side="left"/> <xacro:openarm prefix="left_" side="left"/>

Binary file not shown.

View File

@ -1,42 +1,174 @@
Panels: Panels:
- Class: rviz_common/Displays - Class: rviz_common/Displays
Help Height: 71
Name: Displays Name: Displays
Property Tree Widget:
Expanded:
- /Global Options1
Splitter Ratio: 0.5
Tree Height: 294
- Class: rviz_common/Views - Class: rviz_common/Views
Expanded:
- /Current View1
Name: Views Name: Views
Splitter Ratio: 0.5
Visualization Manager: Visualization Manager:
Class: "" Class: ""
Displays: Displays:
- Class: rviz_default_plugins/Grid - Alpha: 0.5
Cell Size: 1
Class: rviz_default_plugins/Grid
Color: 160; 160; 164
Enabled: true
Line Style:
Line Width: 0.029999999329447746
Value: Lines
Name: Grid Name: Grid
Normal Cell Count: 0
Offset:
X: 0
Y: 0
Z: 0
Plane: XY
Plane Cell Count: 10
Reference Frame: <Fixed Frame>
Value: true Value: true
Alpha: 0.5 - Alpha: 1
- Class: rviz_default_plugins/RobotModel Class: rviz_default_plugins/RobotModel
Collision Enabled: false
Description File: ""
Description Source: Topic Description Source: Topic
Description Topic: Description Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /robot_description Value: /robot_description
Enabled: true Enabled: true
Links:
All Links Enabled: true
Expand Joint Details: false
Expand Link Details: false
Expand Tree: false
Link Tree Style: Links in Alphabetic Order
link1:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
link2:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
link3:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
link4:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
link5:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
link6:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
link7:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
link8:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
link_left_jaw:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
link_right_jaw:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
Mass Properties:
Inertia: false
Mass: false
Name: RobotModel Name: RobotModel
Alpha: 1 TF Prefix: ""
Update Interval: 0
Value: true Value: true
Visual Enabled: true
- Class: rviz_default_plugins/TF - Class: rviz_default_plugins/TF
Name: TF
Value: true
Enabled: false Enabled: false
Filter (blacklist): ""
Filter (whitelist): ""
Frame Timeout: 15
Frames:
All Enabled: true
Marker Scale: 1
Name: TF
Show Arrows: true
Show Axes: true
Show Names: false
Tree:
{}
Update Interval: 0
Value: false
Enabled: true
Global Options: Global Options:
Fixed Frame: l_J1_v002 Background Color: 48; 48; 48
Fixed Frame: link1
Frame Rate: 30 Frame Rate: 30
Name: root Name: root
Tools: Tools:
- Class: rviz_default_plugins/MoveCamera - Class: rviz_default_plugins/MoveCamera
Transformation:
Current:
Class: rviz_default_plugins/TF
Value: true Value: true
Views: Views:
Current: Current:
Class: rviz_default_plugins/Orbit Class: rviz_default_plugins/Orbit
Distance: 5.0 Distance: 5
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: 0
Y: 0
Z: 0
Focal Shape Fixed Size: true
Focal Shape Size: 0.05000000074505806
Invert Z Axis: false
Name: Current View Name: Current View
Pitch: 0.33 Near Clip Distance: 0.009999999776482582
Pitch: 0.33000001311302185
Target Frame: <Fixed Frame>
Value: Orbit (rviz) Value: Orbit (rviz)
Yaw: 5.5 Yaw: 5.5
Saved: ~
Window Geometry: Window Geometry:
Displays:
collapsed: false
Height: 800 Height: 800
Hide Left Dock: false
Hide Right Dock: false
QMainWindow State: 000000ff00000000fd0000000100000000000001b6000002c5fc0200000002fb000000100044006900730070006c006100790073010000003e000001aa000000cb00fffffffb0000000a0056006900650077007301000001ee00000115000000a500ffffff000002f4000002c500000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Views:
collapsed: false
Width: 1200 Width: 1200
X: 43
Y: 12

View File

@ -6,7 +6,7 @@
<color rgba="${105/255} ${105/255} ${105/255} 1.0"/> <color rgba="${105/255} ${105/255} ${105/255} 1.0"/>
</material> </material>
<xacro:macro name="openarm" params="side prefix"> <xacro:macro name="openarm" params="side:='right' prefix:=''">
<xacro:property name="reflect" value="${1 if side=='right' else -1}"/> <xacro:property name="reflect" value="${1 if side=='right' else -1}"/>
<xacro:property name="rotate" value="${0 if side=='right' else pi}"/> <xacro:property name="rotate" value="${0 if side=='right' else pi}"/>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="openarm"> <robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="openarm">
<xacro:include filename="openarm.xacro.urdf"/> <xacro:include filename="openarm.urdf.xacro"/>
<xacro:openarm/> <xacro:openarm/>
<xacro:include filename="openarm_sensors.urdf.xacro"/> <xacro:include filename="openarm_sensors.urdf.xacro"/>
</robot> </robot>