Permalink
Cannot retrieve contributors at this time
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?
adas-api/src/status/wheel_speeds_frame.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
65 lines (54 sloc)
1.61 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "status/wheel_speeds_frame.h" | |
const WheelSpeedsFrame::rpm_t WheelSpeedsFrame::rpm( size_t index ) const | |
{ | |
switch( index ) | |
{ | |
case 0: | |
return front_left(); | |
case 1: | |
return front_right(); | |
case 2: | |
return rear_left(); | |
case 3: | |
return rear_right(); | |
} | |
return 0; | |
} | |
const WheelSpeedsFrame::rpm_t WheelSpeedsFrame::front_left() const | |
{ | |
return candata_vcu2_ai_speeds_fl_wheel_speed_decode( data.fl_wheel_speed ); | |
} | |
const WheelSpeedsFrame::rpm_t WheelSpeedsFrame::front_right() const | |
{ | |
return candata_vcu2_ai_speeds_fr_wheel_speed_decode( data.fr_wheel_speed ); | |
} | |
const WheelSpeedsFrame::rpm_t WheelSpeedsFrame::rear_left() const | |
{ | |
return candata_vcu2_ai_speeds_rl_wheel_speed_decode( data.rl_wheel_speed ); | |
} | |
const WheelSpeedsFrame::rpm_t WheelSpeedsFrame::rear_right() const | |
{ | |
return candata_vcu2_ai_speeds_rr_wheel_speed_decode( data.rr_wheel_speed ); | |
} | |
const WheelSpeedsFrame::rpm_t WheelSpeedsFrame::fastest() const | |
{ | |
return std::max( std::max( front_left(), front_right() ), | |
std::max( rear_left(), rear_right() ) ); | |
} | |
void WheelSpeedsFrame::_process( const can_frame& frame ) | |
{ | |
if( candata_vcu2_ai_speeds_unpack( &data, frame.data, frame.can_dlc ) ) | |
{ | |
throw std::runtime_error( "Failed to unpack wheel counts frame" ); | |
} | |
} | |
void WheelSpeedsFrame::_print( std::ostream& os ) const | |
{ | |
os << "Wheel counts: " << rpm(0); | |
for( size_t i=1; i<4; ++i ) | |
os << ", " << rpm(i); | |
} | |
WheelSpeedsFrame::WheelSpeedsFrame() : | |
ProcessFrame( CANDATA_VCU2_AI_SPEEDS_FRAME_ID ) | |
{ | |
} |