This example demonstrates joint control using MIT_INTEGRATED mode.
#include <array>
#include <cmath>
#include <thread>
#include <chrono>
int main() {
auto sdk = std::make_shared<AirbotSdk>("192.168.0.xxx", 50051);
sdk->SwitchMode({"arm"}, {RobotMode::PLANNING_POS});
std::array<double, 6> init_pos = {0.0, -1.19, 1.17, -1.55, 1.51, 0.0};
sdk->MoveToJointPos(init_pos);
sdk->SwitchMode({"arm"}, {RobotMode::MIT_INTEGRATED});
std::array<double, 6> &pos = init_pos;
const std::array<double, 6> vel = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
const std::array<double, 6> eff = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
const std::array<double, 6> kp = {90.0, 150.0, 150.0, 25.0, 25.0, 25.0};
const std::array<double, 6> kd = {2.5, 1.75, 1.5, 0.5, 1.5, 0.5};
double joint1_upper = 1.57;
double joint1_lower = -1.57;
double delta_pos = 0.0015;
int direction = 1;
constexpr int loop_count = 8000;
constexpr double interval_ms = 0.8 / 250 * 1000;
for (int i = 0; i < loop_count; ++i) {
sdk->MitJointIntegratedControl(pos, vel, eff, kp, kd);
pos[0] += direction * delta_pos;
if (pos[0] >= joint1_upper || pos[0] <= joint1_lower) {
direction *= -1;
}
}
std::this_thread::sleep_for(std::chrono::seconds(1) +
std::chrono::microseconds(static_cast<int>(loop_count * interval_ms * 1000)));
sdk->SwitchMode({"arm"}, {RobotMode::PLANNING_POS});
sdk->MoveToJointPos(init_pos);
return 0;
}
Main SDK interface for controlling Airbot robotic arm.
Namespace containing all Airbot SDK related definitions.