Skip to content
Permalink
191052b602
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
73 lines (60 sloc) 1.69 KB
#include "status/wheel_rpms_frame.h"
const WheelRpmsFrame::rpms_t WheelRpmsFrame::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 WheelRpmsFrame::rpms_t WheelRpmsFrame::fastest() const
{
const auto fl = front_left();
const auto fr = front_right();
const auto rl = rear_left();
const auto rr = rear_right();
return std::max( std::max( fl, fr ), std::max( rl, rr ) );
}
const WheelRpmsFrame::rpms_t WheelRpmsFrame::front_left() const
{
return candata_vcu2_ai_speeds_fl_wheel_speed_decode( data.fl_wheel_speed );
}
const WheelRpmsFrame::rpms_t WheelRpmsFrame::front_right() const
{
return candata_vcu2_ai_speeds_fr_wheel_speed_decode( data.fr_wheel_speed );
}
const WheelRpmsFrame::rpms_t WheelRpmsFrame::rear_left() const
{
return candata_vcu2_ai_speeds_rl_wheel_speed_decode( data.rl_wheel_speed );
}
const WheelRpmsFrame::rpms_t WheelRpmsFrame::rear_right() const
{
return candata_vcu2_ai_speeds_rr_wheel_speed_decode( data.rr_wheel_speed );
}
void WheelRpmsFrame::_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 WheelRpmsFrame::_print( std::ostream& os ) const
{
os << "Wheel counts: " << rpm(0);
for( size_t i=1; i<4; ++i )
os << ", " << rpm(i);
}
WheelRpmsFrame::WheelRpmsFrame() :
ProcessFrame( CANDATA_VCU2_AI_SPEEDS_FRAME_ID )
{
}
WheelRpmsFrame::~WheelRpmsFrame()
{
}