moveit2_tutorials
moveit2_tutorials copied to clipboard
move_group error. ros2
Your environment
- ROS Distro: [Humble]
- OS Version: Ubuntu 22.04
Expected behaviour
An error occurs when sending a message to the action server. A move_group object is created in the action server to find out the current state of the robot. Below is the code.
group->clearPoseTarget();
group->clearPoseTargets();
group->clearPathConstraints();
group->clearTrajectoryConstraints();
group->setEndEffectorLink(goal->ee_link);
moveit::core::RobotStatePtr robot_state_ptr = group->getCurrentState(); // <-- this is where the error occurs
RCLCPP_ERROR(rclcpp::get_logger("MoveToPose"), " e.what()");
if (!robot_state_ptr) {
throw std::runtime_error(
"Cant get current state in moveit, check time syncro");
}
moveit::core::RobotState start_state(*robot_state_ptr);
group->setStartState(start_state);
The error looks like this:
"Didn't received robot state (joint angles) with recent timestamp within 1 seconds. Check clock synchronization if your are running ROS across multiple machines"
Hi,
Did you manage to solve this? :) Thanks!
Someone solve it? I have the same problem.
Hi, yes I did.
In this case it is related probably to the one of two things:
- wrong node initialization
-
use_sim_time
parameter.
In order to solve this, ensure that use_sim_time
parameter is set to true
for all nodes that currently running.
And besides that, make sure that you initialize node correctly as described here.
I am having the same error but when using getCurrentJointValues()
(which internally makes calls to getCurrentState
) and I followed the described issue that @fzoric8 is referring to. This did not fix the problem for me. Also use_sim_time
should only be set to true
if using a simulation. I am getting this error on hardware. However, out of curiosity I tried setting use_sim_time
to true and it allowed getCurrentJointValues()
to work as expected. However, the joint values it returned were older joint angles - not the most up to date joint angles. So setting use_sim_time
is not a workaround that can be used for the time being on hardware. Anyone else have any ideas with regards to this issue?
Hi @nilp-dromeda ,
Are you sure you're initializing your class in a right way. You can see how I initialized it here.
Because my issue was related more to the wrong initialization of the interface than usage of the use_sim_time
.
I don't know if your PC's are decoupled (one runs arm and one runs MoveIt2!, then you need to make sure that PCs have the same time - also known as clock synchronization). If yes, make sure to synchronize clocks of those two PCs, you can use chrony or NTP to do so.
Hi @fzoric8,
I just tried the changes you had on your branch and it still doesn't work. Running on the same PC so no need to sync clocks. Will try and investigate further.