-
Notifications
You must be signed in to change notification settings - Fork 0
Added commands, version check and now throws exception #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: pr
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"; | ||
|
||
std::unique_ptr<DashboardClient> my_dashboard; | ||
|
||
|
@@ -64,6 +65,8 @@ int main(int argc, char* argv[]) | |
return 1; | ||
} | ||
|
||
my_dashboard->commandCloseSafetyPopup(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment on why this is a good idea. |
||
|
||
// Power it on | ||
if (!my_dashboard->commandPowerOn()) | ||
{ | ||
|
@@ -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; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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. | ||||||
*/ | ||||||
|
@@ -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 | ||||||
* | ||||||
|
@@ -136,7 +147,7 @@ class DashboardClient : public comm::TCPSocket | |||||
* | ||||||
* \return True succeeded | ||||||
*/ | ||||||
bool commandBreakeRelease(); | ||||||
bool commandBrakeRelease(); | ||||||
|
||||||
/*! | ||||||
* \brief Send Load program command | ||||||
|
@@ -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 | ||||||
* | ||||||
|
@@ -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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* | ||||||
* \return True succeeded | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*/ | ||||||
bool commandIsProgramSaved(); | ||||||
|
||||||
/*! | ||||||
* \brief Send Is in remote control command | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* | ||||||
* \return True succeeded | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*/ | ||||||
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_; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest reverting this line