This tutorial runs an automatic recovery process if the robot's safety system is in recovery state. See rdk::Robot::recovery() and RDK manual for more details.
- Copyright
- Copyright (C) 2016-2024 Flexiv Ltd. All Rights Reserved.
- Author
- Flexiv
#include <spdlog/spdlog.h>
#include <iostream>
#include <string>
#include <thread>
using namespace flexiv;
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 ||
rdk::utility::ProgramArgsExistAny(argc, argv, {
"-h",
"--help"})) {
PrintHelp();
return 1;
}
std::string robot_sn = argv[1];
spdlog::info(
">>> Tutorial description <<<\nThis tutorial runs an automatic recovery process if the "
"robot's safety system is in recovery state. See rdk::Robot::recovery() and RDK "
"manual for more details.\n");
try {
rdk::Robot robot(robot_sn);
spdlog::info("Enabling robot ...");
robot.Enable();
std::this_thread::sleep_for(std::chrono::seconds(8));
if (robot.recovery()) {
robot.RunAutoRecovery();
}
else {
spdlog::info("Robot system is not in recovery state, nothing to be done, exiting ...");
}
} catch (const std::exception& e) {
spdlog::error(e.what());
return 1;
}
return 0;
}