diff --git a/examples/pdu_communication/src/asset_controller.c b/examples/pdu_communication/src/asset_controller.c index 6bbbb08..2dbfa2d 100644 --- a/examples/pdu_communication/src/asset_controller.c +++ b/examples/pdu_communication/src/asset_controller.c @@ -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"); diff --git a/examples/pdu_communication/src/asset_plant.c b/examples/pdu_communication/src/asset_plant.c index f405c91..111c1b2 100644 --- a/examples/pdu_communication/src/asset_plant.c +++ b/examples/pdu_communication/src/asset_plant.c @@ -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");