Good afternoon, in our work we use the OpenCM 9.04, 3 ax-12a board, and when we display the state of the dynamics in Serial, then at some point the goal position values are not correct and the controller quickly freezes after that.
Only restart helps. What is it and how to fix the situation?
When I set the angle to all the engines, I check in a loop to see if they have completed the command. Only then does the code continue.
void WaitServosPosPerformed() {
int* servosPos = new int[JOINT_N];
if (DEBUG_LEVEL >= 1) DEBUG_SERIAL.println("Current servos position: ");
while (true) {
int* servosPos = GetServosPos();
bool* isMoving = GetServosMoving();
if (DEBUG_LEVEL >= 1) {
for (byte i = 0; i < JOINT_N; i++) {
DEBUG_SERIAL.print(servosPos[i]);
if (i < JOINT_N - 1) DEBUG_SERIAL.print(", ");
else DEBUG_SERIAL.println();
}
}
if (DEBUG_LEVEL >= 2) {
for (byte i = 0; i < JOINT_N; i++) { // 1 - движение, 0 - движения нет
DEBUG_SERIAL.print(isMoving[i]);
if (i < JOINT_N - 1) DEBUG_SERIAL.print(", ");
else DEBUG_SERIAL.println();
}
}
if ((isMoving[0] == 0 && isMoving[1] == 0 && isMoving[2] == 0)) break;
delay(10);
}
DEBUG_SERIAL.print("Motors performed position: ");
for (byte i = 0; i < JOINT_N; i++) {
DEBUG_SERIAL.print(servosPos[i]);
if (i < JOINT_N - 1) DEBUG_SERIAL.print(", ");
else DEBUG_SERIAL.println();
}
}
int* GetServosPos() {
int *pos = new int[JOINT_N];
for (byte i = 0; i < JOINT_N; i++) {
pos[i] = dxl.getPresentPosition(i + 1);
}
return pos;
}
int GetServoMoving(byte servoId) {
return dxl.readControlTableItem(MOVING, servoId);
}
bool* GetServosMoving() {
bool *moving = new bool[JOINT_N];
for (byte i = 0; i < JOINT_N; i++) {
moving[i] = dxl.readControlTableItem(MOVING, i + 1);
}
return moving;
}
I set different baud rates for Serial communication with the computer, for
DEBUG_SERIAL.begin(9600); dxl.begin(1000000); and even for all servos, but it still happens. The controller freezes.
I decided. I read an incomplete manual on how to return an array from a function in c++. There was no information on how to delete an array from memory. Now I delete and my robot works stably for a long time.
Good afternoon, in our work we use the OpenCM 9.04, 3 ax-12a board, and when we display the state of the dynamics in Serial, then at some point the goal position values are not correct and the controller quickly freezes after that. Only restart helps. What is it and how to fix the situation?
When I set the angle to all the engines, I check in a loop to see if they have completed the command. Only then does the code continue.
I set different baud rates for Serial communication with the computer, for DEBUG_SERIAL.begin(9600); dxl.begin(1000000); and even for all servos, but it still happens. The controller freezes.
https://community.robotis.us/t/opencm-9-04-hangs-when-using-serial-port/855