@@ -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
99121ExampleRobotWrapper::~ExampleRobotWrapper ()
0 commit comments