ROBOTIS-GIT / OpenCR

Software for ROS Embedded board (a.k.a. OpenCR). OpenCR means Open-source Control Module for ROS.
Apache License 2.0
382 stars 239 forks source link

[TxRxResult] Incorrect status packet! when syncRead [dynamixelworkbench] #258

Closed tzf230201 closed 3 years ago

tzf230201 commented 3 years ago

the device i use is OpenCR, I use 2 servo MX-28 (id 3 and id 5),return time delay = 5 (10uS),protocol 2.0 at 1M baudrate

i tried Sync_Read_Write on opencr example

syncwrite works fine but got the following message when syncread

[TxRxResult] Incorrect packet status!

each servo works fine when I try Read_Write on the example

What do you think I missed? the following program that I use


#include <DynamixelWorkbench.h>

#if defined(__OPENCM904__)
  #define DEVICE_NAME "3" //Dynamixel on Serial3(USART3)  <-OpenCM 485EXP
#elif defined(__OPENCR__)
  #define DEVICE_NAME ""
#endif   

#define BAUDRATE  1000000
#define DXL_ID_1  3
#define DXL_ID_2  5

DynamixelWorkbench dxl_wb;

uint8_t dxl_id[2] = {DXL_ID_1, DXL_ID_2};
  int32_t state[2]={1,1};
const uint8_t handler_index = 0;

void setup() 
{
  Serial.begin(57600);
  // while(!Serial); // Wait for Opening Serial Monitor

  const char *log;
  bool result = false;

  uint16_t model_number = 0;

  result = dxl_wb.init(DEVICE_NAME, BAUDRATE, &log);
  if (result == false)
  {
    Serial.println(log);
    Serial.println("Failed to init");
  }
  else
  {
    Serial.print("Succeeded to init : ");
    Serial.println(BAUDRATE);  
  }

  for (int cnt = 0; cnt < 2; cnt++)
  {
    result = dxl_wb.ping(dxl_id[cnt], &model_number, &log);
    if (result == false)
    {
      Serial.println(log);
      Serial.println("Failed to ping");
    }
    else
    {
      Serial.println("Succeeded to ping");
      Serial.print("id : ");
      Serial.print(dxl_id[cnt]);
      Serial.print(" model_number : ");
      Serial.println(model_number);
    }

  } 

  result = dxl_wb.addSyncWriteHandler(dxl_id[0], "LED", &log);
  if (result == false)
  {
    Serial.println(log);
    Serial.println("Failed to add sync write handler");
  }

  result = dxl_wb.addSyncReadHandler(dxl_id[0], "Present_Position", &log);
  if (result == false)
  {
    Serial.println(log);
    Serial.println("Failed to add sync read handler");
  }
}

void loop() 
{  
  const char *log;
  bool result = false;

  int32_t present_position[2] = {0, 0};

  result = dxl_wb.syncWrite(handler_index, &state[0], &log);
  if (result == false)
  {
    Serial.println(log);
  }

    result = dxl_wb.syncRead(0, &dxl_id[0], 2, &log);
    if (result == false)
    {
      Serial.println(log);
      Serial.println("Failed to sync read position");
    }

    result = dxl_wb.getSyncReadData(handler_index, &present_position[0], &log);
    if (result == false)
    {
      Serial.println(log);
    }
   delay(1000);
  state[0] = !state[0];
  state[1] = !state[1];
}

thank you for your attention!

tzf230201 commented 3 years ago

I bought a new opencr, and it worked there.

I found that on my older opencr, syncread can work if the return time is delay >= 100 (200uS) whereas the new opencr can work even if the return time delay = 4 (8uS).

what causes the opencr's performance to drop? whereas I use the same servo.