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

Acceleration limits #1

Merged
Merged
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 @@ -237,11 +237,14 @@ class EffortJointSoftLimitsHandle
class VelocityJointSaturationHandle
{
public:
VelocityJointSaturationHandle () {}
VelocityJointSaturationHandle ()
: prev_cmd_(0.0)
{}

VelocityJointSaturationHandle(const hardware_interface::JointHandle& jh, const JointLimits& limits)
: jh_(jh),
limits_(limits)
limits_(limits),
prev_cmd_(0.0)
{
if (!limits.has_velocity_limits)
{
Expand All @@ -268,11 +271,10 @@ class VelocityJointSaturationHandle
if (limits_.has_acceleration_limits)
{
assert(period.toSec() > 0.0);
const double vel = jh_.getVelocity();
const double dt = period.toSec();

vel_low = std::max(vel - limits_.max_acceleration * dt, -limits_.max_velocity);
vel_high = std::min(vel + limits_.max_acceleration * dt, limits_.max_velocity);
vel_low = std::max(prev_cmd_ - limits_.max_acceleration * dt, -limits_.max_velocity);
vel_high = std::min(prev_cmd_ + limits_.max_acceleration * dt, limits_.max_velocity);
}
else
{
Expand All @@ -285,11 +287,16 @@ class VelocityJointSaturationHandle
vel_low,
vel_high);
jh_.setCommand(vel_cmd);

// Cache variables
prev_cmd_ = jh_.getCommand();
}

private:
hardware_interface::JointHandle jh_;
JointLimits limits_;

double prev_cmd_;
};

/**
Expand Down