Skip to content
Permalink
9d174c0f46
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
75 lines (62 sloc) 2.17 KB
#ifndef AXLE_CONTROL_FRAME_HPP
#define AXLE_CONTROL_FRAME_HPP
#pragma once
#include "status_frames.hpp"
#include "control_frames.hpp"
#include <candata.h>
#include <array>
#include <iostream>
#include <stdexcept>
#include <variant>
namespace adas_api{
class AxleControlFrame : public ControlFrame
{
public:
bool is_front() const;
AxleControlFrame( const AxleTorqueFrame &torqueFrame,
const BrakeFrame &brakeFrame,
const WheelSpeedsFrame &speedsFrame,
const StatusFrame &statusFrame,
const BrakeControlFrame &brakeControl,
const bool front=true );
virtual ~AxleControlFrame() = default;
void set_speed( const float speed );
void set_torque( const float torque );
/**
* @brief Limit torque based on rpm.
*
* Limit the torque based on the wheel rpm to help maintain constant electrical
* power and minimise the risk of an over-current trip. These limits are copied
* from the official FS-AI_API code.
*
* @param rpm
* @return float Limited torque.
*/
static float torque_rpm_limit( const float rpm );
constexpr static float motor_ratio = 3.5f;
private:
/**
* @brief Generate can_frame for transmission.
*
* @warning Will default to speed and torque = 0 unless all requirements are
* met, i.e.:
* - Recent status frame.
* - Recent torque frame.
* - Recent wheel speeds frame.
* - AS_STATE == DRIVING
*
* @return can_frame
*/
virtual can_frame _process() const override;
virtual void _print( std::ostream& os ) const override;
const AxleTorqueFrame &_torqueFrame;
const BrakeFrame &_brakeFrame;
const WheelSpeedsFrame &_speedsFrame;
const StatusFrame &_statusFrame;
const BrakeControlFrame &_brakeControl;
const bool _front;
float _speed = 0.f;
float _torque = 0.f;
};
};
#endif // AXLE_CONTROL_FRAME_HPP