Skip to content

Commit

Permalink
sample bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
tmori committed Jan 21, 2024
1 parent f5e36e6 commit d3fad51
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
22 changes: 13 additions & 9 deletions examples/pdu_communication/src/asset_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,26 @@ static int my_on_manual_timing_control(hako_asset_context_t* context)
int result = 0;
double count = 0;
while (result == 0) {
int ret = hako_asset_pdu_read("Robot", PDU_POS_CHANNEL_ID, (char*)(&pos), sizeof(pos));
motor.linear.x = count + 1001;
motor.linear.y = count + 1002;
motor.linear.z = count + 1003;
int ret = hako_asset_pdu_write("Robot", PDU_MOTOR_CHANNEL_ID, (const char*)(&motor), sizeof(motor));
if (ret != 0) {
printf("ERROR: hako_asset_pdu_read erro: %d\n", ret);
printf("ERROR: hako_asset_pdu_write erro: %d\n", ret);
}
result = hako_asset_usleep(1000);
if (result != 0) {
break;
}
printf("%llu: pos data(%f, %f, %f)\n", hako_asset_simulation_time(), pos.linear.x, pos.linear.y, pos.linear.z);

motor.linear.x = count + 1000;
motor.linear.y = count + 1000;
motor.linear.z = count + 1000;
ret = hako_asset_pdu_write("Robot", PDU_MOTOR_CHANNEL_ID, (const char*)(&motor), sizeof(motor));
ret = hako_asset_pdu_read("Robot", PDU_POS_CHANNEL_ID, (char*)(&pos), sizeof(pos));
if (ret != 0) {
printf("ERROR: hako_asset_pdu_write erro: %d\n", ret);
printf("ERROR: hako_asset_pdu_read erro: %d\n", ret);
}
printf("%llu: pos data(%f, %f, %f)\n", hako_asset_simulation_time(), pos.linear.x, pos.linear.y, pos.linear.z);

usleep(1000*1000);
result = hako_asset_usleep(1000);
usleep(1000*1000);
count++;
}
printf("INFO: on_manual_timing_control exit\n");
Expand Down
19 changes: 12 additions & 7 deletions examples/pdu_communication/src/asset_plant.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,27 @@ static int my_on_manual_timing_control(hako_asset_context_t* context)
int result = 0;
double count = 0;
while (result == 0) {
int ret = hako_asset_pdu_read("Robot", PDU_MOTOR_CHANNEL_ID, (char*)(&motor), sizeof(motor));
pos.linear.x = count + 1;
pos.linear.y = count + 2;
pos.linear.z = count + 3;
int ret = hako_asset_pdu_write("Robot", PDU_POS_CHANNEL_ID, (const char*)(&pos), sizeof(pos));
if (ret != 0) {
printf("ERROR: hako_asset_pdu_read erro: %d\n", ret);
}
printf("%llu: motor data(%f, %f, %f)\n", hako_asset_simulation_time(), motor.linear.x, motor.linear.y, motor.linear.z);
result = hako_asset_usleep(1000);
if (result != 0) {
break;
}

pos.linear.x = count + 1;
pos.linear.y = count + 2;
pos.linear.z = count + 3;
ret = hako_asset_pdu_write("Robot", PDU_POS_CHANNEL_ID, (const char*)(&pos), sizeof(pos));
ret = hako_asset_pdu_read("Robot", PDU_MOTOR_CHANNEL_ID, (char*)(&motor), sizeof(motor));
if (ret != 0) {
printf("ERROR: hako_asset_pdu_read erro: %d\n", ret);
}
printf("%llu: motor data(%f, %f, %f)\n", hako_asset_simulation_time(), motor.linear.x, motor.linear.y, motor.linear.z);


usleep(1000*1000);
result = hako_asset_usleep(1000);
usleep(1000*1000);
count++;
}
printf("INFO: on_manual_timing_control exit\n");
Expand Down

0 comments on commit d3fad51

Please sign in to comment.