[moveit_robot_state.robot_state] appears when using MoveIt2 in ROS2: No kinematics solver instantiated for group

1. Phenomenon


When I try to call setApproximateJointValueTarget(target_pose) in my standalone Qt program
, it returns false and the error message appears:
No kinematics solver instantiated for group 'my_group'
Insert image description here

2. Find information

Looking here and there, looking here and there. Found a useful information.
This question was also asked on MoveIt2’s issues, and the developer also answered:
[ hello_moveit does not work when demo.launch.py ​​is modified to include use of occupancy map monitor plugin #1843 ]
Insert image description here

3.Analysis

3.1.Transfer of parameters

According to henningkayser 's answer to this question, the main reason is that the configuration of moveit needs to be passed to the MGI (moveit::planning_interface::MoveGroupInterface) node so that MGI can use the parameters through the node.
The moveit related parameters are passed to the starting node through the parameters of the Node node in the from launch_ros.actions import Node: [move_group_interface_tutorial.launch.py]
Insert image description here The way to pass the parameters of the launch_ros.actions.Node node is to save the parameter file in /tmp directory, and then pass the file path to our program as argv, and rclcpp::init(argc, argv); initializes the parameters through argc and argv.

3.2. Test of parameter passing

This can be verified by writing a node yourself:
Code reference: [2. RCLCPP implementation of parameters]
First create a package example_parameters_rclcpp, which has a parameters_basic node. In its main function, print out argc and argv
Insert image description hereand then create it. A package param_startup, this does not need to create a node, but you need to create a launch file. This launch file uses launch_ros.actions.Node to start the previous parameters_basic and passes parameters to it.
Code reference: [2.1 Three methods of writing launch files]
Insert image description here Execute it and see what the results are:
Insert image description hereyou can see that a lot of parameters are passed Come in, mainly look at –params-file. But let’s print /tmp/launch_params_jzq3dg9_ to take a look:
Insert image description here
you can see that it is one of the parameters we are trying to pass in through launch_ros.actions.Node. So, at this time, does our parameters_basic node already have these parameters? But it is negative:
Insert image description here
because we have to do a very important thing, let the node automatically load the parameters passed in: automatically_declare_parameters_from_overrides

  rclcpp::NodeOptions node_options;
  node_options.automatically_declare_parameters_from_overrides(true);

  /*创建对应节点的共享指针对象*/
  auto node = std::make_shared<ParametersBasicNode>("parameters_basic", node_options);

Insert image description hereNow we have the parameters we passed in.
Insert image description here

4.Solution

4.1. Pass parameters in the launch file and start your own program

We can also use launch_ros.actions.Node to start our Qt program in the launch file that starts moveit and rviz, thereby passing the necessary parameters to our own program.

    ld.add_action(
        Node(
            executable='/home/yong/Desktop/QtPrj/build-myArmTest-Desktop_Qt_5_15_2_GCC_64bit-Profile/myArmTest',
            parameters=params,
        )
    )

Insert image description hereRemember to add automatically_declare_parameters_from_overrides to the nodes in your own program

    // 构建带参数的节点
    // https://github.com/ros-planning/moveit2/issues/1843
    rclcpp::NodeOptions node_options;
    node_options.automatically_declare_parameters_from_overrides(true);
    MGINode = std::make_shared<rclcpp::Node>(
        "my_arm_node", node_options);
    QtConcurrent::run([=](){
    
    
        rclcpp::spin(MGINode); // 阻塞其
    });

After testing, there is no problem:
the red words below are the content output by the independently started Qt program. You can see that No kinematics plugins, No kinematics solver and other errors are reported; while the output of the console above is to start Qt through launch_ros.actions.Node There are no similar errors in the output of the program.
Insert image description here

4.2. Read configuration through file

Passing parameters in the launch file and starting your own program is more convenient in the release and running stages, but it is not convenient in the code writing and debugging stages.
Since the parameters have been saved in the /tmp folder (will not be deleted until the next boot), we can save the passed argc and argv into a txt file through a package node, and then our Qt program can Go read this txt file.
In this way, as long as we first start the moveit related launch file, generate (update) the above txt file, and then start our Qt program, we can also solve this parameter-related problem.

Guess you like

Origin blog.csdn.net/joyopirate/article/details/130947496