1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-12 11:00:47 +02:00

moved rtde recipe to external text file

This commit is contained in:
Tristan Schnell
2019-05-23 15:03:39 +02:00
parent 876d4a06f5
commit 649f499499
8 changed files with 37 additions and 17 deletions

View File

@@ -20,13 +20,14 @@ int main(int argc, char* argv[])
{
std::string robot_ip = "192.168.56.101";
std::string script_filename = "urprog.urscript";
std::string recipe_filename = "rtde_recipe.txt";
if (argc > 2)
{
robot_ip = argv[1];
}
UrDriver driver(robot_ip, script_filename);
UrDriver driver(robot_ip, script_filename, recipe_filename);
while (true)
{

View File

@@ -46,14 +46,21 @@ bool HardwareInterface ::init(ros::NodeHandle& root_nh, ros::NodeHandle& robot_h
joint_efforts_ = { { 0, 0, 0, 0, 0, 0 } };
std::string robot_ip = robot_hw_nh.param<std::string>("robot_ip", "192.168.56.101");
std::string script_filename;
std::string recipe_filename;
if (!robot_hw_nh.getParam("script_file", script_filename))
{
ROS_ERROR_STREAM("Required parameter " << robot_hw_nh.resolveName("script_file") << " not given.");
return false;
}
if (!robot_hw_nh.getParam("recipe_file", recipe_filename))
{
ROS_ERROR_STREAM("Required parameter " << robot_hw_nh.resolveName("recipe_file") << " not given.");
return false;
}
ROS_INFO_STREAM("Initializing urdriver");
ur_driver_.reset(new UrDriver(robot_ip, script_filename));
ur_driver_.reset(new UrDriver(robot_ip, script_filename, recipe_filename));
if (!root_nh.getParam("hardware_interface/joints", joint_names_))
{

View File

@@ -31,9 +31,10 @@ namespace ur_driver
{
namespace rtde_interface
{
RTDEClient::RTDEClient(std::string robot_ip, comm::INotifier& notifier)
RTDEClient::RTDEClient(std::string robot_ip, comm::INotifier& notifier, const std::string& recipe_file)
: stream_(robot_ip, UR_RTDE_PORT)
, parser_(readRecipe())
, recipe_(readRecipe(recipe_file))
, parser_(recipe_)
, prod_(stream_, parser_)
, pipeline_(prod_, PIPELINE_NAME, notifier)
, max_frequency_(URE_MAX_FREQUENCY)
@@ -83,11 +84,11 @@ bool RTDEClient::init()
LOG_INFO("Setting up RTDE communication with frequency %f", max_frequency_);
if (protocol_version == 2)
{
size = ControlPackageSetupOutputsRequest::generateSerializedRequest(buffer, max_frequency_, readRecipe());
size = ControlPackageSetupOutputsRequest::generateSerializedRequest(buffer, max_frequency_, recipe_);
}
else
{
size = ControlPackageSetupOutputsRequest::generateSerializedRequest(buffer, readRecipe());
size = ControlPackageSetupOutputsRequest::generateSerializedRequest(buffer, recipe_);
}
stream_.write(buffer, size, written);
return pipeline_.getLatestProduct(package, std::chrono::milliseconds(1000));
@@ -104,14 +105,16 @@ bool RTDEClient::start()
rtde_interface::ControlPackageStart* tmp = dynamic_cast<rtde_interface::ControlPackageStart*>(package.get());
return tmp->accepted_;
}
std::vector<std::string> RTDEClient::readRecipe()
std::vector<std::string> RTDEClient::readRecipe(const std::string& recipe_file)
{
std::vector<std::string> recipe;
recipe.push_back("timestamp");
recipe.push_back("actual_q");
recipe.push_back("actual_qd");
recipe.push_back("speed_scaling");
recipe.push_back("target_speed_fraction");
std::ifstream file(recipe_file);
std::string line;
while (std::getline(file, line))
{
recipe.push_back(line);
}
recipe_ = recipe;
return recipe;
}

View File

@@ -42,11 +42,12 @@ static const std::string SERVO_J_REPLACE("{{SERVO_J_REPLACE}}");
static const std::string SERVER_IP_REPLACE("{{SERVER_IP_REPLACE}}");
static const std::string SERVER_PORT_REPLACE("{{SERVER_PORT_REPLACE}}");
ur_driver::UrDriver::UrDriver(const std::string& robot_ip, const std::string& script_file)
ur_driver::UrDriver::UrDriver(const std::string& robot_ip, const std::string& script_file,
const std::string& recipe_file)
: servoj_time_(0.008), servoj_gain_(750), servoj_lookahead_time_(0.03)
{
LOG_INFO("Initializing RTDE client");
rtde_client_.reset(new rtde_interface::RTDEClient(robot_ip, notifier_));
rtde_client_.reset(new rtde_interface::RTDEClient(robot_ip, notifier_, recipe_file));
if (!rtde_client_->init())
{