UNPKG

@robotical/ricjs

Version:

Javascript/TS library for Robotical RIC

36 lines (34 loc) 1.84 kB
/** * The RICServoFaultDetection class is responsible for detecting faults in the RIC servos. * These are the faults that can currently be detected: 1) Wiring fault - Intermittent connection to servo potentiometer 2) Wiring fault - no connection to servo potentiometer 3) Wiring fault - faulty connection to servo drive 4) Servo horn has shifted out of position * To detect these faults: 1) get the list of all servos 1.1) We filter out the servos that don't have the fault bit enabled in their status byte 2) sending an atomic read command to the servos 2.1) the servos will respond with a report msg 2.2) the fault flags are on the 11th byte of the report msg 2.3) The 'fault' byte has 8 bits, each of which corresponds to a specific type of fault (there are only 4 types of faults so far, so the remaining 4 bits are unused.) Bit 0: Intermittent connection to potentiometer Bit 1: No connection to potentiometer Bit 2: Faulty connection to motor drive Bit 3: Servo horn position error 3) in a second phase, we receive the report msg from the app, and check the fault flags */ import RICMsgHandler from "./RICMsgHandler"; import { RICReportMsg, RICServoFaultFlags, RICStateInfo } from "./RICTypes"; export default class RICServoFaultDetector { private _ricMsgHandler; private static expirationDate; private static _servoList; private ricStateReference; constructor(ricMsgHandler: RICMsgHandler, ricStateReference: RICStateInfo); private getAllServos; atomicReadOperation(expirationTime?: number): Promise<void>; static interpretReportMsg(reportMsg: RICReportMsg): RICServoFaultFlags | undefined; private static decodeFault; static isFaultBitEnabled(input: number | string): boolean; }