Skip to content

Commit

Permalink
Add cstdlib library include because of error on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ckyun777 committed Nov 1, 2024
1 parent e3bb2d4 commit 6b94826
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 53 deletions.
7 changes: 4 additions & 3 deletions dynamixel_workbench_toolbox/examples/src/b_Ping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -52,7 +53,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeeded to init(%d)\n", baud_rate);
printf("Succeeded to init(%d)\n", baud_rate);

result = dxl_wb.ping(dxl_id, &model_number, &log);
if (result == false)
Expand All @@ -67,4 +68,4 @@ int main(int argc, char *argv[])
}

return 0;
}
}
7 changes: 4 additions & 3 deletions dynamixel_workbench_toolbox/examples/src/c_ID_Change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -52,7 +53,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeeded to init(%d)\n", baud_rate);
printf("Succeeded to init(%d)\n", baud_rate);

uint16_t model_number = 0;
result = dxl_wb.ping(dxl_id, &model_number, &log);
Expand Down Expand Up @@ -98,4 +99,4 @@ int main(int argc, char *argv[])
for (int cnt = 0; cnt < dxl_cnt; cnt++)
printf("id : %d, model name : %s\n", scanned_id[cnt], dxl_wb.getModelName(scanned_id[cnt]));
}
}
}
7 changes: 4 additions & 3 deletions dynamixel_workbench_toolbox/examples/src/d_BPS_Change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int dxl_id = 1;
Expand Down Expand Up @@ -52,7 +53,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeeded to init(%d)\n", baud_rate);
printf("Succeeded to init(%d)\n", baud_rate);

uint16_t model_number = 0;
result = dxl_wb.ping(dxl_id, &model_number, &log);
Expand Down Expand Up @@ -81,4 +82,4 @@ int main(int argc, char *argv[])
}

return 0;
}
}
5 changes: 3 additions & 2 deletions dynamixel_workbench_toolbox/examples/src/e_Mode_Change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -53,7 +54,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeeded to init(%d)\n", baud_rate);
printf("Succeeded to init(%d)\n", baud_rate);

result = dxl_wb.ping(dxl_id, &model_number, &log);
if (result == false)
Expand Down
7 changes: 4 additions & 3 deletions dynamixel_workbench_toolbox/examples/src/f_Reboot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -52,7 +53,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeed to init(%d)\n", baud_rate);
printf("Succeed to init(%d)\n", baud_rate);

result = dxl_wb.ping(dxl_id, &model_number, &log);
if (result == false)
Expand All @@ -78,4 +79,4 @@ int main(int argc, char *argv[])
}

return 0;
}
}
7 changes: 4 additions & 3 deletions dynamixel_workbench_toolbox/examples/src/g_Reset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -52,7 +53,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeed to init(%d)\n", baud_rate);
printf("Succeed to init(%d)\n", baud_rate);

result = dxl_wb.ping(dxl_id, &model_number, &log);
if (result == false)
Expand All @@ -78,4 +79,4 @@ int main(int argc, char *argv[])
}

return 0;
}
}
7 changes: 4 additions & 3 deletions dynamixel_workbench_toolbox/examples/src/h_Position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -52,7 +53,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeed to init(%d)\n", baud_rate);
printf("Succeed to init(%d)\n", baud_rate);

result = dxl_wb.ping(dxl_id, &model_number, &log);
if (result == false)
Expand Down Expand Up @@ -88,4 +89,4 @@ int main(int argc, char *argv[])
}

return 0;
}
}
7 changes: 4 additions & 3 deletions dynamixel_workbench_toolbox/examples/src/i_Velocity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -52,7 +53,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeed to init(%d)\n", baud_rate);
printf("Succeed to init(%d)\n", baud_rate);

result = dxl_wb.ping(dxl_id, &model_number, &log);
if (result == false)
Expand Down Expand Up @@ -90,4 +91,4 @@ int main(int argc, char *argv[])
}

return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -52,7 +53,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeed to init(%d)\n", baud_rate);
printf("Succeed to init(%d)\n", baud_rate);

result = dxl_wb.ping(dxl_id, &model_number, &log);
if (result == false)
Expand Down Expand Up @@ -88,4 +89,4 @@ int main(int argc, char *argv[])
}

return 0;
}
}
7 changes: 4 additions & 3 deletions dynamixel_workbench_toolbox/examples/src/k_Read_Write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -52,7 +53,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeed to init(%d)\n", baud_rate);
printf("Succeed to init(%d)\n", baud_rate);

result = dxl_wb.ping(dxl_id, &model_number, &log);
if (result == false)
Expand Down Expand Up @@ -90,4 +91,4 @@ int main(int argc, char *argv[])
}

return 0;
}
}
9 changes: 5 additions & 4 deletions dynamixel_workbench_toolbox/examples/src/l_Sync_Write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

void swap(int32_t *array);

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -55,7 +56,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeed to init(%d)\n", baud_rate);
printf("Succeed to init(%d)\n", baud_rate);

for (int cnt = 0; cnt < 2; cnt++)
{
Expand Down Expand Up @@ -93,7 +94,7 @@ int main(int argc, char *argv[])
int32_t goal_position[2] = {0, 1023};

const uint8_t handler_index = 0;

while(1)
{
result = dxl_wb.syncWrite(handler_index, &goal_position[0], &log);
Expand All @@ -116,4 +117,4 @@ void swap(int32_t *array)
int32_t tmp = array[0];
array[0] = array[1];
array[1] = tmp;
}
}
21 changes: 16 additions & 5 deletions dynamixel_workbench_toolbox/examples/src/m_Sync_Read_Write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
/* Authors: Taehun Lim (Darby) */

#include <DynamixelWorkbench.h>
#include <cstdlib>

void swap(int32_t *array);

int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
const char* port_name = "/dev/ttyUSB0";
int baud_rate = 57600;
Expand Down Expand Up @@ -55,7 +56,7 @@ int main(int argc, char *argv[])
return 0;
}
else
printf("Succeed to init(%d)\n", baud_rate);
printf("Succeed to init(%d)\n", baud_rate);

for (int cnt = 0; cnt < 2; cnt++)
{
Expand All @@ -69,6 +70,7 @@ int main(int argc, char *argv[])
{
printf("Succeeded to ping\n");
printf("id : %d, model_number : %d\n", dxl_id[cnt], model_number);
printf("model_name : %s\n", dxl_wb.getModelName(dxl_id[cnt]));
}

result = dxl_wb.jointMode(dxl_id[cnt], 0, 0, &log);
Expand Down Expand Up @@ -101,7 +103,10 @@ int main(int argc, char *argv[])
int32_t present_position[2] = {0, 0};

const uint8_t handler_index = 0;


const char* modelName1 = dxl_wb.getModelName(dxl_id[0]);
const char* modelName2 = dxl_wb.getModelName(dxl_id[1]);

while(1)
{
result = dxl_wb.syncWrite(handler_index, &goal_position[0], &log);
Expand All @@ -124,14 +129,20 @@ int main(int argc, char *argv[])
if (result == false)
{
printf("%s\n", log);
if(!strncmp(modelName1, "AX-12", strlen("AX-12")) ||
!strncmp(modelName2, "AX-12", strlen("AX-12")))
{
printf("AX-12 does NOT support syncRead \n");
return -1;
}
}
else
{
printf("[ID %d]\tGoal Position : %d\tPresent Position : %d, [ID %d]\tGoal Position : %d\tPresent Position : %d\n"
,dxl_id[0], goal_position[0], present_position[0], dxl_id[1], goal_position[1], present_position[1]);
}

}while(abs(goal_position[0] - present_position[0]) > 15 &&
}while(abs(goal_position[0] - present_position[0]) > 15 &&
abs(goal_position[1] - present_position[1]) > 15);

swap(goal_position);
Expand All @@ -145,4 +156,4 @@ void swap(int32_t *array)
int32_t tmp = array[0];
array[0] = array[1];
array[1] = tmp;
}
}
Loading

0 comments on commit 6b94826

Please sign in to comment.