Refactor URDF and launch files for iiwa robot
- Updated gripper macros in gripper_macros.xacro to simplify parameters and add Gazebo support. - Removed unused mesh property in gripper_meshes.xacro. - Enhanced iiwa7 digital and FRI URDF files with simulation arguments and improved controller setup. - Added new launch files for Gazebo simulation and universal launch configuration. - Implemented YAML parameter wrapping for ROS2 in converter.py. - Introduced a new gz_bridge.yaml configuration for Gazebo to ROS2 topic mapping. - Cleaned up setting_loader.py and added necessary imports.
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import OpaqueFunction
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch.event_handlers import OnProcessExit
|
||||
from launch.actions import RegisterEventHandler
|
||||
from launch_ros.actions import Node
|
||||
|
||||
from iiwa_utils import converter
|
||||
|
||||
|
||||
def _setup_controllers(context, *args, **kwargs):
|
||||
robot_name = LaunchConfiguration("robot_name").perform(context)
|
||||
description = LaunchConfiguration("description").perform(context)
|
||||
initial_positions_file = LaunchConfiguration("initial_positions_file").perform(context)
|
||||
controller_path = LaunchConfiguration("controller_path").perform(context)
|
||||
simulate = LaunchConfiguration("simulate").perform(context).lower() in ("true", "1", "yes")
|
||||
|
||||
robot_description = converter.load_robot_description(
|
||||
model_path=description,
|
||||
robot_name=robot_name,
|
||||
xacro_args={"initial_positions_file": initial_positions_file},
|
||||
)
|
||||
|
||||
# СИМУЛЯЦИЯ (Gazebo)
|
||||
if simulate:
|
||||
jsb = Node(
|
||||
package="controller_manager",
|
||||
executable="spawner",
|
||||
output="screen",
|
||||
arguments=[
|
||||
"joint_state_broadcaster",
|
||||
"--controller-manager", "/controller_manager",
|
||||
"--controller-manager-timeout", "30",
|
||||
],
|
||||
parameters=[{"use_sim_time": True}],
|
||||
)
|
||||
|
||||
jtc = Node(
|
||||
package="controller_manager",
|
||||
executable="spawner",
|
||||
output="screen",
|
||||
arguments=[
|
||||
"iiwa_arm_controller",
|
||||
"--controller-manager", "/controller_manager",
|
||||
"--controller-manager-timeout", "30",
|
||||
],
|
||||
parameters=[{"use_sim_time": True}],
|
||||
)
|
||||
|
||||
jtc_after_jsb = RegisterEventHandler(
|
||||
OnProcessExit(
|
||||
target_action=jsb,
|
||||
on_exit=[jtc],
|
||||
)
|
||||
)
|
||||
|
||||
return [jsb, jtc_after_jsb]
|
||||
|
||||
# РЕАЛЬНЫЙ РОБОТ (FRI)
|
||||
else:
|
||||
ros2_control_node = Node(
|
||||
package="controller_manager",
|
||||
executable="ros2_control_node",
|
||||
output="screen",
|
||||
parameters=[
|
||||
{"robot_description": robot_description},
|
||||
controller_path,
|
||||
],
|
||||
)
|
||||
|
||||
jsb = Node(
|
||||
package="controller_manager",
|
||||
executable="spawner",
|
||||
output="screen",
|
||||
arguments=[
|
||||
"joint_state_broadcaster",
|
||||
"--controller-manager", "/controller_manager",
|
||||
],
|
||||
)
|
||||
|
||||
jtc = Node(
|
||||
package="controller_manager",
|
||||
executable="spawner",
|
||||
output="screen",
|
||||
arguments=[
|
||||
"iiwa_arm_controller",
|
||||
"--controller-manager", "/controller_manager",
|
||||
],
|
||||
)
|
||||
|
||||
torque_controller = Node(
|
||||
package="controller_manager",
|
||||
executable="spawner",
|
||||
output="screen",
|
||||
arguments=[
|
||||
"forward_torque_controller",
|
||||
"--controller-manager", "/controller_manager",
|
||||
"--inactive",
|
||||
],
|
||||
)
|
||||
|
||||
jtc_after_jsb = RegisterEventHandler(
|
||||
OnProcessExit(
|
||||
target_action=jsb,
|
||||
on_exit=[jtc, torque_controller],
|
||||
)
|
||||
)
|
||||
|
||||
return [
|
||||
ros2_control_node,
|
||||
jsb,
|
||||
jtc_after_jsb,
|
||||
]
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
return LaunchDescription([OpaqueFunction(function=_setup_controllers)])
|
||||
@@ -0,0 +1,63 @@
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import (
|
||||
IncludeLaunchDescription,
|
||||
OpaqueFunction,
|
||||
)
|
||||
from launch_ros.actions import Node
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
|
||||
from launch_ros.substitutions import FindPackageShare
|
||||
|
||||
|
||||
def _spawn_setup(context, *args, **kwargs):
|
||||
robot_name = LaunchConfiguration("robot_name").perform(context)
|
||||
world = LaunchConfiguration("world").perform(context)
|
||||
gazebo_config = LaunchConfiguration("gazebo_config").perform(context)
|
||||
simulate = LaunchConfiguration("simulate").perform(context).lower() in ("true", "1", "yes")
|
||||
# transform = LaunchConfiguration("transform").perform(context)
|
||||
|
||||
gazebo = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
PathJoinSubstitution(
|
||||
[
|
||||
FindPackageShare("ros_gz_sim"),
|
||||
"launch",
|
||||
"gz_sim.launch.py",
|
||||
]
|
||||
)
|
||||
),
|
||||
launch_arguments={
|
||||
"gz_args": f"-r {world}",
|
||||
"on_exit_shutdown": "true",
|
||||
}.items(),
|
||||
)
|
||||
|
||||
# TODO: добавить аргументы для transform и rotation
|
||||
spawn_robot = Node(
|
||||
package="ros_gz_sim",
|
||||
executable="create",
|
||||
name="spawn_iiwa7",
|
||||
output="screen",
|
||||
arguments=[
|
||||
"-topic", "/robot_description",
|
||||
"-name", robot_name,
|
||||
"-z", "0.0"
|
||||
],
|
||||
)
|
||||
|
||||
gz_bridge = Node(
|
||||
package="ros_gz_bridge",
|
||||
executable="parameter_bridge",
|
||||
name="gz_bridge",
|
||||
output="screen",
|
||||
parameters=[{
|
||||
"config_file": gazebo_config,
|
||||
"use_sim_time": simulate
|
||||
}],
|
||||
)
|
||||
|
||||
return [gazebo, spawn_robot, gz_bridge]
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
return LaunchDescription([OpaqueFunction(function=_spawn_setup)])
|
||||
@@ -33,7 +33,6 @@ def _setup_controllers(context, *args, **kwargs):
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
joint_state_broadcaster_spawner = Node(
|
||||
package="controller_manager",
|
||||
executable="spawner",
|
||||
|
||||
Reference in New Issue
Block a user