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;
34 spdlog::info(
"Current robot states:");
35 std::cout << robot.
states() << std::endl;
38 spdlog::info(
"Current digital inputs:");
39 std::cout << rdk::utility::Arr2Str(robot.
digital_inputs()) << std::endl;
40 std::this_thread::sleep_for(std::chrono::seconds(1));
44 int main(
int argc,
char* argv[])
49 if (argc < 2 || rdk::utility::ProgramArgsExistAny(argc, argv, {
"-h",
"--help"})) {
54 std::string robot_sn = argv[1];
58 ">>> Tutorial description <<<\nThis tutorial does the very first thing: check connection "
59 "with the robot server and print received robot states.\n");
69 spdlog::warn(
"Fault occurred on the connected robot, trying to clear ...");
72 spdlog::error(
"Fault cannot be cleared, exiting ...");
75 spdlog::info(
"Fault on the connected robot is cleared");
79 spdlog::info(
"Enabling robot ...");
84 std::this_thread::sleep_for(std::chrono::seconds(1));
86 spdlog::info(
"Robot is now operational");
92 std::thread low_priority_thread(std::bind(PrintRobotStates, std::ref(robot)));
95 low_priority_thread.join();
97 }
catch (
const std::exception& e) {
98 spdlog::error(e.what());
Main interface with the robot, containing several function categories and background services.
const RobotStates states() const
[Non-blocking] Current states data of the robot.
bool operational(bool verbose=true) const
[Non-blocking] Whether the robot is ready to be operated, which requires the following conditions to ...
const std::array< bool, kIOPorts > digital_inputs() const
[Non-blocking] Current reading from all digital input ports, including 16 on the control box plus 2 i...
void Enable()
[Blocking] Enable the robot, if E-stop is released and there's no fault, the robot will release brake...
bool fault() const
[Non-blocking] Whether the robot is in fault state.
bool ClearFault(unsigned int timeout_sec=30)
[Blocking] Try to clear minor or critical fault of the robot without a power cycle.