@@ -52,6 +52,8 @@ using namespace std;
52
52
UserControlOnCan *userControlOnCan;
53
53
Gripper *gripper;
54
54
mra_core_msgs::AssemblyState mra_state;
55
+ bool senting_error = false ;
56
+ int error_count = 0 ;
55
57
56
58
void copy_ID_in_current_canbus ()
57
59
{
@@ -87,6 +89,7 @@ void copy_ID_in_current_canbus()
87
89
88
90
void joint_command_callback (const mra_core_msgs::JointCommandConstPtr &msg)
89
91
{
92
+ /* print joint command messages*/
90
93
// for(int i=0; i<msg->command.size(); i++) {
91
94
// std::cout<<msg->command[i]<<" || ";
92
95
// }
@@ -96,11 +99,22 @@ void joint_command_callback(const mra_core_msgs::JointCommandConstPtr &msg)
96
99
for (int i=0 ; i<jointID.size (); i++) {
97
100
bool isSent = userControlOnCan->setJointTagPos (jointID[i],msg->command [i]);
98
101
if (isSent==false ) {
99
- ROS_ERROR (" Senting is failure in ID:%d" ,jointID[i]);
100
- // set canbus state = CANBUS_STATE_INTERRUPT
101
- mra_state.canbus_state = mra_core_msgs::AssemblyState::CANBUS_STATE_INTERRUPT;
102
+ senting_error = true ;
103
+ // ROS_WARN("Senting is failure in ID:%d",jointID[i]);
102
104
}
103
105
}
106
+ /* Continuous error 5 times*/
107
+ if (senting_error){
108
+ error_count++;
109
+ senting_error = false ;
110
+ }else {
111
+ error_count = 0 ;
112
+ }
113
+ if (error_count >= 5 ){
114
+ ROS_ERROR (" Senting Error Number >= 5" );
115
+ // set canbus state = CANBUS_STATE_INTERRUPT
116
+ // mra_state.canbus_state = mra_core_msgs::AssemblyState::CANBUS_STATE_INTERRUPT;
117
+ }
104
118
}
105
119
}
106
120
void moveJ_callback (const std_msgs::Float32MultiArray::ConstPtr &msg)
@@ -112,11 +126,12 @@ void moveJ_callback(const std_msgs::Float32MultiArray::ConstPtr &msg)
112
126
for (int i=0 ; i<jointID.size (); i++) {
113
127
bool isSent = userControlOnCan->setJointTagPos (jointID[i],msg->data [i]);
114
128
if (isSent==false ) {
115
- ROS_ERROR (" Senting is failure in ID:%d" ,jointID[i]);
129
+ ROS_WARN (" Senting is failure in ID:%d" ,jointID[i]);
116
130
// set canbus state = CANBUS_STATE_INTERRUPT
117
131
mra_state.canbus_state = mra_core_msgs::AssemblyState::CANBUS_STATE_INTERRUPT;
118
132
}
119
133
}
134
+
120
135
}
121
136
}
122
137
0 commit comments