11 #include <spdlog/spdlog.h>
16 using namespace flexiv;
22 std::cout <<
"Required arguments: [robot_sn]" << std::endl;
23 std::cout <<
" robot_sn: Serial number of the robot to connect. Remove any space, e.g. Rizon4s-123456" << std::endl;
24 std::cout <<
"Optional arguments: None" << std::endl;
25 std::cout << std::endl;
29 int main(
int argc,
char* argv[])
34 if (argc < 2 || rdk::utility::ProgramArgsExistAny(argc, argv, {
"-h",
"--help"})) {
39 std::string robot_sn = argv[1];
43 ">>> Tutorial description <<<\nThis tutorial zeros the robot's force and torque sensors, "
44 "which is a recommended (but not mandatory) step before any operations that require "
45 "accurate force/torque measurement.\n");
55 spdlog::warn(
"Fault occurred on the connected robot, trying to clear ...");
57 if (!robot.ClearFault()) {
58 spdlog::error(
"Fault cannot be cleared, exiting ...");
61 spdlog::info(
"Fault on the connected robot is cleared");
65 spdlog::info(
"Enabling robot ...");
69 while (!robot.operational()) {
70 std::this_thread::sleep_for(std::chrono::seconds(1));
72 spdlog::info(
"Robot is now operational");
77 spdlog::info(
"TCP force and moment reading in world frame BEFORE sensor zeroing: "
78 + rdk::utility::Arr2Str(robot.states().ext_wrench_in_world) +
"[N][Nm]");
81 robot.SwitchMode(rdk::Mode::NRT_PRIMITIVE_EXECUTION);
82 robot.ExecutePrimitive(
"ZeroFTSensor", std::map<std::string, rdk::FlexivDataTypes> {});
87 "Zeroing force/torque sensors, make sure nothing is in contact with the robot");
90 while (robot.busy()) {
91 std::this_thread::sleep_for(std::chrono::seconds(1));
93 spdlog::info(
"Sensor zeroing complete");
96 spdlog::info(
"TCP force and moment reading in world frame AFTER sensor zeroing: "
97 + rdk::utility::Arr2Str(robot.states().ext_wrench_in_world) +
"[N][Nm]");
99 }
catch (
const std::exception& e) {
100 spdlog::error(e.what());
Main interface with the robot, containing several function categories and background services.