Skip to content
Merged
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
2 changes: 2 additions & 0 deletions include/ur_client_library/example_robot_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ class ExampleRobotWrapper
private:
void handleRobotProgramState(bool program_running);

void initInternal(const UrDriverConfiguration& driver_config);

//! Dashboard client to interact with the robot
std::shared_ptr<urcl::DashboardClient> dashboard_client_;

Expand Down
48 changes: 34 additions & 14 deletions src/example_robot_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,36 @@ ExampleRobotWrapper::ExampleRobotWrapper(const std::string& robot_ip, const std:
const std::string& autostart_program, const std::string& script_file)
: headless_mode_(headless_mode), autostart_program_(autostart_program)
{
primary_client_ = std::make_shared<urcl::primary_interface::PrimaryClient>(robot_ip, notifier_);
UrDriverConfiguration driver_config;
driver_config.robot_ip = robot_ip;
driver_config.script_file = script_file;
driver_config.output_recipe_file = output_recipe_file;
driver_config.input_recipe_file = input_recipe_file;
driver_config.handle_program_state =
std::bind(&ExampleRobotWrapper::handleRobotProgramState, this, std::placeholders::_1);
driver_config.headless_mode = headless_mode;
initInternal(driver_config);
}

ExampleRobotWrapper::ExampleRobotWrapper(const std::string& robot_ip, const std::vector<std::string> output_recipe,
const std::vector<std::string> input_recipe, const bool headless_mode,
const std::string& autostart_program, const std::string& script_file)
: headless_mode_(headless_mode), autostart_program_(autostart_program)
{
UrDriverConfiguration driver_config;
driver_config.robot_ip = robot_ip;
driver_config.script_file = script_file;
driver_config.output_recipe = output_recipe;
driver_config.input_recipe = input_recipe;
driver_config.handle_program_state =
std::bind(&ExampleRobotWrapper::handleRobotProgramState, this, std::placeholders::_1);
driver_config.headless_mode = headless_mode;
initInternal(driver_config);
}

void ExampleRobotWrapper::initInternal(const UrDriverConfiguration& driver_config)
{
primary_client_ = std::make_shared<urcl::primary_interface::PrimaryClient>(driver_config.robot_ip, notifier_);

primary_client_->start();

Expand All @@ -52,7 +81,7 @@ ExampleRobotWrapper::ExampleRobotWrapper(const std::string& robot_ip, const std:
const DashboardClient::ClientPolicy client_policy = *robot_version < VersionInformation::fromString("10.0.0") ?
DashboardClient::ClientPolicy::G5 :
DashboardClient::ClientPolicy::POLYSCOPE_X;
dashboard_client_ = std::make_shared<DashboardClient>(robot_ip, client_policy);
dashboard_client_ = std::make_shared<DashboardClient>(driver_config.robot_ip, client_policy);
// Connect the robot Dashboard
if (!dashboard_client_->connect())
{
Expand All @@ -71,23 +100,14 @@ ExampleRobotWrapper::ExampleRobotWrapper(const std::string& robot_ip, const std:
{
throw UrException("Could not initialize robot with primary client");
}

UrDriverConfiguration driver_config;
driver_config.robot_ip = robot_ip;
driver_config.script_file = script_file;
driver_config.output_recipe_file = output_recipe_file;
driver_config.input_recipe_file = input_recipe_file;
driver_config.handle_program_state =
std::bind(&ExampleRobotWrapper::handleRobotProgramState, this, std::placeholders::_1);
driver_config.headless_mode = headless_mode;
ur_driver_ = std::make_shared<UrDriver>(driver_config);

if (!headless_mode && !std::empty(autostart_program))
if (!headless_mode_ && !std::empty(autostart_program_))
{
startRobotProgram(autostart_program);
startRobotProgram(autostart_program_);
}

if (headless_mode || !std::empty(autostart_program))
if (headless_mode_ || !std::empty(autostart_program_))
{
if (!waitForProgramRunning(500))
{
Expand Down
27 changes: 16 additions & 11 deletions tests/test_ur_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const std::string SCRIPT_FILE = "../resources/external_control.urscript";
const std::string OUTPUT_RECIPE = "resources/rtde_output_recipe.txt";
const std::string INPUT_RECIPE = "resources/rtde_input_recipe.txt";
const std::vector<std::string> OUTPUT_RECIPE_VECTOR = { "timestamp",
"actual_q",
"actual_qd",
"speed_scaling",
"target_speed_fraction",
Expand All @@ -66,19 +67,23 @@ const std::vector<std::string> OUTPUT_RECIPE_VECTOR = { "timestamp",
"robot_mode",
"safety_mode",
"robot_status_bits",
"safety_status_bits",
"actual_current",
"tcp_offset" };
const std::vector<std::string> INPUT_RECIPE_VECTOR = {
"speed_slider_mask", "standard_digital_output_mask",
"standard_digital_output", "configurable_digital_output_mask",
"configurable_digital_output", "tool_digital_output_mask",
"tool_digital_output", "standard_analog_output_mask",
"standard_analog_output_type", "standard_analog_output_0",
"standard_analog_output_1"
"speed_slider_fraction",
"speed_slider_mask",
"standard_digital_output_mask",
"standard_digital_output",
"configurable_digital_output_mask",
"configurable_digital_output",
"tool_digital_output_mask",
"tool_digital_output",
"standard_analog_output_mask",
"standard_analog_output_type",
"standard_analog_output_0",
};
const std::string OUTPUT_RECIPE_VECTOR_EXCLUDED_VALUE = "actual_q";
const std::string INPUT_RECIPE_VECTOR_EXCLUDED_VALUE = "speed_slider_fraction";
const std::string OUTPUT_RECIPE_VECTOR_EXCLUDED_VALUE = "safety_status_bits";
const std::string INPUT_RECIPE_VECTOR_EXCLUDED_VALUE = "standard_analog_output_1";
const std::string CALIBRATION_CHECKSUM = "calib_12788084448423163542";
std::string g_ROBOT_IP = "192.168.56.101";
bool g_HEADLESS = true;
Expand All @@ -95,8 +100,8 @@ class UrDriverTest : public ::testing::Test
GTEST_SKIP_("Running URCap tests for PolyScope X is currently not supported.");
}
// Setup driver
g_my_robot = std::make_unique<ExampleRobotWrapper>(g_ROBOT_IP, OUTPUT_RECIPE, INPUT_RECIPE, g_HEADLESS,
"external_control.urp", SCRIPT_FILE);
g_my_robot = std::make_unique<ExampleRobotWrapper>(g_ROBOT_IP, OUTPUT_RECIPE_VECTOR, INPUT_RECIPE_VECTOR,
g_HEADLESS, "external_control.urp", SCRIPT_FILE);

g_my_robot->startRTDECommununication(true);
}
Expand Down
Loading