Переработана вся структура запуска файлов. Теперь в iiwa_bringup хранятся только launch файлы.

Все конфигурационные файлы переехали в пакет `iiwa_config`. также там появился общий конфигурационный файл, который упращает запуск `digital_twin.launch.py`

Добавлен дополнительный пакет  `iiwa_utils`, в который переехал весь код с папки `iiwa_bringup/utils`, а также все тестовые ноды переехали с `iiwa_object_spawner` в этот пакет

Пакеты `iiwa_bringup` и `iiwa_description` переведены на `ament_cmake` для дальнейшего удобсва - пакеты не будут содержать код для реализации
This commit is contained in:
Даниил Грабарь
2025-12-25 21:46:40 +10:00
parent 1a65f48c03
commit fa39991bcf
41 changed files with 680 additions and 377 deletions
+15
View File
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.8)
project(iiwa_bringup)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(ament_cmake REQUIRED)
install(
DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
)
ament_package()
View File
-65
View File
@@ -1,65 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<robot name="iiwa7">
<!--GROUPS: Representation of a set of joints and links. This can be useful for specifying DOF to plan for, defining arms, end effectors, etc-->
<!--LINKS: When a link is specified, the parent joint of that link (if it exists) is automatically included-->
<!--JOINTS: When a joint is specified, the child link of that joint (which will always exist) is automatically included-->
<!--CHAINS: When a chain is specified, all the links along the chain (including endpoints) are included in the group. Additionally, all the joints that are parents to included links are also included. This means that joints along the chain and the parent joint of the base link are included in the group-->
<!--SUBGROUPS: Groups can also be formed by referencing to already defined group names-->
<group name="iiwa_arm">
<joint name="joint1"/>
<joint name="joint2"/>
<joint name="joint3"/>
<joint name="joint4"/>
<joint name="joint5"/>
<joint name="joint6"/>
<joint name="joint7"/>
</group>
<!--GROUP STATES: Purpose: Define a named state for a particular group, in terms of joint values. This is useful to define states like 'folded arms'-->
<group_state name="home" group="iiwa_arm">
<joint name="joint1" value="0"/>
<joint name="joint2" value="0"/>
<joint name="joint3" value="0"/>
<joint name="joint4" value="0"/>
<joint name="joint5" value="0"/>
<joint name="joint6" value="0"/>
<joint name="joint7" value="0"/>
</group_state>
<group_state name="work" group="iiwa_arm">
<joint name="joint1" value="0"/>
<joint name="joint2" value="0"/>
<joint name="joint3" value="0"/>
<joint name="joint4" value="-1.57"/>
<joint name="joint5" value="0"/>
<joint name="joint6" value="1.57"/>
<joint name="joint7" value="0"/>
</group_state>
<!--DISABLE COLLISIONS: By default it is assumed that any link of the robot could potentially come into collision with any other link in the robot. This tag disables collision checking between a specified pair of links. -->
<disable_collisions link1="base_link" link2="link1" reason="Adjacent"/>
<disable_collisions link1="base_link" link2="link2" reason="Never"/>
<disable_collisions link1="base_link" link2="link3" reason="Never"/>
<disable_collisions link1="base_link" link2="link4" reason="Never"/>
<disable_collisions link1="link1" link2="link2" reason="Adjacent"/>
<disable_collisions link1="link1" link2="link3" reason="Never"/>
<disable_collisions link1="link1" link2="link4" reason="Never"/>
<disable_collisions link1="link1" link2="link5" reason="Never"/>
<disable_collisions link1="link1" link2="link6" reason="Never"/>
<disable_collisions link1="link1" link2="link7" reason="Never"/>
<disable_collisions link1="link2" link2="link3" reason="Adjacent"/>
<disable_collisions link1="link2" link2="link4" reason="Never"/>
<disable_collisions link1="link2" link2="link5" reason="Never"/>
<disable_collisions link1="link2" link2="link6" reason="Never"/>
<disable_collisions link1="link2" link2="link7" reason="Never"/>
<disable_collisions link1="link3" link2="link4" reason="Adjacent"/>
<disable_collisions link1="link3" link2="link5" reason="Never"/>
<disable_collisions link1="link3" link2="link6" reason="Never"/>
<disable_collisions link1="link3" link2="link7" reason="Never"/>
<disable_collisions link1="link4" link2="link5" reason="Adjacent"/>
<disable_collisions link1="link4" link2="link6" reason="Never"/>
<disable_collisions link1="link4" link2="link7" reason="Never"/>
<disable_collisions link1="link5" link2="link6" reason="Adjacent"/>
<disable_collisions link1="link5" link2="link7" reason="Never"/>
<disable_collisions link1="link6" link2="link7" reason="Adjacent"/>
</robot>
@@ -1,30 +0,0 @@
controller_manager:
ros__parameters:
update_rate: 100
joint_state_broadcaster:
type: "joint_state_broadcaster/JointStateBroadcaster"
iiwa_arm_controller:
type: "joint_trajectory_controller/JointTrajectoryController"
iiwa_arm_controller:
ros__parameters:
joints:
- joint1
- joint2
- joint3
- joint4
- joint5
- joint6
- joint7
command_interfaces:
- position
state_interfaces:
- position
allow_partial_joints_goal: false
interpolate_from_desired_state: true
allow_nonzero_velocity_at_trajectory_end: true
@@ -1,10 +0,0 @@
# Default initial positions for iiwa7's ros2_control fake system
initial_positions:
joint1: 0
joint2: 0
joint3: 0
joint4: 0
joint5: 0
joint6: 0
joint7: 0
-45
View File
@@ -1,45 +0,0 @@
# joint_limits.yaml allows the dynamics properties specified in the URDF to be overwritten or augmented as needed
# For beginners, we downscale velocity and acceleration limits.
# You can always specify higher scaling factors (<= 1.0) in your motion requests. # Increase the values below to 1.0 to always move at maximum speed.
default_velocity_scaling_factor: 0.1
default_acceleration_scaling_factor: 0.1
# Specific joint properties can be changed with the keys [max_position, min_position, max_velocity, max_acceleration]
# Joint limits can be turned off with [has_velocity_limits, has_acceleration_limits]
joint_limits:
joint1:
has_velocity_limits: true
max_velocity: 1.71
has_acceleration_limits: true
max_acceleration: 3.0
joint2:
has_velocity_limits: true
max_velocity: 1.71
has_acceleration_limits: true
max_acceleration: 3.0
joint3:
has_velocity_limits: true
max_velocity: 1.75
has_acceleration_limits: true
max_acceleration: 3.0
joint4:
has_velocity_limits: true
max_velocity: 2.27
has_acceleration_limits: true
max_acceleration: 3.0
joint5:
has_velocity_limits: true
max_velocity: 2.4399999999999999
has_acceleration_limits: true
max_acceleration: 3.0
joint6:
has_velocity_limits: true
max_velocity: 3.1400000000000001
has_acceleration_limits: true
max_acceleration: 3.0
joint7:
has_velocity_limits: true
max_velocity: 3.1400000000000001
has_acceleration_limits: true
max_acceleration: 3.0
-4
View File
@@ -1,4 +0,0 @@
iiwa_arm:
kinematics_solver: kdl_kinematics_plugin/KDLKinematicsPlugin
kinematics_solver_search_resolution: 0.0050000000000000001
kinematics_solver_timeout: 0.0050000000000000001
@@ -1,43 +0,0 @@
planning_scene_monitor_options:
name: "planning_scene_monitor"
robot_description: "robot_description"
joint_state_topic: "/joint_states"
attached_collision_object_topic: "/moveit_cpp/planning_scene_monitor"
publish_planning_scene_topic: "/moveit_cpp/publish_planning_scene"
monitored_planning_scene_topic: "/moveit_cpp/monitored_planning_scene"
wait_for_initial_state_timeout: 10.0
planning_pipelines:
pipeline_names: ["ompl", "pilz_industrial_motion_planner", "chomp"]
plan_request_params:
planning_attempts: 1
planning_pipeline: ompl
max_velocity_scaling_factor: 1.0
max_acceleration_scaling_factor: 1.0
ompl_rrtc: # Namespace for individual plan request
plan_request_params: # PlanRequestParameters similar to the ones that are used by the single pipeline planning of moveit_cpp
planning_attempts: 1 # Number of attempts the planning pipeline tries to solve a given motion planning problem
planning_pipeline: ompl # Name of the pipeline that is being used
planner_id: "RRTConnectkConfigDefault" # Name of the specific planner to be used by the pipeline
max_velocity_scaling_factor: 1.0 # Velocity scaling parameter for the trajectory generation algorithm that is called (if configured) after the path planning
max_acceleration_scaling_factor: 1.0 # Acceleration scaling parameter for the trajectory generation algorithm that is called (if configured) after the path planning
planning_time: 1.0 # Time budget for the motion plan request. If the planning problem cannot be solved within this time, an empty solution with error code is returned
pilz_lin:
plan_request_params:
planning_attempts: 1
planning_pipeline: pilz_industrial_motion_planner
planner_id: "PTP"
max_velocity_scaling_factor: 1.0
max_acceleration_scaling_factor: 1.0
planning_time: 0.8
chomp_planner:
plan_request_params:
planning_attempts: 1
planning_pipeline: chomp
max_velocity_scaling_factor: 1.0
max_acceleration_scaling_factor: 1.0
planning_time: 1.5
@@ -1,20 +0,0 @@
# MoveIt uses this configuration for controller management
moveit_controller_manager: moveit_simple_controller_manager/MoveItSimpleControllerManager
moveit_simple_controller_manager:
controller_names:
- iiwa_arm_controller
iiwa_arm_controller:
type: FollowJointTrajectory
joints:
- joint1
- joint2
- joint3
- joint4
- joint5
- joint6
- joint7
action_ns: follow_joint_trajectory
default: true
@@ -1,6 +0,0 @@
# Limits for the Pilz planner
cartesian_limits:
max_trans_vel: 1.0
max_trans_acc: 2.25
max_trans_dec: -5.0
max_rot_vel: 1.57
-315
View File
@@ -1,315 +0,0 @@
Panels:
- Class: rviz_common/Displays
Help Height: 78
Name: Displays
Property Tree Widget:
Expanded:
- /Global Options1
- /Status1
Splitter Ratio: 0.5
Tree Height: 166
- Class: rviz_common/Selection
Name: Selection
- Class: rviz_common/Tool Properties
Expanded:
- /2D Goal Pose1
- /Publish Point1
Name: Tool Properties
Splitter Ratio: 0.5886790156364441
- Class: rviz_common/Views
Expanded:
- /Current View1
Name: Views
Splitter Ratio: 0.5
- Class: rviz_common/Time
Experimental: false
Name: Time
SyncMode: 0
SyncSource: ""
Visualization Manager:
Class: ""
Displays:
- 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
Normal Cell Count: 0
Offset:
X: 0
Y: 0
Z: 0
Plane: XY
Plane Cell Count: 10
Reference Frame: <Fixed Frame>
Value: true
- Acceleration_Scaling_Factor: 0.1
Class: moveit_rviz_plugin/MotionPlanning
Enabled: true
Move Group Namespace: ""
MoveIt_Allow_Approximate_IK: false
MoveIt_Allow_External_Program: false
MoveIt_Allow_Replanning: false
MoveIt_Allow_Sensor_Positioning: false
MoveIt_Planning_Attempts: 10
MoveIt_Planning_Time: 5
MoveIt_Use_Cartesian_Path: false
MoveIt_Use_Constraint_Aware_IK: false
MoveIt_Workspace:
Center:
X: 0
Y: 0
Z: 0
Size:
X: 2
Y: 2
Z: 2
Name: MotionPlanning
Planned Path:
Color Enabled: false
Interrupt Display: false
Links:
All Links Enabled: true
Expand Joint Details: false
Expand Link Details: false
Expand Tree: false
Link Tree Style: Links in Alphabetic Order
base_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
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
link_ee:
Alpha: 1
Show Axes: false
Show Trail: false
world:
Alpha: 1
Show Axes: false
Show Trail: false
Loop Animation: false
Robot Alpha: 0.5
Robot Color: 150; 50; 150
Show Robot Collision: false
Show Robot Visual: true
Show Trail: false
State Display Time: 3x
Trail Step Size: 1
Trajectory Topic: /display_planned_path
Use Sim Time: false
Planning Metrics:
Payload: 1
Show Joint Torques: false
Show Manipulability: false
Show Manipulability Index: false
Show Weight Limit: false
TextHeight: 0.07999999821186066
Planning Request:
Colliding Link Color: 255; 0; 0
Goal State Alpha: 1
Goal State Color: 250; 128; 0
Interactive Marker Size: 0
Joint Violation Color: 255; 0; 255
Planning Group: iiwa_arm
Query Goal State: true
Query Start State: false
Show Workspace: false
Start State Alpha: 1
Start State Color: 0; 255; 0
Planning Scene Topic: /monitored_planning_scene
Robot Description: robot_description
Scene Geometry:
Scene Alpha: 0.8999999761581421
Scene Color: 50; 230; 50
Scene Display Time: 0.009999999776482582
Show Scene Geometry: true
Voxel Coloring: Z-Axis
Voxel Rendering: Occupied Voxels
Scene Robot:
Attached Body Color: 150; 50; 150
Links:
All Links Enabled: true
Expand Joint Details: false
Expand Link Details: false
Expand Tree: false
Link Tree Style: Links in Alphabetic Order
base_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
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
link_ee:
Alpha: 1
Show Axes: false
Show Trail: false
world:
Alpha: 1
Show Axes: false
Show Trail: false
Robot Alpha: 1
Show Robot Collision: false
Show Robot Visual: true
Value: true
Velocity_Scaling_Factor: 0.1
Enabled: true
Global Options:
Background Color: 48; 48; 48
Fixed Frame: world
Frame Rate: 30
Name: root
Tools:
- Class: rviz_default_plugins/Interact
Hide Inactive Objects: true
- Class: rviz_default_plugins/MoveCamera
- Class: rviz_default_plugins/Select
- Class: rviz_default_plugins/FocusCamera
- Class: rviz_default_plugins/Measure
Line color: 128; 128; 0
- Class: rviz_default_plugins/SetInitialPose
Covariance x: 0.25
Covariance y: 0.25
Covariance yaw: 0.06853891909122467
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /initialpose
- Class: rviz_default_plugins/SetGoal
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /goal_pose
- Class: rviz_default_plugins/PublishPoint
Single click: true
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /clicked_point
Transformation:
Current:
Class: rviz_default_plugins/TF
Value: true
Views:
Current:
Class: rviz_default_plugins/Orbit
Distance: 3.753772020339966
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
Near Clip Distance: 0.009999999776482582
Pitch: 0.6753981113433838
Target Frame: <Fixed Frame>
Value: Orbit (rviz)
Yaw: 5.888577938079834
Saved: ~
Window Geometry:
"":
collapsed: false
" - Trajectory Slider":
collapsed: false
Displays:
collapsed: false
Height: 846
Hide Left Dock: false
Hide Right Dock: false
QMainWindow State: 000000ff00000000fd0000000400000000000001c1000002b2fc020000000afb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003c00000130000000c800fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb000000280020002d0020005400720061006a006500630074006f0072007900200053006c00690064006500720000000000ffffffff0000004000fffffffbffffffff01000001720000017c0000017100ffffff000000010000010f000002b2fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003c000002b2000000a200fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b00000003efc0100000002fb0000000800540069006d00650100000000000004b00000023200fffffffb0000000800540069006d00650100000000000004500000000000000000000001d4000002b200000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: false
Width: 1200
X: 414
Y: 160
+55 -169
View File
@@ -15,45 +15,22 @@ from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from moveit_configs_utils import MoveItConfigsBuilder
from iiwa_bringup.utils import converter
PACKAGE = "iiwa_bringup"
DESCRIPTION_PKG = "iiwa_description"
def _arg(name: str, default, desc: str):
"""Short helper to declare a launch argument."""
return DeclareLaunchArgument(name=name, default_value=default, description=desc)
def _share_file(pkg_arg_name: str, *relpath: str):
"""Join <share>/<relpath...> where <share> is FindPackageShare(LaunchConfiguration(pkg_arg_name))."""
return PathJoinSubstitution([FindPackageShare(LaunchConfiguration(pkg_arg_name)), *relpath])
from iiwa_utils import converter, setting_loader
def _runtime_setup(context, *args, **kwatgs):
setup = []
robot_name = LaunchConfiguration("robot_name").perform(context)
world_path = LaunchConfiguration("world").perform(context)
transform = LaunchConfiguration("transform").perform(context)
rotation = LaunchConfiguration("rotation").perform(context)
timer = LaunchConfiguration("controller_timer").perform(context)
xacro_file = LaunchConfiguration("xacro_file").perform(context)
srdf_file = LaunchConfiguration("srdf_file").perform(context)
# ros2_controllers_file = LaunchConfiguration("controller").perform(context)
initial_positions_file = LaunchConfiguration("initial_positions_file").perform(context)
kinematics_yaml = LaunchConfiguration("kinematics_yaml").perform(context)
joint_limits_yaml = LaunchConfiguration("joint_limits_yaml").perform(context)
pilz_limits_yaml = LaunchConfiguration("pilz_limits_yaml").perform(context)
moveit_controllers_yaml = LaunchConfiguration("moveit_controllers_yaml").perform(context)
settings = setting_loader.build_settings(
settings_path=LaunchConfiguration("setting").perform(context), check_files=True
)
robot_description = converter.load_robot_description(
model_path=xacro_file, robot_name=robot_name
model_path=settings.digital_twin.description,
robot_name=settings.robot.name,
xacro_args={
"initial_positions_file": settings.controller.moveit.initial_positions
},
)
rsp_node = Node(
@@ -61,15 +38,14 @@ def _runtime_setup(context, *args, **kwatgs):
executable="robot_state_publisher",
name="robot_state_publisher",
output="screen",
parameters=[{"robot_description": robot_description,
"use_sim_time": False}],
parameters=[{"robot_description": robot_description, "use_sim_time": False}],
)
webots_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution(
[
FindPackageShare(PACKAGE),
FindPackageShare("iiwa_bringup"),
"launch",
"supported",
"webots_spawn.launch.py",
@@ -77,26 +53,31 @@ def _runtime_setup(context, *args, **kwatgs):
)
),
launch_arguments={
"robot_name": robot_name,
"xacro_file": xacro_file,
"world": world_path,
"transform": transform,
"rotation": rotation,
"controller_timer": timer,
"robot_name": str(settings.robot.name),
"description": str(settings.digital_twin.description),
"world": str(settings.digital_twin.webots.world),
"transform": str(settings.digital_twin.webots.transform),
"rotation": str(settings.digital_twin.webots.rotation),
"controller_timer": str(settings.digital_twin.webots.controller_timer),
"controller": str(settings.controller.controller_path),
"initial_positions_file": str(settings.controller.moveit.initial_positions),
}.items(),
)
moveit_configs = (
MoveItConfigsBuilder("iiwa7", package_name=LaunchConfiguration("config_pkg").perform(context))
.robot_description(file_path=xacro_file, mappings={
"initial_positions_file": initial_positions_file,
})
.robot_description_semantic(file_path=srdf_file)
.robot_description_kinematics(file_path=kinematics_yaml)
.joint_limits(file_path=joint_limits_yaml)
.pilz_cartesian_limits(file_path=pilz_limits_yaml)
.trajectory_execution(file_path=moveit_controllers_yaml)
.moveit_cpp(file_path="/home/daniel/dev/ros2_iiwa7/src/iiwa_bringup/config/motion_planing.yaml") # TODO: сделать подстановочным значением
MoveItConfigsBuilder("iiwa7", package_name="iiwa_config")
.robot_description(
file_path=settings.digital_twin.description,
mappings={
"initial_positions_file": settings.controller.moveit.initial_positions
},
)
.robot_description_semantic(file_path=settings.controller.moveit.srdf)
.robot_description_kinematics(file_path=settings.controller.moveit.kinematics)
.joint_limits(file_path=settings.controller.moveit.joint_limits)
.pilz_cartesian_limits(file_path=settings.controller.moveit.pilz_limits)
.trajectory_execution(file_path=settings.controller.moveit.moveit_controllers)
.moveit_cpp(file_path=settings.controller.moveit.moveit_cpp)
.to_moveit_configs()
)
@@ -106,29 +87,25 @@ def _runtime_setup(context, *args, **kwatgs):
output="screen",
parameters=[
moveit_configs.to_dict(),
robot_description,
{"robot_description": robot_description},
],
)
# TODO: не забудь поменять правильное название и имя пакета
moveit_py_node = Node(
name="moveit_py",
package="iiwa_object_spawner",
package="iiwa_utils",
executable="motion_planning_test",
output="both",
parameters=[moveit_configs.to_dict()],
)
rviz_config = PathJoinSubstitution(
[FindPackageShare(PACKAGE), "config", "rviz_iiwa.rviz"]
)
rviz_launch = Node(
condition=IfCondition(LaunchConfiguration("rviz")),
package="rviz2",
executable="rviz2",
name="rviz2",
arguments=["-d", rviz_config],
arguments=["-d", settings.digital_twin.rviz.config],
output="log",
parameters=[
moveit_configs.robot_description,
@@ -140,133 +117,42 @@ def _runtime_setup(context, *args, **kwatgs):
)
shutdown_on_rviz_exit = RegisterEventHandler(
OnProcessExit(target_action=rviz_launch,
on_exit=[EmitEvent(event=Shutdown())])
OnProcessExit(target_action=rviz_launch, on_exit=[EmitEvent(event=Shutdown())])
)
setup += [rsp_node,
webots_launch,
move_group,
moveit_py_node,
rviz_launch,
shutdown_on_rviz_exit
]
setup += [
rsp_node,
webots_launch,
move_group,
moveit_py_node,
rviz_launch,
shutdown_on_rviz_exit,
]
return setup
def generate_launch_description():
# Объявление аргументов командной строки
declare_description_pkg = _arg(
"description_pkg",
DESCRIPTION_PKG,
"Package containing URDF/Xacro (and optionally SRDF/worlds).",
)
declare_config_pkg = _arg(
"config_pkg",
PACKAGE,
"Package containing MoveIt/ros2_control config YAML files (config/*).",
declare_rviz = DeclareLaunchArgument(
name="rviz",
default_value="0",
description="If true|1|yes then launch RViz/MoveIt branch (instead of controllers branch)",
)
declare_robot_name = _arg(
"robot_name",
"iiwa7",
"Robot name (used for TF and naming).",
declacre_setting = DeclareLaunchArgument(
name="setting",
default_value=PathJoinSubstitution(
[FindPackageShare("iiwa_config"), "config", "setting.yaml"]
),
description="Absolute path to settings file",
)
declare_world = _arg(
"world",
_share_file("description_pkg", "worlds", "iiwa.wbt"),
"Path to Webots world (.wbt).",
)
declare_controller = _arg(
"controller",
_share_file("config_pkg", "config", "iiwa_controller.yaml"),
"Controllers YAML (spawner/controller_manager).",
)
declare_transform = _arg(
"transform",
"-0.25 0 0.79",
"Spawn translation in Webots (x y z).",
)
declare_rotation = _arg(
"rotation",
"0 0 1 0",
"Spawn rotation axis-angle in Webots.",
)
declare_rviz = _arg(
"rviz",
"0",
"If true|1|yes then launch RViz/MoveIt branch (instead of controllers branch).",
)
declare_controller_timer = _arg(
"controller_timer",
"50",
"Timeout (seconds) for controller_manager spawners.",
)
# URDF/SRDF
declare_xacro_file = _arg(
"xacro_file",
_share_file("description_pkg", "urdf", "iiwa7.urdf.xacro"),
"Xacro used by MoveIt robot_description.",
)
declare_srdf_file = _arg(
"srdf_file",
_share_file("config_pkg", "config", "iiwa7.srdf"),
"SRDF path.",
)
# YAML конфиги
declare_initial_positions = _arg(
"initial_positions_file",
_share_file("config_pkg", "config", "initial_positions.yaml"),
"initial_positions.yaml passed into xacro arg initial_positions_file.",
)
declare_kinematics_yaml = _arg(
"kinematics_yaml",
_share_file("config_pkg", "config", "kinematics.yaml"),
"MoveIt kinematics.yaml",
)
declare_joint_limits_yaml = _arg(
"joint_limits_yaml",
_share_file("config_pkg", "config", "joint_limits.yaml"),
"MoveIt joint_limits.yaml",
)
declare_pilz_limits_yaml = _arg(
"pilz_limits_yaml",
_share_file("config_pkg", "config", "pilz_cartesian_limits.yaml"),
"Pilz cartesian limits yaml.",
)
declare_moveit_controllers_yaml = _arg(
"moveit_controllers_yaml",
_share_file("config_pkg", "config", "moveit_controllers.yaml"),
"MoveIt controllers (trajectory_execution / simple_controller_manager).",
)
runtime_setup = OpaqueFunction(function=_runtime_setup)
return LaunchDescription(
[
declare_description_pkg,
declare_config_pkg,
declare_robot_name,
declare_world,
declare_controller,
declare_transform,
declare_rotation,
declare_rviz,
declare_controller_timer,
declare_xacro_file,
declare_srdf_file,
declare_initial_positions,
declare_kinematics_yaml,
declare_joint_limits_yaml,
declare_pilz_limits_yaml,
declare_moveit_controllers_yaml,
declacre_setting,
runtime_setup,
]
)
@@ -4,23 +4,26 @@ from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from webots_ros2_driver.urdf_spawner import URDFSpawner
from iiwa_bringup.utils import converter
from iiwa_utils import converter
def _setup_controllers(context, *args, **kwargs):
xacro_file = LaunchConfiguration("xacro_file").perform(context)
robot_name = LaunchConfiguration("robot_name").perform(context)
description = LaunchConfiguration("description").perform(context)
transform = LaunchConfiguration("transform").perform(context)
rotation = LaunchConfiguration("rotation").perform(context)
timer = LaunchConfiguration("controller_timer").perform(context)
robot_description = converter.load_robot_description(
model_path=xacro_file, robot_name=robot_name
controller_timer = LaunchConfiguration("controller_timer").perform(context)
initial_positions_file = LaunchConfiguration("initial_positions_file").perform(
context
)
tmo = ["--controller-manager-timeout", str(timer)]
robot_description = converter.load_robot_description(
model_path=description,
robot_name=robot_name,
xacro_args={"initial_positions_file": initial_positions_file},
)
tmo = ["--controller-manager-timeout", str(controller_timer)]
jsb = Node(
package="controller_manager",
@@ -16,24 +16,28 @@ from webots_ros2_driver.webots_launcher import WebotsLauncher
def _spawn_setup(context, *args, **kwargs):
xacro_file = LaunchConfiguration("xacro_file").perform(context)
robot_name = LaunchConfiguration("robot_name").perform(context)
world_path = LaunchConfiguration("world").perform(context)
description = LaunchConfiguration("description").perform(context)
world = LaunchConfiguration("world").perform(context)
transform = LaunchConfiguration("transform").perform(context)
rotation = LaunchConfiguration("rotation").perform(context)
timer = LaunchConfiguration("controller_timer").perform(context)
controller_timer = LaunchConfiguration("controller_timer").perform(context)
controller = LaunchConfiguration("controller").perform(context)
initial_positions_file = LaunchConfiguration("initial_positions_file").perform(
context
)
webots = WebotsLauncher(world=world_path, ros2_supervisor=True)
webots = WebotsLauncher(world=world, ros2_supervisor=True)
driver = WebotsController(
robot_name=robot_name,
parameters=[
{
"robot_description": xacro_file,
"robot_description": description,
"use_sim_time": False,
"set_robot_state_publisher": False,
},
LaunchConfiguration("controller").perform(context),
controller,
],
respawn=True,
)
@@ -51,10 +55,11 @@ def _spawn_setup(context, *args, **kwargs):
),
launch_arguments={
"robot_name": robot_name,
"xacro_file": xacro_file,
"description": description,
"transform": transform,
"rotation": rotation,
"controller_timer": timer,
"controller_timer": controller_timer,
"initial_positions_file": initial_positions_file,
}.items(),
)
+9 -9
View File
@@ -2,18 +2,18 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>iiwa_bringup</name>
<version>0.0.1</version>
<description>TODO: Package description</description>
<maintainer email="grabardm@ml-dev.ru">Grabar Daniil</maintainer>
<version>0.2.0</version>
<description>Файлы запуска проектов</description>
<maintainer email="grabardm@ml-dev.ru">daniel</maintainer>
<license>Apache-2.0</license>
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>ament_xmllint</test_depend>
<test_depend>python3-pytest</test_depend>
<buildtool_depend>ament_cmake</buildtool_depend>
<exec_depend>iiwa_utils</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<export>
<build_type>ament_python</build_type>
<build_type>ament_cmake</build_type>
</export>
</package>
-4
View File
@@ -1,4 +0,0 @@
[develop]
script_dir=$base/lib/iiwa_bringup
[install]
install_scripts=$base/lib/iiwa_bringup
-58
View File
@@ -1,58 +0,0 @@
import os
from setuptools import setup
package_name = "iiwa_bringup"
# Собираем список пакетов: основной + вложенные (если они есть).
packages = [package_name]
# Если есть подпапка utils с __init__.py — зарегистрируем её как iiwa_bringup.utils
if os.path.isdir("utils") and os.path.isfile(os.path.join("utils", "__init__.py")):
packages.append(f"{package_name}.utils")
# Соответствие имени пакета -> директория на диске.
# iiwa_bringup -> текущая папка '.'
# iiwa_bringup.utils -> ./utils
package_dir = {
package_name: ".",
}
if f"{package_name}.utils" in packages:
package_dir[f"{package_name}.utils"] = os.path.join(".", "utils")
def data_files_from_tree(src_dir: str, dst_root: str) -> list:
entries = []
if not os.path.isdir(src_dir):
return entries
EXCLUDE_DIRS = {".git", "__pycache__", ".pytest_cache", ".idea"}
EXCLUDES = {".DS_Store", "Thumbs.db"}
for root, dirs, files in os.walk(src_dir):
dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS]
file_list = [os.path.join(root, f) for f in files if f not in EXCLUDES]
if not file_list:
continue
rel = os.path.relpath(root, src_dir)
dst_dir = os.path.join(dst_root, rel) if rel != "." else dst_root
entries.append((dst_dir, file_list))
return entries
data_files = [(f"share/{package_name}", ["package.xml"])]
data_files += data_files_from_tree("launch", f"share/{package_name}/launch")
data_files += data_files_from_tree("config", f"share/{package_name}/config")
data_files += data_files_from_tree("resource", f"share/{package_name}/resource")
setup(
name=package_name,
version="0.0.1",
packages=packages,
package_dir=package_dir,
include_package_data=True,
data_files=data_files,
install_requires=["setuptools"],
zip_safe=False,
maintainer="Grabar Daniil",
maintainer_email="grabardm@ml-dev.ru",
description="iiwa bringup package",
license="Apache-2.0",
)
View File
-12
View File
@@ -1,12 +0,0 @@
import xacro
from pathlib import Path
def load_robot_description(model_path: Path, robot_name: str) -> str:
suffix = Path(model_path).suffix.lower()
if suffix == ".xacro":
return xacro.process_file(model_path, mappings={'name': str(robot_name)}).toxml()
elif suffix == ".urdf":
return Path(model_path).read_text(encoding="utf-8")
else:
raise FileNotFoundError("Supported file formats: xacro/urdf")