Skip to content

Moveit error code -27 #3667

@usmanNoor5

Description

@usmanNoor5

Description

So basically I am using ros2 humble and have moveit install on it. Working on ros for about 2.5 years so know a little bit of it. Moveit is working perfectly fine and not having problem to plan a path their is a error coming when i tried to collied with the collision object error code -27 which is not mentioned in the error code list
int32 val

overall behavior

int32 SUCCESS=1
int32 FAILURE=99999

int32 PLANNING_FAILED=-1
int32 INVALID_MOTION_PLAN=-2
int32 MOTION_PLAN_INVALIDATED_BY_ENVIRONMENT_CHANGE=-3
int32 CONTROL_FAILED=-4
int32 UNABLE_TO_AQUIRE_SENSOR_DATA=-5
int32 TIMED_OUT=-6
int32 PREEMPTED=-7

planning & kinematics request errors

int32 START_STATE_IN_COLLISION=-10
int32 START_STATE_VIOLATES_PATH_CONSTRAINTS=-11

int32 GOAL_IN_COLLISION=-12
int32 GOAL_VIOLATES_PATH_CONSTRAINTS=-13
int32 GOAL_CONSTRAINTS_VIOLATED=-14

int32 INVALID_GROUP_NAME=-15
int32 INVALID_GOAL_CONSTRAINTS=-16
int32 INVALID_ROBOT_STATE=-17
int32 INVALID_LINK_NAME=-18
int32 INVALID_OBJECT_NAME=-19

system errors

int32 FRAME_TRANSFORM_FAILURE=-21
int32 COLLISION_CHECKING_UNAVAILABLE=-22
int32 ROBOT_STATE_STALE=-23
int32 SENSOR_INFO_STALE=-24

kinematics errors

int32 NO_IK_SOLUTION=-31

Secondly when I change the arm_group name from "arm" to am it has to give me error of -15 but it giving 99999 general failure.
Can anyone help me to find out where I might be doing wrong

ROS Distro

Humble

OS and version

Ubuntu 22.04

Source or binary build?

Source

If binary, which release version?

No response

If source, which branch?

No response

Which RMW are you using?

CycloneDDS

Steps to Reproduce

I start the moveit working perfectly fine write a code
` #!/usr/bin/env python3

import rclpy
from rclpy.node import Node
from rclpy.action import ActionClient
from moveit_msgs.action import MoveGroup
from moveit_msgs.msg import MotionPlanRequest, Constraints, JointConstraint, MoveItErrorCodes
import math

class MoveItJointMover(Node):
    def __init__(self):
        super().__init__('moveit_joint_mover')
        
        # Action client for MoveGroup
        self._action_client = ActionClient(self, MoveGroup, 'move_action')
        
        self.get_logger().info("Connecting to MoveGroup Action Server...")
        if not self._action_client.wait_for_server(timeout_sec=10.0):
            self.get_logger().error("Action server not available! Is MoveIt running?")
            return
            
        self.get_logger().info("Connected to MoveIt!")

    def move_to_joints(self, joint_angles):
        goal_msg = MoveGroup.Goal()
        
        # 1. Setup Request
        request = MotionPlanRequest()
        request.group_name = "arm" # Change to your group name if different
        request.max_velocity_scaling_factor = 0.5
        request.max_acceleration_scaling_factor = 0.5

        # 2. Joint Names (Mapping your specific joints)
        joint_names = [
            'shoulder_pan_joint', 'shoulder_lift_joint', 'elbow_joint',
            'wrist_1_joint', 'wrist_2_joint', 'wrist_3_joint'
        ]

        # 3. Create Constraints
        constraints = Constraints()
        for name, angle in zip(joint_names, joint_angles):
            jc = JointConstraint()
            jc.joint_name = name
            jc.position = angle
            jc.tolerance_above = 0.01
            jc.tolerance_below = 0.01
            jc.weight = 1.0
            constraints.joint_constraints.append(jc)
        
        request.goal_constraints.append(constraints)
        goal_msg.request = request
        goal_msg.planning_options.plan_only = False # We want to EXECUTE

        self.get_logger().info(f"Sending goal to MoveIt with angles (rad): {[round(a, 3) for a in joint_angles]}")
        
        send_goal_future = self._action_client.send_goal_async(goal_msg)
        send_goal_future.add_done_callback(self.goal_response_callback)

    def goal_response_callback(self, future):
        goal_handle = future.result()
        if not goal_handle.accepted:
            self.get_logger().error("Goal rejected by MoveIt (Invalid request)")
            return

        self.get_logger().info("Goal accepted. Planning/Executing...")
        result_future = goal_handle.get_result_async()
        result_future.add_done_callback(self.get_result_callback)

    def get_result_callback(self, future):
        result = future.result().result
        error_code = result.error_code.val

        # --- ACCURATE ERROR DECODER (Based on MoveItErrorCodes.msg) ---
        self.get_logger().info(f"Received Error Code: {error_code}")
        
        # Success
        if error_code == 1:  # SUCCESS
            self.get_logger().info("✓ SUCCESS: Robot moved to the target position!")
        
        # Overall behavior
        elif error_code == 99999:  # FAILURE
            self.get_logger().error("✗ FAILURE: General failure")
        
        # Planning failures
        elif error_code == -1:  # PLANNING_FAILED
            self.get_logger().error("✗ PLANNING_FAILED: Could not find a valid path")
            self.get_logger().error("   → Try adjusting max_velocity/acceleration or check for obstacles")
            
        elif error_code == -2:  # INVALID_MOTION_PLAN
            self.get_logger().error("✗ INVALID_MOTION_PLAN: Generated plan is invalid")
            
        elif error_code == -3:  # MOTION_PLAN_INVALIDATED_BY_ENVIRONMENT_CHANGE
            self.get_logger().error("✗ MOTION_PLAN_INVALIDATED_BY_ENVIRONMENT_CHANGE: Environment changed during planning")
            
        # Execution errors
        elif error_code == -4:  # CONTROL_FAILED
            self.get_logger().error("✗ CONTROL_FAILED: Controller couldn't execute the trajectory")
            self.get_logger().error("   → Check if controllers are running: ros2 control list_controllers")
            self.get_logger().error("   → Verify controller_manager is active")
            
        elif error_code == -5:  # UNABLE_TO_AQUIRE_SENSOR_DATA
            self.get_logger().error("✗ UNABLE_TO_AQUIRE_SENSOR_DATA: Cannot get sensor information")
            
        elif error_code == -6:  # TIMED_OUT
            self.get_logger().error("✗ TIMED_OUT: Planning took too long")
            self.get_logger().error("   → Increase planning time limit")
            
        elif error_code == -7:  # PREEMPTED
            self.get_logger().error("✗ PREEMPTED: Goal was cancelled/preempted")
        
        # Planning & kinematics request errors
        elif error_code == -10:  # START_STATE_IN_COLLISION
            self.get_logger().error("✗ START_STATE_IN_COLLISION: Current robot position is in collision")
            self.get_logger().error("   → Move robot away from obstacles first")
            
        elif error_code == -11:  # START_STATE_VIOLATES_PATH_CONSTRAINTS
            self.get_logger().error("✗ START_STATE_VIOLATES_PATH_CONSTRAINTS")
            
        elif error_code == -12:  # GOAL_IN_COLLISION
            self.get_logger().error("✗ GOAL_IN_COLLISION: Target position would cause collision")
            self.get_logger().error("   → Choose a different target pose")
            
        elif error_code == -13:  # GOAL_VIOLATES_PATH_CONSTRAINTS
            self.get_logger().error("✗ GOAL_VIOLATES_PATH_CONSTRAINTS: Goal violates path constraints")
            
        elif error_code == -14:  # GOAL_CONSTRAINTS_VIOLATED
            self.get_logger().error("✗ GOAL_CONSTRAINTS_VIOLATED: Goal constraints are violated")
            
        elif error_code == -15:  # INVALID_GROUP_NAME
            self.get_logger().error("✗ INVALID_GROUP_NAME: Planning group 'arm' doesn't exist")
            self.get_logger().error("   → Check your SRDF configuration or update group_name in code")
            
        elif error_code == -16:  # INVALID_GOAL_CONSTRAINTS
            self.get_logger().error("✗ INVALID_GOAL_CONSTRAINTS: Goal constraints are malformed")
            
        elif error_code == -17:  # INVALID_ROBOT_STATE
            self.get_logger().error("✗ INVALID_ROBOT_STATE: Robot state is invalid")
            
        elif error_code == -18:  # INVALID_LINK_NAME
            self.get_logger().error("✗ INVALID_LINK_NAME: Referenced link name doesn't exist")
            
        elif error_code == -19:  # INVALID_OBJECT_NAME
            self.get_logger().error("✗ INVALID_OBJECT_NAME: Referenced object doesn't exist")
        
        # System errors
        elif error_code == -21:  # FRAME_TRANSFORM_FAILURE
            self.get_logger().error("✗ FRAME_TRANSFORM_FAILURE: TF transformation failed")
            self.get_logger().error("   → Check TF tree: ros2 run tf2_tools view_frames")
            
        elif error_code == -22:  # COLLISION_CHECKING_UNAVAILABLE
            self.get_logger().error("✗ COLLISION_CHECKING_UNAVAILABLE: Collision checker not available")
            
        elif error_code == -23:  # ROBOT_STATE_STALE
            self.get_logger().error("✗ ROBOT_STATE_STALE: Robot state information is outdated")
            
        elif error_code == -24:  # SENSOR_INFO_STALE
            self.get_logger().error("✗ SENSOR_INFO_STALE: Sensor information is outdated")
        
        # Kinematics errors
        elif error_code == -31:  # NO_IK_SOLUTION
            self.get_logger().error("✗ NO_IK_SOLUTION: Position is unreachable (no inverse kinematics solution)")
            self.get_logger().error("   → Target joint angles may be outside limits")
            
        else:
            self.get_logger().error(f"✗ UNKNOWN ERROR CODE: {error_code}")
            self.get_logger().error("   → This is not a standard MoveIt error code")

def main(args=None):
    rclpy.init(args=args)
    node = MoveItJointMover()

    # YOUR ACTUAL JOINT ANGLES IN DEGREES
    joint_angles_degrees = [28.2, 20.9, 80.7, -12.0, -0.5, -0.5]
    
    # CONVERT TO RADIANS (MoveIt requires radians!)
    test_angles = [math.radians(angle) for angle in joint_angles_degrees]
    
    node.get_logger().info(f"Target angles in degrees: {joint_angles_degrees}")
    node.get_logger().info(f"Converted to radians: {[round(a, 3) for a in test_angles]}")
    
    node.move_to_joints(test_angles)

    rclpy.spin(node)
    rclpy.shutdown()

if __name__ == '__main__':
    main()`

You have to give a position that is not possible to achive or colliding with obstacle

Expected behavior

For not reaching you have to get error -31 and for wrong group name you have to get -15

Actual behavior

getting 99999 or new error -27

Backtrace or Console output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions