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

Add passthrough interfaces for joints #1121

Merged
merged 1 commit into from
Oct 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ class URPositionHardwareInterface : public hardware_interface::SystemInterface
double system_interface_initialized_;
bool async_thread_shutdown_;

// Passthrough trajectory controller interface values
urcl::vector6d_t passthrough_trajectory_positions_;
urcl::vector6d_t passthrough_trajectory_velocities_;
urcl::vector6d_t passthrough_trajectory_accelerations_;

// payload stuff
urcl::vector3d_t payload_center_of_gravity_;
double payload_mass_;
Expand Down
13 changes: 11 additions & 2 deletions ur_robot_driver/src/hardware_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ URPositionHardwareInterface::on_init(const hardware_interface::HardwareInfo& sys
system_interface_initialized_ = 0.0;

for (const hardware_interface::ComponentInfo& joint : info_.joints) {
if (joint.command_interfaces.size() != 2) {
if (joint.command_interfaces.size() != 5) {
RCLCPP_FATAL(rclcpp::get_logger("URPositionHardwareInterface"),
"Joint '%s' has %zu command interfaces found. 2 expected.", joint.name.c_str(),
"Joint '%s' has %zu command interfaces found. 5 expected.", joint.name.c_str(),
joint.command_interfaces.size());
return hardware_interface::CallbackReturn::ERROR;
}
Expand Down Expand Up @@ -243,6 +243,15 @@ std::vector<hardware_interface::CommandInterface> URPositionHardwareInterface::e

command_interfaces.emplace_back(hardware_interface::CommandInterface(
info_.joints[i].name, hardware_interface::HW_IF_VELOCITY, &urcl_velocity_commands_[i]));

command_interfaces.emplace_back(hardware_interface::CommandInterface(info_.joints[i].name, "passthrough_position",
&passthrough_trajectory_positions_[i]));

command_interfaces.emplace_back(hardware_interface::CommandInterface(info_.joints[i].name, "passthrough_velocity",
&passthrough_trajectory_velocities_[i]));

command_interfaces.emplace_back(hardware_interface::CommandInterface(
info_.joints[i].name, "passthrough_acceleration", &passthrough_trajectory_accelerations_[i]));
}
// Obtain the tf_prefix from the urdf so that we can have the general interface multiple times
// NOTE using the tf_prefix at this point is some kind of workaround. One should actually go through the list of gpio
Expand Down
Loading