Skip to content

Commit

Permalink
fix: makes position state interface mandatory, adds compatibility wit…
Browse files Browse the repository at this point in the history
…h velocity command interface without position command interface
  • Loading branch information
MarcoMagriDev authored Jul 6, 2024
1 parent f427c4d commit 7ac93f6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion admittance_controller/src/admittance_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ controller_interface::CallbackReturn AdmittanceController::on_configure(
has_acceleration_state_interface_ = contains_interface_type(
admittance_->parameters_.state_interfaces, hardware_interface::HW_IF_ACCELERATION);

if (!has_position_state_interface_)
{
RCLCPP_ERROR(get_node()->get_logger(), "Position state interface is required.");
return CallbackReturn::FAILURE;
}

auto get_interface_list = [](const std::vector<std::string> & interface_types)
{
std::stringstream ss_command_interfaces;
Expand Down Expand Up @@ -523,7 +529,7 @@ void AdmittanceController::write_state_to_hardware(
{
// if any interface has nan values, assume state_commanded is the last command state
size_t pos_ind = 0;
size_t vel_ind = pos_ind + has_velocity_command_interface_;
size_t vel_ind = (has_position_command_interface_) ? has_velocity_command_interface_ : pos_ind;
size_t acc_ind = vel_ind + has_acceleration_command_interface_;
for (size_t joint_ind = 0; joint_ind < num_joints_; ++joint_ind)
{
Expand Down

0 comments on commit 7ac93f6

Please sign in to comment.