Validate AXIS task state flow
This commit is contained in:
@@ -284,6 +284,19 @@ static void queue_error_message(const char *message)
|
||||
state->error_count += 1;
|
||||
}
|
||||
|
||||
static void clear_motion_fault_latch(LcmotRuntime *state)
|
||||
{
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
state->aborted = 0;
|
||||
state->motion_error = 0;
|
||||
state->on_soft_limit = 0;
|
||||
state->error_head = 0;
|
||||
state->error_tail = 0;
|
||||
state->error_count = 0;
|
||||
}
|
||||
|
||||
static void sync_hal_pins(void)
|
||||
{
|
||||
int i;
|
||||
@@ -360,6 +373,7 @@ static void apply_command(const LcmotCommand *command)
|
||||
switch (command->type) {
|
||||
case LCMOT_CMD_ENABLE:
|
||||
state->motion_enabled = 1;
|
||||
clear_motion_fault_latch(state);
|
||||
break;
|
||||
case LCMOT_CMD_DISABLE:
|
||||
state->motion_enabled = 0;
|
||||
|
||||
@@ -2215,17 +2215,16 @@ std::string status_json()
|
||||
out << ",\"hardwareDrive\":false";
|
||||
out << ",\"statusSource\":\"" << json_escape(emc_status.source) << "\"";
|
||||
out << ",\"schemaVersion\":1";
|
||||
out << ",\"taskTopLevelStatus\":\"" << json_escape(emc_status.top_rcs_status) << "\"";
|
||||
out << ",\"rcsStatus\":{\"top\":\"" << json_escape(emc_status.top_rcs_status) << "\"";
|
||||
out << ",\"task\":\"" << json_escape(task_status.rcs_status) << "\"";
|
||||
out << ",\"motion\":\"" << json_escape(motion.rcs_status) << "\"";
|
||||
out << ",\"io\":\"" << json_escape(emc_status.io.rcs_status) << "\"}";
|
||||
out << ",\"task\":{\"state\":\"" << json_escape(task_status.state) << "\"";
|
||||
out << ",\"emcStatus\":{\"source\":\"" << json_escape(emc_status.source) << "\"";
|
||||
out << ",\"sourcePath\":\"" << json_escape(emc_status.source_path) << "\"";
|
||||
out << ",\"valid\":" << (emc_status.valid ? "true" : "false");
|
||||
out << ",\"top\":{\"status\":\"" << json_escape(emc_status.top_rcs_status) << "\"}";
|
||||
out << ",\"task\":{\"status\":\"" << json_escape(task_status.rcs_status) << "\"";
|
||||
out << ",\"state\":\"" << json_escape(task_status.state) << "\"";
|
||||
out << ",\"mode\":\"" << json_escape(task_status.mode) << "\"";
|
||||
out << ",\"interpState\":\"" << json_escape(task_status.interp_state) << "\"";
|
||||
out << ",\"interpResumeState\":\"" << json_escape(task_status.interp_resume_state) << "\"";
|
||||
out << ",\"execState\":\"" << json_escape(task_status.exec_state) << "\"";
|
||||
out << ",\"status\":\"" << json_escape(task_status.rcs_status) << "\"";
|
||||
out << ",\"taskPaused\":" << (task_status.task_paused ? "true" : "false");
|
||||
out << ",\"singleStepping\":" << (task_status.single_stepping ? "true" : "false");
|
||||
out << ",\"cycle\":" << task_status.cycle;
|
||||
@@ -2255,84 +2254,30 @@ std::string status_json()
|
||||
out << ",\"readLine\":" << task_status.read_line;
|
||||
out << ",\"motionLine\":" << task_status.motion_line;
|
||||
out << ",\"callLevel\":" << task_status.call_level << "}";
|
||||
out << ",\"servoCycle\":" << state.servo_cycle;
|
||||
out << ",\"motionStatus\":";
|
||||
if (motion.valid) {
|
||||
out << "{\"semanticBoundary\":\"linuxcnc_motion_runtime_phase3_minimal\"";
|
||||
out << ",\"motionRuntimeReady\":true";
|
||||
out << ",\"nativeHalSyncReady\":false";
|
||||
out << ",\"cycle\":" << motion.cycle;
|
||||
out << ",\"motion\":{\"programLine\":" << motion.program_line;
|
||||
out << ",\"id\":" << motion.motion_id;
|
||||
out << ",\"status\":" << motion.status;
|
||||
out << ",\"enabled\":" << (motion.enabled ? "true" : "false");
|
||||
out << ",\"nextMotionId\":" << motion.next_motion_id;
|
||||
out << ",\"motionType\":" << motion.motion_type;
|
||||
out << ",\"coordMode\":" << motion.coord_mode;
|
||||
out << ",\"teleopMode\":" << motion.teleop_mode;
|
||||
out << ",\"inPosition\":" << (motion.in_position ? "true" : "false");
|
||||
out << ",\"paused\":" << (motion.paused ? "true" : "false");
|
||||
out << ",\"aborted\":" << (motion.aborted ? "true" : "false");
|
||||
out << ",\"motionError\":" << (motion.motion_error ? "true" : "false");
|
||||
out << ",\"onSoftLimit\":" << (motion.on_soft_limit ? "true" : "false");
|
||||
out << ",\"stepping\":" << (motion.stepping ? "true" : "false");
|
||||
out << ",\"idForStep\":" << motion.id_for_step;
|
||||
out << ",\"motionId\":" << motion.motion_id;
|
||||
out << ",\"switchkinsType\":" << motion.switchkins_type;
|
||||
out << ",\"requestedVel\":" << motion.requested_vel;
|
||||
out << ",\"currentVel\":" << motion.current_vel;
|
||||
out << ",\"queueDepth\":" << motion.queue_depth;
|
||||
out << ",\"queueCapacity\":" << motion.queue_capacity;
|
||||
out << ",\"queueFull\":" << (motion.queue_full ? "true" : "false");
|
||||
out << ",\"activeDepth\":" << motion.active_depth;
|
||||
out << ",\"commandQueueDepth\":" << motion.command_queue_depth << "}";
|
||||
out << ",\"axis\":{\"x\":" << motion.axis_fb[0];
|
||||
out << ",\"y\":" << motion.axis_fb[1];
|
||||
out << ",\"z\":" << motion.axis_fb[2];
|
||||
out << ",\"a\":" << motion.axis_fb[3];
|
||||
out << ",\"b\":" << motion.axis_fb[4];
|
||||
out << ",\"c\":" << motion.axis_fb[5] << "}";
|
||||
out << ",\"joint0\":{\"motorPosCmd\":" << motion.joint_cmd[0];
|
||||
out << ",\"motorPosFb\":" << motion.joint_fb[0] << "}";
|
||||
out << ",\"queueDepth\":" << motion.queue_depth;
|
||||
out << ",\"activeDepth\":" << motion.active_depth;
|
||||
out << ",\"commandQueueDepth\":" << motion.command_queue_depth;
|
||||
out << "}";
|
||||
} else {
|
||||
out << "{}";
|
||||
}
|
||||
out << ",\"emcStatus\":{\"source\":\"" << json_escape(emc_status.source) << "\"";
|
||||
out << ",\"sourcePath\":\"" << json_escape(emc_status.source_path) << "\"";
|
||||
out << ",\"valid\":" << (emc_status.valid ? "true" : "false");
|
||||
out << ",\"top\":{\"status\":\"" << json_escape(emc_status.top_rcs_status) << "\"}";
|
||||
out << ",\"task\":{\"status\":\"" << json_escape(task_status.rcs_status) << "\"";
|
||||
out << ",\"state\":\"" << json_escape(task_status.state) << "\"";
|
||||
out << ",\"mode\":\"" << json_escape(task_status.mode) << "\"";
|
||||
out << ",\"interpState\":\"" << json_escape(task_status.interp_state) << "\"";
|
||||
out << ",\"execState\":\"" << json_escape(task_status.exec_state) << "\"";
|
||||
out << ",\"cycle\":" << task_status.cycle;
|
||||
out << ",\"programOpen\":" << (task_status.program_open ? "true" : "false");
|
||||
out << ",\"taskPlanOpen\":" << (task_status.task_plan_open ? "true" : "false");
|
||||
out << ",\"planId\":" << task_status.plan_id;
|
||||
out << ",\"motionPlanLoaded\":" << (task_status.motion_plan_loaded ? "true" : "false");
|
||||
out << ",\"pendingCommandDepth\":" << task_status.pending_command_depth;
|
||||
out << ",\"pendingExecuteMotionDepth\":" << task_status.pending_execute_motion_depth;
|
||||
out << ",\"allHomed\":" << (task_status.all_homed ? "true" : "false");
|
||||
out << ",\"nextProgramLine\":" << task_status.next_program_line;
|
||||
out << ",\"currentLine\":" << task_status.current_line;
|
||||
out << ",\"readLine\":" << task_status.read_line;
|
||||
out << ",\"motionLine\":" << task_status.motion_line;
|
||||
out << ",\"callLevel\":" << task_status.call_level << "}";
|
||||
out << ",\"motion\":{\"valid\":" << (motion.valid ? "true" : "false");
|
||||
out << ",\"status\":\"" << json_escape(motion.rcs_status) << "\"";
|
||||
out << ",\"programLine\":" << motion.program_line;
|
||||
out << ",\"motionId\":" << motion.motion_id;
|
||||
out << ",\"enabled\":" << (motion.enabled ? "true" : "false");
|
||||
out << ",\"nextMotionId\":" << motion.next_motion_id;
|
||||
out << ",\"motionType\":" << motion.motion_type;
|
||||
out << ",\"coordMode\":" << motion.coord_mode;
|
||||
out << ",\"teleopMode\":" << motion.teleop_mode;
|
||||
out << ",\"inPosition\":" << (motion.in_position ? "true" : "false");
|
||||
out << ",\"paused\":" << (motion.paused ? "true" : "false");
|
||||
out << ",\"aborted\":" << (motion.aborted ? "true" : "false");
|
||||
out << ",\"motionError\":" << (motion.motion_error ? "true" : "false");
|
||||
out << ",\"queueDepth\":" << motion.queue_depth;
|
||||
out << ",\"queueCapacity\":" << motion.queue_capacity;
|
||||
out << ",\"queueFull\":" << (motion.queue_full ? "true" : "false");
|
||||
out << ",\"activeDepth\":" << motion.active_depth;
|
||||
out << ",\"commandQueueDepth\":" << motion.command_queue_depth;
|
||||
out << ",\"onSoftLimit\":" << (motion.on_soft_limit ? "true" : "false");
|
||||
out << ",\"stepping\":" << (motion.stepping ? "true" : "false");
|
||||
out << ",\"idForStep\":" << motion.id_for_step;
|
||||
out << ",\"switchkinsType\":" << motion.switchkins_type;
|
||||
out << ",\"requestedVel\":" << motion.requested_vel;
|
||||
out << ",\"currentVel\":" << motion.current_vel;
|
||||
out << ",\"traj\":{\"enabled\":" << (motion.enabled ? "true" : "false");
|
||||
out << ",\"inpos\":" << (motion.in_position ? "true" : "false");
|
||||
out << ",\"queue\":" << motion.queue_depth;
|
||||
|
||||
Reference in New Issue
Block a user