Catch move group error
Hello folks,
When moving my robot i sometimes get errors from the Move Group. For example:
[ INFO] [1685618721.819197275]: Generating PTP trajectory...
[ERROR] [1685618721.829472804]: Inverse kinematics for pose
20
0.4
0.5 has no solution.
[ERROR] [1685618721.829598707]: No IK solution for goal pose
[ INFO] [1685618891.699098837]: Combined planning and execution request received for MoveGroup action. Forwarding to planning and execution pipeline.
[ INFO] [1685618891.699238863]: Planning attempt 1 of at most 1
[ INFO] [1685618891.699341280]: Initialized Point-to-Point Trajectory Generator.
[ INFO] [1685618891.699387198]: Generating PTP trajectory...
[ INFO] [1685618891.699897834]: Goal already reached, set one goal point explicitly.
[ERROR] [1685618891.707460618]: Can't accept new action goals. Controller is not running.
I want to catch these errors somehow and store them in a variable (so i can work with them)
How can i get my script to catch these errors?
Script which should "catch" the errors, reduced to most important function:
move_group = moveit_commander.MoveGroupCommander(group_name)
self.moveGroupCommander = move_group
self.moveGroupCommander.set_pose_target(target_pose)
did_move_succeed = self.moveGroupCommander.go(wait=True)
# If the motion failed, set action_success to False and return
if not did_move_succeed:
self.action_success = False
self._result.motion_executed = False
self._result.error = 'Motion failed due to move group. Maybe IK failed.'
print("Error: %s" % self._result.error)
self._as.set_aborted(self._result)
else:
# Calling `stop()` ensures that there is no residual movement
self.moveGroupCommander.stop()
reached_pose = self.moveGroupCommander.get_current_pose().pose
self.print_pose(reached_pose, "Reached")
self.action_success = True
self._result.motion_executed = True
self._result.error = ""
self._as.set_succeeded(self._result)
self.moveGroupCommander.clear_pose_targets()
print("POSE TO POSE MOVEMENT END\n")
But i want to catch the real error, not that fake version i made.
The launchfile that that opens another terminal displays all the errors i wish:
<!-- Launch UR10 Robot -->
<!-- Include the launch file for bringing up the UR10 robot -->
<include file="$(find ur_robot_driver)/launch/ur10_bringup.launch">
<arg name="robot_ip" value="$(arg robot_ip)"/>
<arg name="kinematics_config" value="$(find fmp_ur10_with_gripper)/calibration/ur10_calibration.yaml"/>
</include>
<!-- Motion Planning -->
<!-- Include the launch file for launching MoveIt motion planning -->
<include file="$(find fmp_ur10_moveit_config)/launch/move_group.launch">
<arg name="pipeline" value="$(arg pipeline)"/>
<arg name="robot_type" value="$(arg robot_type)"/>
<arg name="camera_type" value="$(arg camera_type)"/>
<arg name="load_env_robot_description" value="false"/>
<arg name="load_only_robot_description" value="false"/>
<arg name="load_only_robot_rmag" value="true"/>
</include>
Asked by infraviored on 2023-06-01 06:34:58 UTC
Answers
i have it.
rospy.Subscriber("/rosout", Log, self.error_handler)
def error_handler(self, data):
if data.level == Log.ERROR: # Only store error messages
current_time = rospy.get_time()
message = data.msg
# If the previous error message was less than 1 second ago, append the current message
if self.last_error_time is not None and current_time - self.last_error_time < 1:
self.error_message += "\n" + message
else:
self.error_message = message
# find "Controller is not running." in message
if message.find("Controller is not running.") != -1:
self.error_message += "\n\nPressed Play on UR Panel?"
if message.find("No IK solution for goal pose") != -1:
self.error_message += "\n\nMaybe the Pose is not reachable."
self.last_error_time = current_time
Thank you sir!
Asked by infraviored on 2023-06-05 11:04:09 UTC
Comments
Quick comment (and not an answer): the error you quote is actually not from
move_group
. It's logged by thejoint_trajectory_controller
. See here.I'd suggest to update your
ROSCONSOLE_FORMAT
to something like:'[${severity}] [${time}] [${node}]: ${message}'
so it's clear which node prints what. You could add the following to your.bashrc
(if using Bash):doesn't change your question of course, but thought I'd mention it.
Asked by gvdhoorn on 2023-06-01 07:34:34 UTC
many thanks for the hint!
So it apparently is from the move group?
Asked by infraviored on 2023-06-05 08:57:17 UTC
Your statement:
was ambiguous. I assumed you cut off your snippet after the error you were interested in (ie:
Can't accept new action goals. Controller is not running.
).But yes, the error you quote does seem to be printed by
move_group
.Asked by gvdhoorn on 2023-06-05 09:03:47 UTC
you are right! actually, it would be great to catch any ERROR and be able to forward it.
Reason is that i have a web frontend and want to inform the user why a command can not be executed.
Asked by infraviored on 2023-06-05 10:16:47 UTC
Subscribe to
rosout
?Asked by gvdhoorn on 2023-06-05 10:43:06 UTC