Skip to content

Commit

Permalink
Merge pull request #1 from efernandez/accel_limits
Browse files Browse the repository at this point in the history
Acceleration limits
  • Loading branch information
Adolfo Rodriguez Tsouroukdissian committed Nov 12, 2013
2 parents 63ab728 + e9e3bde commit 35fbc27
Showing 1 changed file with 12 additions and 5 deletions.
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

0 comments on commit 35fbc27

Please sign in to comment.