This tutorial zeros the robot's force and torque sensors, which is a recommended (but not mandatory) step before any operations that require accurate force/torque measurement.
#include <spdlog/spdlog.h>
#include <iostream>
#include <thread>
void PrintHelp()
{
std::cout << "Required arguments: [robot SN]" << std::endl;
std::cout << " robot SN: Serial number of the robot to connect to. "
"Remove any space, for example: Rizon4s-123456" << std::endl;
std::cout << "Optional arguments: None" << std::endl;
std::cout << std::endl;
}
int main(int argc, char* argv[])
{
if (argc < 2 ||
flexiv::rdk::utility::ProgramArgsExistAny(argc, argv, {
"-h",
"--help"})) {
PrintHelp();
return 1;
}
std::string robot_sn = argv[1];
spdlog::info(
">>> Tutorial description <<<\nThis tutorial zeros the robot's force and torque sensors, "
"which is a recommended (but not mandatory) step before any operations that require "
"accurate force/torque measurement.");
try {
if (robot.fault()) {
spdlog::warn("Fault occurred on the connected robot, trying to clear ...");
if (!robot.ClearFault()) {
spdlog::error("Fault cannot be cleared, exiting ...");
return 1;
}
spdlog::info("Fault on the connected robot is cleared");
}
spdlog::info("Enabling robot ...");
robot.Enable();
while (!robot.operational()) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
spdlog::info("Robot is now operational");
spdlog::info("TCP force and moment reading in base frame BEFORE sensor zeroing: "
+
flexiv::rdk::utility::Arr2Str(robot.states().ext_wrench_in_world)
+ "[N][Nm]");
robot.SwitchMode(
flexiv::rdk::Mode::NRT_PRIMITIVE_EXECUTION);
robot.ExecutePrimitive("ZeroFTSensor()");
spdlog::warn(
"Zeroing force/torque sensors, make sure nothing is in contact with the robot");
while (robot.busy()) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
spdlog::info("Sensor zeroing complete");
spdlog::info("TCP force and moment reading in base frame AFTER sensor zeroing: "
+ flexiv::rdk::utility::Arr2Str(robot.states().ext_wrench_in_world)
+ "[N][Nm]");
} catch (const std::exception& e) {
spdlog::error(e.what());
return 1;
}
return 0;
}
Main interface with the robot, containing several function categories and background services.