Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
fmauch committed Nov 22, 2022
1 parent 0b28fb5 commit b52d6b9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
7 changes: 1 addition & 6 deletions examples/dashboard_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,8 @@ using namespace urcl;
// better configuration system such as Boost.Program_options
const std::string DEFAULT_ROBOT_IP = "127.0.0.1";

std::unique_ptr<DashboardClient> my_dashboard;

// We need a callback function to register. See UrDriver's parameters for details.
void handleRobotProgramState(bool program_running)
{
// Print the text in green so we see it better
std::cout << "\033[1;32mProgram running: " << std::boolalpha << program_running << "\033[0m\n" << std::endl;
}

int main(int argc, char* argv[])
{
Expand All @@ -51,6 +45,7 @@ int main(int argc, char* argv[])

// Making the robot ready for the program by:
// Connect the the robot Dashboard
std::unique_ptr<DashboardClient> my_dashboard;
my_dashboard.reset(new DashboardClient(robot_ip));
if (!my_dashboard->connect())
{
Expand Down
16 changes: 8 additions & 8 deletions examples/full_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const std::string INPUT_RECIPE = "examples/resources/rtde_input_recipe.txt";
const std::string CALIBRATION_CHECKSUM = "calib_12788084448423163542";

std::unique_ptr<UrDriver> g_my_driver;
std::unique_ptr<DashboardClient> my_dashboard;
std::unique_ptr<DashboardClient> g_my_dashboard;
vector6d_t g_joint_positions;

// We need a callback function to register. See UrDriver's parameters for details.
Expand All @@ -69,36 +69,36 @@ int main(int argc, char* argv[])

// Making the robot ready for the program by:
// Connect the the robot Dashboard
my_dashboard.reset(new DashboardClient(robot_ip));
if (!my_dashboard->connect())
g_my_dashboard.reset(new DashboardClient(robot_ip));
if (!g_my_dashboard->connect())
{
URCL_LOG_ERROR("Could not connect to dashboard");
return 1;
}

// Stop program, if there is one running
if (!my_dashboard->commandStop())
if (!g_my_dashboard->commandStop())
{
URCL_LOG_ERROR("Could not send stop program command");
return 1;
}

// Power it on
if (!my_dashboard->commandPowerOff())
// Power it off
if (!g_my_dashboard->commandPowerOff())
{
URCL_LOG_ERROR("Could not send Power off command");
return 1;
}

// Power it on
if (!my_dashboard->commandPowerOn())
if (!g_my_dashboard->commandPowerOn())
{
URCL_LOG_ERROR("Could not send Power on command");
return 1;
}

// Release the brakes
if (!my_dashboard->commandBrakeRelease())
if (!g_my_dashboard->commandBrakeRelease())
{
URCL_LOG_ERROR("Could not send BrakeRelease command");
return 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/primary_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main(int argc, char* argv[])
robot_ip = std::string(argv[1]);
}

// Parse how may seconds to run
// Parse how many seconds to run
int second_to_run = -1;
if (argc > 2)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ur/dashboard_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool DashboardClient::waitForReply(const std::string& command, const std::string
// Send the request
response = sendAndReceive(command + "\n");

// Check it the response was as expected
// Check if the response was as expected
if (std::regex_match(response, std::regex(expected)))
{
return true;
Expand Down

0 comments on commit b52d6b9

Please sign in to comment.