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 < 11)
 74  {
 75    URCL_LOG_ERROR("DashboardClient examples require PolyScope version 10.11.0 or higher. Exiting now.");
 76    return 0;
 77  }
 78
 79  // Connect to the robot Dashboard Server
 80  auto my_dashboard = std::make_unique<DashboardClient>(robot_ip, policy);
 81  if (!my_dashboard->connect())
 82  {
 83    URCL_LOG_ERROR("Could not connect to dashboard");
 84    return 1;
 85  }
 86
 87  // Bring the robot to a defined state being powered off.
 88  if (version_information->major < 10)
 89  {
 90    if (!my_dashboard->commandPowerOff())
 91    {
 92      URCL_LOG_ERROR("Could not send power off");
 93      return 1;
 94    }
 95    // Get the PolyScope version
 96    std::string version;
 97    my_dashboard->commandPolyscopeVersion(version);
 98    URCL_LOG_INFO(version.c_str());
 99
100    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:
95    // Get the PolyScope version
96    std::string version;
97    my_dashboard->commandPolyscopeVersion(version);
98    URCL_LOG_INFO(version.c_str());
The DashboardClient can easily be used to cycle through the robot’s states, for example for
initialization:
109  // Power it on
110  if (!my_dashboard->commandPowerOn())
111  {
112    URCL_LOG_ERROR("Could not send Power on command");
113    return 1;
114  }
115
116  // Release the brakes
117  if (!my_dashboard->commandBrakeRelease())
118  {
119    URCL_LOG_ERROR("Could not send BrakeRelease command");
120    return 1;
121  }