Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit b4aca87

Browse files
committed
modify canbus error
1 parent 16c37be commit b4aca87

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

mra_basic/src/joint_control/joint_control.cpp

+19-4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ using namespace std;
5252
UserControlOnCan *userControlOnCan;
5353
Gripper *gripper;
5454
mra_core_msgs::AssemblyState mra_state;
55+
bool senting_error = false;
56+
int error_count = 0;
5557

5658
void copy_ID_in_current_canbus()
5759
{
@@ -87,6 +89,7 @@ void copy_ID_in_current_canbus()
8789

8890
void joint_command_callback(const mra_core_msgs::JointCommandConstPtr &msg)
8991
{
92+
/*print joint command messages*/
9093
// for(int i=0; i<msg->command.size(); i++) {
9194
// std::cout<<msg->command[i]<<" || ";
9295
// }
@@ -96,11 +99,22 @@ void joint_command_callback(const mra_core_msgs::JointCommandConstPtr &msg)
9699
for(int i=0; i<jointID.size(); i++) {
97100
bool isSent = userControlOnCan->setJointTagPos(jointID[i],msg->command[i]);
98101
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]);
102104
}
103105
}
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+
}
104118
}
105119
}
106120
void moveJ_callback(const std_msgs::Float32MultiArray::ConstPtr &msg)
@@ -112,11 +126,12 @@ void moveJ_callback(const std_msgs::Float32MultiArray::ConstPtr &msg)
112126
for(int i=0; i<jointID.size(); i++) {
113127
bool isSent = userControlOnCan->setJointTagPos(jointID[i],msg->data[i]);
114128
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]);
116130
//set canbus state = CANBUS_STATE_INTERRUPT
117131
mra_state.canbus_state = mra_core_msgs::AssemblyState::CANBUS_STATE_INTERRUPT;
118132
}
119133
}
134+
120135
}
121136
}
122137

0 commit comments

Comments
 (0)