controller_bb_8_driver/tests/test_wheel_control.c
void testOneWheelControllerMatlab( void )
{
    wheelControlInit();
    debug_stream_init();

    sdStart( &SD6, &sdcfg );
    palSetPadMode( GPIOG, 14, PAL_MODE_ALTERNATE(8) );   // TX
    palSetPadMode( GPIOG, 9,  PAL_MODE_ALTERNATE(8) );   // RX

    bool                    matlab_start_flag   = false;

    wheelSpeedValue_t       test_ref_speed      = 0.3f;
    wheelSpeedValue_t       test_real_speed     = 0.0f;

    wheelControlSetPermeation( );

    systime_t   time = chVTGetSystemTimeX( );
    while( true )
    {
        char rc_data = sdGetTimeout( &SD6, TIME_IMMEDIATE );

        switch( rc_data )
        {
            case 's':   // start
                matlab_start_flag = true;
                break;

            case 'n':   // set speed to 0
                test_ref_speed = 0.02f;
                break;

            case 'm':   // set speed to negative
                test_ref_speed = -test_ref_speed;
                break;

            case 'x':   // stop
                matlab_start_flag = false;
                break;

            default:
              break;
        }

        if( matlab_start_flag )
        {
            wheelControlSetPermeation( );
            wheelControlSetSpeedAllWheels( test_ref_speed, REVS_PER_SEC );

            test_real_speed = odometryGetWheelSpeed( A, REVS_PER_SEC );

            sdWrite(&SD6, (uint8_t*) &test_real_speed, 4);
            sdWrite(&SD6, (uint8_t*) &test_ref_speed,  4);
        }
        else
        {
            wheelControlResetPermeation( );
            wheelControlResetControllerAllWheels();
            lldControlStopAllMotors();
        }

        time = chThdSleepUntilWindowed( time, time + MS2ST( 10 ) );
    }
}
/*
 * @brief   Test wheel control system with matlab
 * @note    Send two packages with float value (4-byte)
 *          only wheel A data are send to matlab
 */
@brief   Test wheel control system with matlab
@note    Send two packages with float value (4-byte)
only wheel A data are send to matlab
@brief Test wheel control system with matlab @note Send two packages with float value ( 4 - byte ) only wheel A data are send to matlab
void testOneWheelControllerMatlab( void )
{
    wheelControlInit();
    debug_stream_init();
    sdStart( &SD6, &sdcfg );
    palSetPadMode( GPIOG, 14, PAL_MODE_ALTERNATE(8) );   
    palSetPadMode( GPIOG, 9,  PAL_MODE_ALTERNATE(8) );   
    bool                    matlab_start_flag   = false;
    wheelSpeedValue_t       test_ref_speed      = 0.3f;
    wheelSpeedValue_t       test_real_speed     = 0.0f;
    wheelControlSetPermeation( );
    systime_t   time = chVTGetSystemTimeX( );
    while( true )
    {
        char rc_data = sdGetTimeout( &SD6, TIME_IMMEDIATE );
        switch( rc_data )
        {
            case 's':   
                matlab_start_flag = true;
                break;
            case 'n':   
                test_ref_speed = 0.02f;
                break;
            case 'm':   
                test_ref_speed = -test_ref_speed;
                break;
            case 'x':   
                matlab_start_flag = false;
                break;
            default:
              break;
        }
        if( matlab_start_flag )
        {
            wheelControlSetPermeation( );
            wheelControlSetSpeedAllWheels( test_ref_speed, REVS_PER_SEC );
            test_real_speed = odometryGetWheelSpeed( A, REVS_PER_SEC );
            sdWrite(&SD6, (uint8_t*) &test_real_speed, 4);
            sdWrite(&SD6, (uint8_t*) &test_ref_speed,  4);
        }
        else
        {
            wheelControlResetPermeation( );
            wheelControlResetControllerAllWheels();
            lldControlStopAllMotors();
        }
        time = chThdSleepUntilWindowed( time, time + MS2ST( 10 ) );
    }
}
void testOneWheelControllerMatlab ( void ) { wheelControlInit ( ) ; debug_stream_init ( ) ; sdStart ( & SD6 , & sdcfg ) ; palSetPadMode ( GPIOG , 14 , PAL_MODE_ALTERNATE ( 8 ) ) ; palSetPadMode ( GPIOG , 9 , PAL_MODE_ALTERNATE ( 8 ) ) ; bool matlab_start_flag = false ; wheelSpeedValue_t test_ref_speed = 0.3f ; wheelSpeedValue_t test_real_speed = 0.0f ; wheelControlSetPermeation ( ) ; systime_t time = chVTGetSystemTimeX ( ) ; while ( true ) { char rc_data = sdGetTimeout ( & SD6 , TIME_IMMEDIATE ) ; switch ( rc_data ) { case ' ' : matlab_start_flag = true ; break ; case ' ' : test_ref_speed = 0.02f ; break ; case ' ' : test_ref_speed = - test_ref_speed ; break ; case ' ' : matlab_start_flag = false ; break ; default : break ; } if ( matlab_start_flag ) { wheelControlSetPermeation ( ) ; wheelControlSetSpeedAllWheels ( test_ref_speed , REVS_PER_SEC ) ; test_real_speed = odometryGetWheelSpeed ( A , REVS_PER_SEC ) ; sdWrite ( & SD6 , ( uint8_t * ) & test_real_speed , 4 ) ; sdWrite ( & SD6 , ( uint8_t * ) & test_ref_speed , 4 ) ; } else { wheelControlResetPermeation ( ) ; wheelControlResetControllerAllWheels ( ) ; lldControlStopAllMotors ( ) ; } time = chThdSleepUntilWindowed ( time , time + MS2ST ( 10 ) ) ; } }
@brief   Test wheel control system with matlab
 @note    Send two packages with float value (4-byte)
          only wheel A data are send to matlab
@brief Test wheel control system with matlab @note Send two packages with float value ( 4 - byte ) only wheel A data are send to matlab
// TX // RX // start // set speed to 0 // set speed to negative // stop