Skip to content

Commit c4fad15

Browse files
committed
Add implementation of creating ExampleRobotWrapper with recipe vectors
The signature was added earlier, but the implementation was missing
1 parent 3a272a7 commit c4fad15

3 files changed

Lines changed: 39 additions & 15 deletions

File tree

include/ur_client_library/example_robot_wrapper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ class ExampleRobotWrapper
181181
private:
182182
void handleRobotProgramState(bool program_running);
183183

184+
void initInternal(const UrDriverConfiguration& driver_config);
185+
184186
//! Dashboard client to interact with the robot
185187
std::shared_ptr<urcl::DashboardClient> dashboard_client_;
186188

src/example_robot_wrapper.cpp

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,37 @@ ExampleRobotWrapper::ExampleRobotWrapper(const std::string& robot_ip, const std:
4141
const std::string& autostart_program, const std::string& script_file)
4242
: headless_mode_(headless_mode), autostart_program_(autostart_program)
4343
{
44-
primary_client_ = std::make_shared<urcl::primary_interface::PrimaryClient>(robot_ip, notifier_);
44+
UrDriverConfiguration driver_config;
45+
driver_config.robot_ip = robot_ip;
46+
driver_config.script_file = script_file;
47+
driver_config.output_recipe_file = output_recipe_file;
48+
driver_config.input_recipe_file = input_recipe_file;
49+
driver_config.handle_program_state =
50+
std::bind(&ExampleRobotWrapper::handleRobotProgramState, this, std::placeholders::_1);
51+
driver_config.headless_mode = headless_mode;
52+
initInternal(driver_config);
53+
}
54+
55+
ExampleRobotWrapper::ExampleRobotWrapper(const std::string& robot_ip, const std::vector<std::string> output_recipe,
56+
const std::vector<std::string> input_recipe, const bool headless_mode,
57+
const std::string& autostart_program, const std::string& script_file)
58+
: headless_mode_(headless_mode), autostart_program_(autostart_program)
59+
{
60+
61+
UrDriverConfiguration driver_config;
62+
driver_config.robot_ip = robot_ip;
63+
driver_config.script_file = script_file;
64+
driver_config.output_recipe = output_recipe;
65+
driver_config.input_recipe = input_recipe;
66+
driver_config.handle_program_state =
67+
std::bind(&ExampleRobotWrapper::handleRobotProgramState, this, std::placeholders::_1);
68+
driver_config.headless_mode = headless_mode;
69+
initInternal(driver_config);
70+
}
71+
72+
void ExampleRobotWrapper::initInternal(const UrDriverConfiguration& driver_config)
73+
{
74+
primary_client_ = std::make_shared<urcl::primary_interface::PrimaryClient>(driver_config.robot_ip, notifier_);
4575

4676
primary_client_->start();
4777

@@ -52,7 +82,7 @@ ExampleRobotWrapper::ExampleRobotWrapper(const std::string& robot_ip, const std:
5282
const DashboardClient::ClientPolicy client_policy = *robot_version < VersionInformation::fromString("10.0.0") ?
5383
DashboardClient::ClientPolicy::G5 :
5484
DashboardClient::ClientPolicy::POLYSCOPE_X;
55-
dashboard_client_ = std::make_shared<DashboardClient>(robot_ip, client_policy);
85+
dashboard_client_ = std::make_shared<DashboardClient>(driver_config.robot_ip, client_policy);
5686
// Connect the robot Dashboard
5787
if (!dashboard_client_->connect())
5888
{
@@ -71,29 +101,21 @@ ExampleRobotWrapper::ExampleRobotWrapper(const std::string& robot_ip, const std:
71101
{
72102
throw UrException("Could not initialize robot with primary client");
73103
}
74-
75-
UrDriverConfiguration driver_config;
76-
driver_config.robot_ip = robot_ip;
77-
driver_config.script_file = script_file;
78-
driver_config.output_recipe_file = output_recipe_file;
79-
driver_config.input_recipe_file = input_recipe_file;
80-
driver_config.handle_program_state =
81-
std::bind(&ExampleRobotWrapper::handleRobotProgramState, this, std::placeholders::_1);
82-
driver_config.headless_mode = headless_mode;
83104
ur_driver_ = std::make_shared<UrDriver>(driver_config);
84105

85-
if (!headless_mode && !std::empty(autostart_program))
106+
if (!headless_mode_ && !std::empty(autostart_program_))
86107
{
87-
startRobotProgram(autostart_program);
108+
startRobotProgram(autostart_program_);
88109
}
89110

90-
if (headless_mode || !std::empty(autostart_program))
111+
if (headless_mode_ || !std::empty(autostart_program_))
91112
{
92113
if (!waitForProgramRunning(500))
93114
{
94115
throw UrException("Program did not start running. Is the robot in remote control?");
95116
}
96117
}
118+
97119
}
98120

99121
ExampleRobotWrapper::~ExampleRobotWrapper()

tests/test_ur_driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class UrDriverTest : public ::testing::Test
9595
GTEST_SKIP_("Running URCap tests for PolyScope X is currently not supported.");
9696
}
9797
// Setup driver
98-
g_my_robot = std::make_unique<ExampleRobotWrapper>(g_ROBOT_IP, OUTPUT_RECIPE, INPUT_RECIPE, g_HEADLESS,
98+
g_my_robot = std::make_unique<ExampleRobotWrapper>(g_ROBOT_IP, OUTPUT_RECIPE_VECTOR, INPUT_RECIPE_VECTOR, g_HEADLESS,
9999
"external_control.urp", SCRIPT_FILE);
100100

101101
g_my_robot->startRTDECommununication(true);

0 commit comments

Comments
 (0)