Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about singularity #216

Open
Enzo-let opened this issue Oct 26, 2024 · 1 comment
Open

about singularity #216

Enzo-let opened this issue Oct 26, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Enzo-let
Copy link

I appreciate you well. I have a question about running the lbr_demo/lbr_moveit, which is i find that the initial position of the robot is singularity, so i need to chang the initial position in the simulation. What i do is to change the lbr_movit_config with setup_assistant, but when i run the rviz.launch.py, the robot show like below. So i wanna know which files i need to change.I guess the mock.launch, and i change it like this :
`
from launch import LaunchDescription
from launch.actions import RegisterEventHandler, DeclareLaunchArgument
from launch.event_handlers import OnProcessStart
from launch.substitutions import LaunchConfiguration
from lbr_bringup.description import LBRDescriptionMixin
from lbr_bringup.ros2_control import LBRROS2ControlMixin

def generate_launch_description() -> LaunchDescription:
ld = LaunchDescription()

# Launch arguments
ld.add_action(LBRDescriptionMixin.arg_model())
ld.add_action(LBRDescriptionMixin.arg_robot_name())
ld.add_action(LBRROS2ControlMixin.arg_ctrl_cfg_pkg())
ld.add_action(LBRROS2ControlMixin.arg_ctrl_cfg())
ld.add_action(LBRROS2ControlMixin.arg_ctrl())

# Define initial positions for KUKA robot joints
ld.add_action(DeclareLaunchArgument(
    'joint_a1',
    default_value='0.0',
    description='Initial position for joint a1'
))
ld.add_action(DeclareLaunchArgument(
    'joint_a2',
    default_value='-0.7854',
    description='Initial position for joint a2'
))
ld.add_action(DeclareLaunchArgument(
    'joint_a3',
    default_value='0.0',
    description='Initial position for joint a3'
))
ld.add_action(DeclareLaunchArgument(
    'joint_a4',
    default_value='1.3962',
    description='Initial position for joint a4'
))
ld.add_action(DeclareLaunchArgument(
    'joint_a5',
    default_value='0.0',
    description='Initial position for joint a5'
))
ld.add_action(DeclareLaunchArgument(
    'joint_a6',
    default_value='0.6109',
    description='Initial position for joint a6'
))
ld.add_action(DeclareLaunchArgument(
    'joint_a7',
    default_value='0.0',
    description='Initial position for joint a7'
))

# Robot description
robot_description = LBRDescriptionMixin.param_robot_description(mode="mock")

# Robot state publisher
robot_state_publisher = LBRROS2ControlMixin.node_robot_state_publisher(
    robot_description=robot_description, use_sim_time=False
)
ld.add_action(robot_state_publisher)

# ROS 2 control node
ros2_control_node = LBRROS2ControlMixin.node_ros2_control(use_sim_time=False)
ld.add_action(ros2_control_node)

# Joint state broadcaster and controller on ROS 2 control node start
joint_state_broadcaster = LBRROS2ControlMixin.node_controller_spawner(
    controller="joint_state_broadcaster"
)
controller = LBRROS2ControlMixin.node_controller_spawner(
    controller=LaunchConfiguration("ctrl")
)

# Event handler to start joint state broadcaster and controller
controller_event_handler = RegisterEventHandler(
    OnProcessStart(
        target_action=ros2_control_node,
        on_start=[
            joint_state_broadcaster,
            controller,
        ],
    )
)
ld.add_action(controller_event_handler)


return ld

`
3dd32838ccc21afa00de33d479296de

@mhubii
Copy link
Member

mhubii commented Oct 27, 2024

hi @Enzo-let, this error shows due to a missing transform. Can you try to add a static transform publisher a la

from launch.substitutions import LaunchConfiguration, PathJoinSubstitution

# static transform world -> robot_name/world
ld.add_action(
    LBRDescriptionMixin.node_static_tf(
        tf=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
        parent="world",
        child=PathJoinSubstitution([LaunchConfiguration("robot_name"), "world"]),
    )
)

This should fix your particular issue. However, from what I can see reading through ros2_control (ros-controls/gazebo_ros2_control#100), to configure an initial position, the URDF needs to be modified, i.e. here

<state_interface name="position" />

In case you wish to create a pull request to modify this behavior, may I kindly ask you to target the rolling branch? Note that in the rolling branch frame naming changed from robot_name/link_i -> robot_name_link_i

@mhubii mhubii added the enhancement New feature or request label Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants