Program Listing for File steering_limiter.hpp

Return to documentation for file (include/tricycle_controller/steering_limiter.hpp)

// Copyright 2022 Pixel Robotics.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*
 * Author: Tony Najjar
 */

#ifndef TRICYCLE_CONTROLLER__STEERING_LIMITER_HPP_
#define TRICYCLE_CONTROLLER__STEERING_LIMITER_HPP_

#include <cmath>

namespace tricycle_controller
{
class SteeringLimiter
{
public:
  SteeringLimiter(
    double min_position = NAN, double max_position = NAN, double min_velocity = NAN,
    double max_velocity = NAN, double min_acceleration = NAN, double max_acceleration = NAN);

  double limit(double & p, double p0, double p1, double dt);

  double limit_position(double & p);

  double limit_velocity(double & p, double p0, double dt);

  double limit_acceleration(double & p, double p0, double p1, double dt);

private:
  // Position limits:
  double min_position_;
  double max_position_;

  // Velocity limits:
  double min_velocity_;
  double max_velocity_;

  // Acceleration limits:
  double min_acceleration_;
  double max_acceleration_;
};

}  // namespace tricycle_controller

#endif  // TRICYCLE_CONTROLLER__STEERING_LIMITER_HPP_