Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start_traj_mode fails if home position is not configured #37

Closed
gavanderhoorn opened this issue Jun 1, 2023 · 11 comments · Fixed by #297
Closed

start_traj_mode fails if home position is not configured #37

gavanderhoorn opened this issue Jun 1, 2023 · 11 comments · Fixed by #297
Labels
bug Something isn't working rv:0.1.0 Reported in MotoROS2 0.1.0 yrc1000
Milestone

Comments

@gavanderhoorn
Copy link
Collaborator

If the home position is not set, or the home position needs to be checked, the controller refuses to start INFORM jobs.

For MotoROS2 specifically, this means that start_traj_mode & start_point_queue_mode fail with:

$ ros2 service call /start_traj_mode motoros2_interfaces/srv/StartTrajMode
requester: making request: motoros2_interfaces.srv.StartTrajMode_Request()

response:
motoros2_interfaces.srv.StartTrajMode_Response(result_code=motoros2_interfaces.msg.MotionReadyEnum(value=108), message='The INIT_ROS job has not started. Please call start_traj_mode service')

There is no indication on the pendant as to "why" the job failed to start.

It is unclear whether this issue can be detected, or whether MotoROS2 can provide a better error message.

@gavanderhoorn gavanderhoorn added bug Something isn't working rv:0.1.0 Reported in MotoROS2 0.1.0 yrc1000 labels Jun 1, 2023
@gavanderhoorn
Copy link
Collaborator Author

Note: this is also an issue with MotoROS1.

@ted-miller
Copy link
Collaborator

We need to document this error in the readme.
#201 (comment)

They should be seeing a message on the pendant
image

When attempting to start a job (using the pendant), they should get error 0380 Check Position

@ted-miller ted-miller added this to the 0.2.0 milestone Jan 22, 2024
@gavanderhoorn
Copy link
Collaborator Author

gavanderhoorn commented Jan 22, 2024

Should we instead not have MR2 check whether the home pos is set and raise an appropriate alarm if it isn't?


Edit: or at the very least update the result message returned by start_traj_mode et al.?

@ted-miller
Copy link
Collaborator

It looks like we already are

Ros_ErrorHandling_ErrNo_ToString(rData.err_no), rData.err_no);

So that's apparently broken.

@gavanderhoorn
Copy link
Collaborator Author

You mean we should be seeing:

case 0x3040: return "The home position is not registered";

?

@ted-miller
Copy link
Collaborator

Yeah. That's what I would have thought.

Though perhaps 0x3040 doesn't apply if the home position has been registered and just needs to be validated. If that's the case, then I don't know of any mechanism to detect that this scenario.

@gavanderhoorn
Copy link
Collaborator Author

Just ran into this when testing something for #19:

[...] [...]: Ros_MotionControl_StartMotionMode: enter
[...] [...]: Can't start 'INIT_ROS' because: 'The home position is not registered' (0x3040)
[...] [...]: Ros_MotionControl_StartMotionMode: exit
[...] [...]: Ros_ServiceStartPointQueueMode_Trigger: The INIT_ROS job has not started. Please call start_traj_mode or start_point_queue_mode service (108)

seems this isn't completely broken.

@yai-rosejo
Copy link
Collaborator

yai-rosejo commented Feb 15, 2024

I started looking into this issue. I found that the debug statement is occurring at:

motoros2/src/MotionControl.c

Lines 1503 to 1516 in 10d8f00

// Start Job
bzero(&rData, sizeof(rData));
bzero(&sStartData, sizeof(sStartData));
sStartData.sTaskNo = 0;
strncpy(sStartData.cJobName, g_nodeConfigSettings.inform_job_name, MAX_JOB_NAME_LEN);
ret = mpStartJob(&sStartData, &rData);
if( (ret != 0) || (rData.err_no !=0) )
{
//TODO(gavanderhoorn): special check for "job is not loaded"
Ros_Debug_BroadcastMsg(
"Can't start '%s' because: '%s' (0x%04X)", g_nodeConfigSettings.inform_job_name,
Ros_ErrorHandling_ErrNo_ToString(rData.err_no), rData.err_no);
goto updateStatus;
}

The r.Data is not getting out of the BOOL Ros_MotionControl_StartMotionMode function.

This then gets put out into a failure to start in Ros_ServiceStartTrajMode_Trigger:

if (!Ros_MotionControl_StartMotionMode(MOTION_MODE_TRAJECTORY))
{
// update response
response->result_code.value = Ros_Controller_GetNotReadySubcode();
if (response->result_code.value == MOTION_READY || Ros_MotionControl_IsMotionMode_PointQueue() || Ros_MotionControl_IsMotionMode_RawStreaming())
{
//Motion is ready, but the StartTrajMode service failed
//because it's already in a different mode.
response->result_code.value = MOTION_NOT_READY_OTHER_TRAJ_MODE_ACTIVE;
rosidl_runtime_c__String__assign(&response->message,
"Another motion mode is already active. Please call 'stop_traj_mode' service and try again.");
}
else
{
// map to human readable string
rosidl_runtime_c__String__assign(&response->message,
Ros_ErrorHandling_MotionNotReadyCode_ToString((MotionNotReadyCode)response->result_code.value));
}
Ros_Debug_BroadcastMsg("%s: %s (%d)", __func__,
response->message.data, response->result_code.value);
}

Which then calls Ros_Controller_GetNotReadySubcode(), this function doesn't see the warning only that the job has not started via:

// Check operating
if(!Ros_Controller_IsOperating())
return MOTION_NOT_READY_NOT_STARTED;

@yai-rosejo
Copy link
Collaborator

This same problem also occurs in Issue #192 I believe

@gavanderhoorn
Copy link
Collaborator Author

@jimmy-mcelwain @ted-miller: #265 and #297 have been linked as closing this issue, but I don't believe they address the suspected cause, do they?

@jimmy-mcelwain
Copy link
Collaborator

So neither of those PRs would allow start_traj_mode to succeed if home position is not configured, but it would give a better response. I believe that the response if the home position is not configured would be The controller has an active Error: Can't turn on servo because: 'The home position is not registered' (0x3040). I don't believe that jobs can be run while the home position is not registered, so I don't know if anything can be done besides giving a useful error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rv:0.1.0 Reported in MotoROS2 0.1.0 yrc1000
Projects
None yet
4 participants