1
1
component joint_axis_mapper "Translate faults from Joint to Axis";
2
2
3
3
description """
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'.
5
5
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.
7
8
8
9
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
15
13
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
16
17
""";
17
18
18
19
license "GPL";
19
20
20
- pin in bit temp "Fault in ";
21
+ pin out bit dummy "halcompile requires at least one halpin ";
21
22
22
23
function _;
24
+ option period no;
23
25
option singleton yes;
24
26
option rtapi_app no;
25
27
@@ -39,13 +41,8 @@ typedef struct{
39
41
static faults_in_t *faults_in;
40
42
char fault_letter[16];
41
43
42
-
43
-
44
44
int rtapi_app_main(void) {
45
- int r = 0;
46
45
comp_id = hal_init("joint_axis_mapper");
47
- char buf[HAL_NAME_LEN + 1];
48
-
49
46
if(comp_id < 0) return comp_id;
50
47
51
48
number_joints = strlen(coord);
@@ -54,7 +51,7 @@ int rtapi_app_main(void) {
54
51
rtapi_print_msg(RTAPI_MSG_INFO, "Joint Axis Mapper - Initializing with coords %s\n", coord);
55
52
56
53
int this_count = 0;
57
- for(int i =0; i < strlen(coord); i++){
54
+ for(unsigned i =0; i < strlen(coord); i++){
58
55
if(coord[i] != ' ' && coord[i] != ';' && coord[i] != '{' && coord[i] != '}' && coord[i] != ',' &&
59
56
coord[i] != '\n' && coord[i] != '\r' && coord[i] != '\t' && coord[i] != '\"' && coord[i] != '\'') {
60
57
coord[this_count++] = coord[i];
@@ -66,7 +63,7 @@ int rtapi_app_main(void) {
66
63
this_count = 0;
67
64
number_joints = strlen(coord);
68
65
69
- for(int i = 0; i < strlen(coord); i++) {
66
+ for(unsigned i = 0; i < strlen(coord); i++) {
70
67
fault_letter[i] = coord[i];
71
68
this_count = 0;
72
69
if(coord[i] == 'X' || coord[i] == 'x'){ axis_counts[0]++; this_count = axis_counts[0]; }
@@ -92,7 +89,7 @@ int rtapi_app_main(void) {
92
89
}
93
90
}
94
91
95
- hal_export_funct ("joint_axis_mapper", (void(*))_, 0, 1, 0, comp_id );
92
+ export ("joint_axis_mapper", 0 );
96
93
hal_ready(comp_id);
97
94
return 0;
98
95
}
@@ -103,10 +100,11 @@ void rtapi_app_exit(void) {
103
100
104
101
105
102
FUNCTION(_) {
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]);
111
107
}
112
- }
108
+ *(faults_in->fault_out[i]) = *(faults_in->fault_in[i]);
109
+ }
110
+ }
0 commit comments