Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F parameterise using local hardware interface param #110

Closed
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
21 changes: 18 additions & 3 deletions ur_robot_driver/src/ros/hardware_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ bool HardwareInterface::init(ros::NodeHandle& root_nh, ros::NodeHandle& robot_hw
return false;
}

// Allows the hardware_interface parameter to be in the local (rather than global) namespace
// of the driver. This allows multiple drivers to be started in the same namespace.
bool use_local_hardware_interface_param = robot_hw_nh.param("use_local_hardware_interface_param", false);

// Whenever the runtime state of the "External Control" program node in the UR-program changes, a
// message gets published here. So this is equivalent to the information whether the robot accepts
// commands from ROS side.
Expand Down Expand Up @@ -263,11 +267,22 @@ bool HardwareInterface::init(ros::NodeHandle& root_nh, ros::NodeHandle& robot_hw
// end
command_sub_ = robot_hw_nh.subscribe("script_command", 1, &HardwareInterface::commandCallback, this);

ros::NodeHandle* hardware_interface_nh;

if (use_local_hardware_interface_param)
{
hardware_interface_nh = &robot_hw_nh;
}
else
{
hardware_interface_nh = &root_nh;
}

// Names of the joints. Usually, this is given in the controller config file.
if (!root_nh.getParam("hardware_interface/joints", joint_names_))
if (!hardware_interface_nh->getParam("hardware_interface/joints", joint_names_))
{
ROS_ERROR_STREAM("Cannot find required parameter " << root_nh.resolveName("hardware_interface/joints")
<< " on the parameter server.");
ROS_ERROR_STREAM("Cannot find required parameter "
<< hardware_interface_nh->resolveName("hardware_interface/joints") << " on the parameter server.");
throw std::runtime_error("Cannot find required parameter "
"'controller_joint_names' on the parameter server.");
}
Expand Down