5#include "utils/utils.hpp"
6#include "gtest/gtest.h"
7#include <rclcpp/rclcpp.hpp>
85 double update(
double setpoint,
double measurement);
94 void path_callback(
const custom_interfaces::msg::PathPointArray& msg)
override;
98 void publish_solver_data(std::shared_ptr<rclcpp::Node> node, std::map<std::string, std::shared_ptr<rclcpp::PublisherBase>>& publisher_map)
override;
Base (abstract) class for longitudinal controllers (the ones that calculate throttle)
void calculate_integral_term(double error)
Calculate the integral term.
FRIEND_TEST(PidTests, TestAntiWindUp3)
std::vector< custom_interfaces::msg::PathPoint > last_path_msg_
FRIEND_TEST(PidTests, Update1)
FRIEND_TEST(PidTests, DerivativeTerm1)
FRIEND_TEST(PidTests, TestAntiWindUp2)
FRIEND_TEST(PidTests, Output2)
FRIEND_TEST(PidTests, IntegralTerm1)
void publish_solver_data(std::shared_ptr< rclcpp::Node > node, std::map< std::string, std::shared_ptr< rclcpp::PublisherBase > > &publisher_map) override
Publishes solver specific data using the provided ControlNode.
FRIEND_TEST(PidTests, Output1)
bool received_first_pose_
void calculate_derivative_term(double measurement)
Calculate the derivative term (derivative on measurement)
custom_interfaces::msg::Pose last_pose_msg_
void compute_output()
Compute the output value and apply limits.
double differentiator_
Differentiator term current value.
double proportional_
Proportional term current value.
void path_callback(const custom_interfaces::msg::PathPointArray &msg) override
Called when a new path is sent by Path Planning.
double update(double setpoint, double measurement)
Calculate the output value.
void vehicle_state_callback(const custom_interfaces::msg::Velocities &msg) override
Called when the car state (currently just velocity) is updated.
FRIEND_TEST(PidTests, Output3)
void vehicle_pose_callback(const custom_interfaces::msg::Pose &msg) override
Called when the car pose is updated by SLAM.
bool received_first_path_
FRIEND_TEST(PidTests, DerivativeTerm2)
FRIEND_TEST(PidTests, IntegralTerm2)
double absolute_velocity_
double out_
Current output value.
common_lib::structures::ControlCommand get_throttle_command() override
Returns the throttle command calculated by the solver (only throttle)
double integrator_
Integrator term current value.
custom_interfaces::msg::Velocities last_velocity_msg_
void anti_wind_up()
Anti-wind-up via dynamic integrator clamping.
double prev_measurement_
Previous measurement value, required for defferentiator.
FRIEND_TEST(PidTests, TestAntiWindUp1)
bool received_first_state_
double calculate_error(double setpoint, double measurement) const
Calculate the error signal.
FRIEND_TEST(PidTests, ProportionalTerm)
double prev_error_
Previous error value, required for integrator.
void calculate_proportional_term(double error)
Calculate the proportional term.