Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions examples/dashboard_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@

#include <iostream>
#include <memory>
#include <thread>

using namespace urcl;

// In a real-world example it would be better to get those values from command line parameters / a
// better configuration system such as Boost.Program_options
const std::string DEFAULT_ROBOT_IP = "127.0.0.1";
const std::string DEFAULT_ROBOT_IP = "10.53.253.22";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const std::string DEFAULT_ROBOT_IP = "10.53.253.22";
const std::string DEFAULT_ROBOT_IP = "127.0.0.1";

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest reverting this line


std::unique_ptr<DashboardClient> my_dashboard;

Expand Down Expand Up @@ -64,6 +65,8 @@ int main(int argc, char* argv[])
return 1;
}

my_dashboard->commandCloseSafetyPopup();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment on why this is a good idea.
Remember this is an example to get people started


// Power it on
if (!my_dashboard->commandPowerOn())
{
Expand All @@ -72,9 +75,9 @@ int main(int argc, char* argv[])
}

// Release the brakes
if (!my_dashboard->commandBreakeRelease())
if (!my_dashboard->commandBrakeRelease())
{
URCL_LOG_ERROR("Could not send BreakeRelease command");
URCL_LOG_ERROR("Could not send BrakeRelease command");
return 1;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/full_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ int main(int argc, char* argv[])
}

// Release the brakes
if (!my_dashboard->commandBreakeRelease())
if (!my_dashboard->commandBrakeRelease())
{
URCL_LOG_ERROR("Could not send BreakeRelease command");
URCL_LOG_ERROR("Could not send BrakeRelease command");
return 1;
}

Expand Down
223 changes: 221 additions & 2 deletions include/ur_client_library/ur/dashboard_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DashboardClient : public comm::TCPSocket
const int DASHBOARD_SERVER_PORT = 29999;

/*!
* \brief Opens a connection to the dasboard server on the host as specified in the constructor.
* \brief Opens a connection to the dashboard server on the host as specified in the constructor.
*
* \returns True on successful connection, false otherwise.
*/
Expand Down Expand Up @@ -89,6 +89,17 @@ class DashboardClient : public comm::TCPSocket
*/
bool sendRequest(const std::string& command, const std::string& expected);

/*!
* \brief Sends command and compare it with the expected answer
*
* \param command Command that will be sent to the server. It is important, that the command sent is finished with a
* '\n' (newline) so it will be processed by the server.
* \param expected Expected replay
*
* \return Answer string as received by the server
*/
std::string sendRequestString(const std::string& command, const std::string& expected);

/*!
* \brief brief Sends a command and wait until it returns the expected answer
*
Expand Down Expand Up @@ -136,7 +147,7 @@ class DashboardClient : public comm::TCPSocket
*
* \return True succeeded
*/
bool commandBreakeRelease();
bool commandBrakeRelease();

/*!
* \brief Send Load program command
Expand All @@ -147,6 +158,15 @@ class DashboardClient : public comm::TCPSocket
*/
bool commandLoadProgram(const std::string& program_file_name);

/*!
* \brief Send Load installation command
*
* \param installation_file_name The installation file name with the installation extension
*
* \return True succeeded
*/
bool commandLoadInstallation(const std::string& installation_file_name);

/*!
* \brief Send Play program command
*
Expand Down Expand Up @@ -203,17 +223,216 @@ class DashboardClient : public comm::TCPSocket
*/
bool commandShutdown();

/*!
* \brief Send Quit command
*
* \return True succeeded
*/
bool commandQuit();

/*!
* \brief Send Running command
*
* \return True succeeded
*/
bool commandRunning();

/*!
* \brief Send Is program saved command
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* \brief Send Is program saved command
* \brief Send "Is program saved" request command

*
* \return True succeeded
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* \return True succeeded
* \return True if the program saved

*/
bool commandIsProgramSaved();

/*!
* \brief Send Is in remote control command
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* \brief Send Is in remote control command
* \brief Send "Is in remote control" request command

*
* \return True succeeded
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* \return True succeeded
* \return True if it is in remote control

*/
bool commandIsInRemoteControl();

/*!
* \brief Send popup command
*
* \param popup_text The text to be shown in the popup
*
* \return True succeeded
*/
bool commandPopup(const std::string& popup_text);

/*!
* \brief Send text to log
*
* \param log_text The text to be sent to the log
*
* \return True succeeded
*/
bool commandAddToLog(const std::string& log_text);

/*!
* \brief Get Polyscope version
*
* \param polyscope_version The string for the polyscope version number returned
*
* \return True succeeded
*/
bool commandPolyscopeVersion(std::string& polyscope_version);

/*!
* \brief Get Robot model
*
* \param robot_model The string for the robot model returned
*
* \return True succeeded
*/
bool commandGetRobotModel(std::string& robot_model);

/*!
* \brief Get Serial number
*
* \param serial_number The serial number of the robot returned
*
* \return True succeeded
*/
bool commandGetSerialNumber(std::string& serial_number);

/*!
* \brief Get Robot mode
*
* \param robot_mode The mode of the robot returned
*
* \return True succeeded
*/
bool commandRobotMode(std::string& robot_mode);

/*!
* \brief Get Loaded Program
*
* \param loaded_program The path to the loaded program
*
* \return True succeeded
*/
bool commandGetLoadedProgram(std::string& loaded_program);

/*!
* \brief Get Safety mode
*
* \param safety_mode The safety mode of the robot returned
*
* \return True succeeded
*/
bool commandSafetyMode(std::string& safety_mode);

/*!
* \brief Get Safety status
*
* \param safety_status The safety status of the robot returned
*
* \return True succeeded
*/
bool commandSafetyStatus(std::string& safety_status);

/*!
* \brief Get Program state
*
* \param program_state The program state of the robot returned
*
* \return True succeeded
*/
bool commandProgramState(std::string& program_state);

/*!
* \brief Get Operational mode
*
* \param operational_mode The operational mode of the robot returned (Only available for e-series)
*
* \return True succeeded
*/
bool commandGetOperationalMode(std::string& operational_mode);

/*!
* \brief Send Set operational mode command (Only available for e-series)
*
* \param operational_mode The operational mode to set on the robot
*
* \return True succeeded
*/
bool commandSetOperationalMode(const std::string& operational_mode);

/*!
* \brief Send Clear operational mode command
*
* \return True succeeded
*/
bool commandClearOperationalMode();

/*!
* \brief Send Set user role command (Only available for CB3)
*
* \param user_role The user role to set on the robot
*
* \return True succeeded
*/
bool commandSetUserRole(const std::string& user_role);

/*!
* \brief Send Get user role command (Only available for CB3)
*
* \param user_role The user role on the robot
*
* \return True succeeded
*/
bool commandGetUserRole(std::string& user_role);

/*!
* \brief Send Generate flight report command
*
* \param report_type The report type to set for the flight report
*
* \return True succeeded
*/
bool commandGenerateFlightReport(const std::string& report_type);

/*!
* \brief Send Generate support file command
*
* \param dir_path The path to the directory of an already existing directory location inside the programs directory,
* where the support file is saved
*
* \return True succeeded
*/
bool commandGenerateSupportFile(const std::string& dir_path);

protected:
virtual bool open(int socket_fd, struct sockaddr* address, size_t address_len)
{
return ::connect(socket_fd, address, address_len) == 0;
}

private:
/*!
* \brief Parse input for comparison of sw versions
*
* \param result Parsed result
* \param input Input sw version string
*/
void parseSWVersion(int result[4], const std::string& input);
/*!
* \brief Compare two sw versions
*
* \param a Sw version string for e-series
* \param b Sw version string for cb3
* \param c Sw version string read from robot
*
* \return If a/b is less than c return true else return false
*/
bool lessThanVersion(const std::string& a, const std::string& b, const std::string& c);
bool send(const std::string& text);
std::string read();
void rtrim(std::string& str, const std::string& chars = "\t\n\v\f\r ");

bool e_series_; // Is the robot e-series or cb3
std::string polyscope_version_;
std::string host_;
int port_;
std::mutex write_mutex_;
Expand Down
Loading