Dashboard client example
This example shows how to use the builtin Dashboard server to communicate with a robot.
Note
The Dashboard Server euqivalent for PolyScope X is called the Robot API. In the client library it is accessed through the DashboardClient, as well, as it is meant as a replacement for the Dashboard Server. It doesn’t offer full feature parity at the time of writing and is available only from Software 10.11.0 on.
The dashboard_example.cpp shows how to use this class:
Note
For the following example to work, the robot has to be in remote control mode. CB3 robots don’t require that.
62 // Query the robot information from the primary interface in order to select the correct
63 // implementation policy.
64 urcl::comm::INotifier notifier;
65 urcl::primary_interface::PrimaryClient primary_client(robot_ip, notifier);
66 primary_client.start();
67 auto version_information = primary_client.getRobotVersion();
68 DashboardClient::ClientPolicy policy = DashboardClient::ClientPolicy::POLYSCOPE_X;
69 if (version_information->major < 10)
70 {
71 policy = DashboardClient::ClientPolicy::G5;
72 }
73 else if (version_information->minor < 12)
74 {
75 // We need isInRemoteControl for PolyScope X, which is only supported from version 10.12.0 on.
76 URCL_LOG_ERROR("DashboardClient examples require PolyScope version 10.12.0 or higher. Exiting now.");
77 return 0;
78 }
79
80 // Connect to the robot Dashboard Server
81 auto my_dashboard = std::make_unique<DashboardClient>(robot_ip, policy);
82 if (!my_dashboard->connect())
83 {
84 URCL_LOG_ERROR("Could not connect to dashboard");
85 return 1;
86 }
87
88 bool robot_in_remote_control = false;
89 // CB3 doesn't have remote control
90 if (version_information->major >= 5)
91 {
92 robot_in_remote_control = my_dashboard->commandIsInRemoteControl();
93 }
94
95 // Bring the robot to a defined state being powered off.
96 if (version_information->major < 10)
97 {
98 if (!my_dashboard->commandPowerOff())
99 {
100 URCL_LOG_ERROR("Could not send power off");
101 return 1;
102 }
103 // Get the PolyScope version
104 std::string version;
105 my_dashboard->commandPolyscopeVersion(version);
106 URCL_LOG_INFO(version.c_str());
107
108 my_dashboard->commandCloseSafetyPopup();
At first, a DashboardClient object is created with the IP address of the robot and a
DashboardClient implementation policy. That policy can be either POLYSCOPE_X or G5. To
generalize this, the robot’s sofware version is queried using the primary interface beforehand.
Then, the client is connected to the robot. After that, the client sends a command to the robot and
receives the answer.
Some commands support getting the response from the robot. For example, the
commandPolyScopeVersion() function:
103 // Get the PolyScope version
104 std::string version;
105 my_dashboard->commandPolyscopeVersion(version);
106 URCL_LOG_INFO(version.c_str());
The DashboardClient can easily be used to cycle through the robot’s states, for example for
initialization:
117 // Power it on
118 if (version_information->major < 10 || robot_in_remote_control)
119 {
120 if (!my_dashboard->commandPowerOn())
121 {
122 URCL_LOG_ERROR("Could not send Power on command");
123 return 1;
124 }
125
126 // Release the brakes
127 if (!my_dashboard->commandBrakeRelease())
128 {
129 URCL_LOG_ERROR("Could not send BrakeRelease command");
130 return 1;
131 }