LCOV - code coverage report
Current view: top level - controller - BaseControllerInterface.h Hit Total Coverage
Test: doc-coverage.info Lines: 4 6 66.7 %
Date: 2026-04-20 18:26:22

          Line data    Source code
       1             : #ifndef CONTROLS_CONTROLLER_BASE_CONTROLLER_INTERFACE_H
       2             : #define CONTROLS_CONTROLLER_BASE_CONTROLLER_INTERFACE_H
       3             : 
       4             : #include <controller/ControllerConfig.h>
       5             : #include <dynamics/SystemDynamicsBase.h>
       6             : #include <utils/Transforms.h>
       7             : 
       8             : /**
       9             :  * @brief Abstract base class for a single-responsibility force controller
      10             :  *
      11             :  * Concrete subclasses implement one control strategy (feed-forward, feedback,
      12             :  * or buoyancy compensation).  Higher-level controllers combine instances of
      13             :  * these to produce a total body force.
      14             :  */
      15           1 : class BaseControllerInterface {
      16             : protected:
      17             :     /** @brief Vehicle dynamics model shared with all controllers in a stack */
      18             :     std::shared_ptr<SystemDynamicsBase> auv_;
      19             : 
      20             :     /** @brief Tuning parameters shared with all controllers in a stack */
      21             :     std::shared_ptr<ControllerConfig> config_;
      22             : 
      23             : public:
      24           0 :     BaseControllerInterface() = default;
      25             : 
      26             :     /**
      27             :      * @brief Constructs a controller with the given dynamics model and config
      28             :      *
      29             :      * @param auv    [in] Shared vehicle dynamics model
      30             :      * @param config [in] Shared controller tuning parameters
      31             :      */
      32           1 :     BaseControllerInterface(std::shared_ptr<SystemDynamicsBase> auv, std::shared_ptr<ControllerConfig> config)
      33             :         : auv_(std::move(auv)), config_(std::move(config)) {
      34             :     }
      35             : 
      36           0 :     virtual ~BaseControllerInterface() = default;
      37             : 
      38             :     /**
      39             :      * @brief Resets any internal state (e.g., integrator terms)
      40             :      */
      41           1 :     virtual void reset() {};
      42             : 
      43             :     /**
      44             :      * @brief Computes the instantaneous 6DOF body force for the given goal and current state
      45             :      *
      46             :      * @param goal [in] Desired vehicle state
      47             :      * @param curr [in] Current vehicle state
      48             :      * @param dt   [in] Time step in seconds since the last call
      49             :      *
      50             :      * @return 6-element body force/torque vector [Fx, Fy, Fz, Tx, Ty, Tz] in N and Nm
      51             :      */
      52           1 :     virtual Vector6d getForce(const State& goal, const State& curr, double dt) = 0;
      53             : };
      54             : 
      55             : #endif  // CONTROLS_CONTROLLER_BASE_CONTROLLER_INTERFACE_H

Generated by: LCOV version 1.14