Failed to fetch current robot state
If you use the demo.launch file generated by the moveit assistant to start the robotic arm, it should be that the spin function is missing from other node codes written by you that are running, because the getCurrentPose function depends on spin, and AsyncSpinner can also be used. See the following link for details : https://answers.ros.org/question/302283/failed-to-fetch-current-robot-state/
The code stopped halfway through execution
Some functions rely on the spin function, just add it. Refer to the previous article
For testing purposes, I did not write a loop or use a spin function. I used moveit to move the robotic arm to a predefined posture. After this line of code was executed, the terminal stopped moving, neither ending the program nor continuing to output information. Just add spin.
[startArm-5] process has died [pid 14527, exit code -6,
Because I want to customize a function to operate the robotic arm, and operating the robotic arm requires a planning group MoveGroupInterface object. Passing the object as a parameter into the function feels a bit performance-intensive, so I moved the planning group object outside the main function as a global variable, and this happened Report an error.
moveit::planning_interface::MoveGroupInterface arm("arm_PG");
Reason : Instantiating the planning group object requires instantiating the NodeHandle object first, but the NodeHandle object is instantiated within the main function. The NodeHandle needs to be defined after the init function, and the init function needs to pass in the argc and argv of the main function. This results in the inability to simply move the instantiation of the planning group MoveGroupInterface directly out as a global variable.
Solution : You can define the global planning group pointer as follows
#include "" // 一堆include
moveit::planning_interface::MoveGroupInterface *arm; // 全局指针
int main(int argc, char *argv[])
{
ros::init(argc, argv, "test_node");
ros::NodeHandle nh;
arm = new moveit::planning_interface::MoveGroupInterface("arm_PG"); // 给指针填上东西
// 获取末端名称
std::string endEffector_link = arm->getEndEffectorLink(); // .调用需要改为->调用
}
Reference https://answers.ros.org/question/350643/node-crashes-with-ros-does-not-seem-to-be-running/