ToolNone workaround for Trajectories

Not sure if this has been posted yet, but I couldn’t find anything and other’s might be having this issue.
I’ve been working with a Stretch RE1, and took off the Stretch Gripper it came with. After doing this, I followed the Changing Tools instructions to make sure the robot config reflects this.
After doing a stretch_system_check.py and confirming everything worked, I started on the Align to Aruco tutorial. However, when I ran it, every trajectory crashed - I don’t have the error code, but essentially it was [TypeError]: NoneType has no attribute 'trajectory_manager'.
After tracing it for a bit, the issue was in the trajectory_components.py: get_trajectory_components()
While it DOES check for the wrist_pitch device being on the robot, it then defaults to returning a GripperComponent along with everything else.
This is where the error happens, since a GripperComponent is initialized with ‘stretch_gripper’ - which the robot doesn’t have on it, so it can’t find it.

So to fix this (at least until this issue is closed), just add another check to stretch_ros2/stretch_core/stretch_core/trajectory_components.py: get_trajectory_components(robot):

def get_trajectory_components(robot):
    robot_status = robot.get_status()
    if 'wrist_pitch' in robot_status['end_of_arm']:
        return {component.name: component for component in [HeadPanComponent(robot),
                                                            HeadTiltComponent(robot),
                                                            WristYawComponent(robot),
                                                            WristPitchComponent(robot),
                                                            WristRollComponent(robot),
                                                            GripperComponent(robot),
                                                            ArmComponent(robot),
                                                            LiftComponent(robot),
                                                            BaseComponent(robot),
                                                            ]}
    elif 'stretch_gripper' in robot_status['end_of_arm']:
        return {component.name: component for component in [HeadPanComponent(robot),
                                                            HeadTiltComponent(robot),
                                                            WristYawComponent(robot),
                                                            GripperComponent(robot),
                                                            ArmComponent(robot),
                                                            LiftComponent(robot),
                                                            BaseComponent(robot),
                                                            ]}
    else:
        return {component.name: component for component in [HeadPanComponent(robot),
                                                            HeadTiltComponent(robot),
                                                            WristYawComponent(robot),
                                                            ArmComponent(robot),
                                                            LiftComponent(robot),
                                                            BaseComponent(robot),
                                                            ]}
1 Like

Hey, thanks for posting this. It’s a good tip for customizing the components that get loaded into the ROS 2 driver!