Files
ODrive/Firmware/MotorControl/open_loop_controller.hpp
T
Samuel Sadok 7fd0806d49 introduce InputPort and OutputPort, don't use NAN
The InputPort/OutputPort infrastructure facilitates safer
data paths between components: OutputPorts store a value
and the age of the value measured in number of control loop
iterations. InputPorts can be connected to various sources,
for instance an OutputPort. InputPorts expose the values to
consumers in the form of std::optional to reflect the fact
that an InputPort can be dangling or connected to a stale
OutputPort.
2020-09-23 16:20:21 +02:00

31 lines
857 B
C++

#ifndef __OPEN_LOOP_CONTROLLER_HPP
#define __OPEN_LOOP_CONTROLLER_HPP
#include "component.hpp"
#include <cmath>
#include <autogen/interfaces.hpp>
class OpenLoopController : public ComponentBase {
public:
void update(uint32_t timestamp) final;
// Config
float max_current_ramp_ = INFINITY; // [A/s]
float max_voltage_ramp_ = INFINITY; // [V/s]
float max_phase_vel_ramp_ = INFINITY; // [rad/s^2]
// Inputs
float target_vel_ = 0.0f;
float target_current_ = 0.0f;
float target_voltage_ = 0.0f;
// State/Outputs
uint32_t timestamp_ = 0;
OutputPort<float2D> Idq_setpoint_ = {{0.0f, 0.0f}};
OutputPort<float2D> Vdq_setpoint_ = {{0.0f, 0.0f}};
OutputPort<float> phase_ = 0.0f;
OutputPort<float> phase_vel_ = 0.0f;
OutputPort<float> total_distance_ = 0.0f;
};
#endif // __OPEN_LOOP_CONTROLLER_HPP