11component joint_axis_mapper "Translate faults from Joint to Axis";
22
33description """
4- When a joint has a Fault, is shows as Joint 0.
4+ By default ' joint.n.amp-fault-in' triggers an error message 'Joint n amplifier fault'.
55
6- This is a translation layer that shows an Axis associated with a joint.
6+ This component is a translation layer that shows an additional message
7+ '{L} Axis fault detected', with {L} being the axis letter associated with the faulted joint.
78
89
9- Usage:
10- loadrt joint_axis_mapper coord=[TRAJ]COORDINATES
11-
12- net x-fault joint.0.amp-fault-in => translate.X-fault
13-
14- Replacing axis letter and joint number appropriate for your machine
10+ Usage example:
11+ loadrt joint_axis_mapper coord=xyz
12+ addf joint_axis_mapper servo-thread
1513
14+ net x-fault joint.0.faulted => jam.x-fault
15+ net y-fault joint.1.faulted => jam.y-fault
16+ net z-fault joint.2.faulted => jam.z-fault
1617""";
1718
1819license "GPL";
1920
20- pin in bit temp "Fault in ";
21+ pin out bit dummy "halcompile requires at least one halpin ";
2122
2223function _;
24+ option period no;
2325option singleton yes;
2426option rtapi_app no;
2527
@@ -39,13 +41,8 @@ typedef struct{
3941static faults_in_t *faults_in;
4042char fault_letter[16];
4143
42-
43-
4444int rtapi_app_main(void) {
45- int r = 0;
4645 comp_id = hal_init("joint_axis_mapper");
47- char buf[HAL_NAME_LEN + 1];
48-
4946 if(comp_id < 0) return comp_id;
5047
5148 number_joints = strlen(coord);
@@ -54,7 +51,7 @@ int rtapi_app_main(void) {
5451 rtapi_print_msg(RTAPI_MSG_INFO, "Joint Axis Mapper - Initializing with coords %s\n", coord);
5552
5653 int this_count = 0;
57- for(int i =0; i < strlen(coord); i++){
54+ for(unsigned i =0; i < strlen(coord); i++){
5855 if(coord[i] != ' ' && coord[i] != ';' && coord[i] != '{' && coord[i] != '}' && coord[i] != ',' &&
5956 coord[i] != '\n' && coord[i] != '\r' && coord[i] != '\t' && coord[i] != '\"' && coord[i] != '\'') {
6057 coord[this_count++] = coord[i];
@@ -66,7 +63,7 @@ int rtapi_app_main(void) {
6663 this_count = 0;
6764 number_joints = strlen(coord);
6865
69- for(int i = 0; i < strlen(coord); i++) {
66+ for(unsigned i = 0; i < strlen(coord); i++) {
7067 fault_letter[i] = coord[i];
7168 this_count = 0;
7269 if(coord[i] == 'X' || coord[i] == 'x'){ axis_counts[0]++; this_count = axis_counts[0]; }
@@ -92,7 +89,7 @@ int rtapi_app_main(void) {
9289 }
9390 }
9491
95- hal_export_funct ("joint_axis_mapper", (void(*))_, 0, 1, 0, comp_id );
92+ export ("joint_axis_mapper", 0 );
9693 hal_ready(comp_id);
9794 return 0;
9895}
@@ -103,10 +100,11 @@ void rtapi_app_exit(void) {
103100
104101
105102FUNCTION(_) {
106- for(int i = 0; i < number_joints; i++) {
107- if(*faults_in->fault_in[i] && ! *faults_in->fault_out[i]){
108- rtapi_print_msg(RTAPI_MSG_ERR, "%c Axis fault detected\n", fault_letter[i]);
109- }
110- *(faults_in->fault_out[i]) = *(faults_in->fault_in[i]);
103+ dummy=0; // if we don't use at least one halpin in FUNCTION we get a compiler warning
104+ for(int i = 0; i < number_joints; i++) {
105+ if(*faults_in->fault_in[i] && ! *faults_in->fault_out[i]){
106+ rtapi_print_msg(RTAPI_MSG_ERR, "%c Axis fault detected\n", fault_letter[i]);
111107 }
112- }
108+ *(faults_in->fault_out[i]) = *(faults_in->fault_in[i]);
109+ }
110+ }
0 commit comments