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

Fix joint limits in velocity mode #9

Open
wants to merge 2 commits into
base: kinetic-devel
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions src/generic_hw_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ void GenericHWInterface::registerJointLimits(const hardware_interface::JointHand

joint_position_lower_limits_[joint_id] = joint_limits.min_position;
joint_position_upper_limits_[joint_id] = joint_limits.max_position;

// Enforce limits to not start simulation in invalid state
joint_position_[joint_id] =
joint_limits_interface::internal::saturate(joint_position_[joint_id],
joint_limits.min_position, joint_limits.max_position);
}

// Copy velocity limits if available
Expand Down
13 changes: 12 additions & 1 deletion src/sim_hw_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,18 @@ void SimHWInterface::write(ros::Duration &elapsed_time)
void SimHWInterface::enforceLimits(ros::Duration &period)
{
// Enforces position and velocity
pos_jnt_sat_interface_.enforceLimits(period);
switch (sim_control_mode_)
{
case 0: // hardware_interface::MODE_POSITION:
pos_jnt_sat_interface_.enforceLimits(period);
break;
case 1: // hardware_interface::MODE_VELOCITY:
vel_jnt_sat_interface_.enforceLimits(period);
break;
case 2: // hardware_interface::MODE_EFFORT:
ROS_ERROR_STREAM_NAMED(name_, "Effort not implemented yet");
break;
}
}

void SimHWInterface::positionControlSimulation(ros::Duration &elapsed_time, const std::size_t joint_id)
Expand Down