0

i am a beginner. About my problem, there is an "invalid conversion' error in the swap(goal_positionall)

#include <DynamixelWorkbench.h>

#define Device_Name ""
#define BAUDRATE 57600
#define DXL_ID_1  1
#define DXL_ID_2  2
#define DXL_ID_3  3
#define DXL_ID_4  4
#define DXL_ID_5  5
DynamixelWorkbench dxl_wb;



int32_t goal_positionall[3][5] ={{0, 1024, 2048, 3072, 4080},
                                 {0,1000,0,3000,0},
                                 {1000,1000,500,700,2048}};

const uint8_t handler_index = 0;


    void setup() 
    {
      Serial.begin(57600);
      while(!Serial);

      const char *log;
      bool result = false;

      uint16_t model_number = 0;
      uint8_t dxl_id[5] = {DXL_ID_1, DXL_ID_2, DXL_ID_3, DXL_ID_4,DXL_ID_5};

      result = dxl_wb.init(Device_Name, BAUDRATE, &log); //To initialize the
motor
      if (result == false)
      {
        Serial.println(log);
        Serial.println("Failed to init");
      }
      else
      {
        Serial.print("Succeeded to init : ");
        Serial.println(BAUDRATE);  
      }

      for (int X = 0; X < 5; X++) //To do the actions 5 time
      {
        result = dxl_wb.ping(dxl_id[X], &model_number, &log); //Ping the 5 motors
        if (result == false)
        {
          Serial.println(log);
          Serial.println("Failed to ping");
        }
        else
        {
          Serial.println("Succeeded to ping");
          Serial.print("id : ");
          Serial.print(dxl_id[X]);
          Serial.print(" model_number : ");
          Serial.println(model_number);
        }

        result = dxl_wb.jointMode(dxl_id[X], 0, 0, &log);  //Change joint mode for 5 motors
        if (result == false)
        {
          Serial.println(log);
          Serial.println("Failed to change joint mode");
        }
        else
        {
          Serial.println("Succeed to change joint mode");
        }
      } 


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

    }

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

      result = dxl_wb.syncWrite(handler_index, &goal_positionall[0][0], &log); 
      if (result == false)
      {
        Serial.println(log);
        Serial.println("Failed to sync write position");
      }

      delay(1000);

      swap(goal_positionall); 
    }





void swap (  int32_t **array[][5] )
    {
      int32_t tmp = array[0][5];
      array[0][5] = array[1][5];
      array[1][5] = array[2][5];
      array[2][5] = tmp;


    }
  • please format your code ... select the code and click the {} button – jsotola Sep 17 at 1:57
  • No wonder, the int32_t **array[][5] means int32_t *** array[5], so you're passing 2 dimensional array into the 4 dimensional parameter. – KIIV Sep 17 at 5:30
  • what should i do to avoid this? – Song Bul Sep 17 at 5:51
  • Either fully define the size of the 2 dimensional array or don't specify the size at all – chrisl Sep 17 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.