Пример #1
0
/**
 * Escape objects and go to the light or dark
 * @global _mode_light_ it must be set
 */
void go_light_touch()
{
    int bmp;
    start_process(go_light());
    _go_light_touch_running_ = 1;

    while(_go_light_touch_running_)
    {
        /* Obstacle touched, I stop the run and I am escaping */
        bmp = bumper_detection();

        if(bmp != 0 && bmp != BMP_BACK)
        {
            _go_light_running_ = 0;

            while(_go_light_running_ != -1);

            escape(bmp);
            /* Run after the correction*/
            start_process(go_light());
        }
    }

    _go_light_running_ = 0;

    while(_go_light_running_ != -1);

    _go_light_touch_running_ = -1;
}
Пример #2
0
/**
 * Running to 20cm of ligth
 * but escape obstacle with bumpers
 */
void go_light_stop_touch()
{
    int bmp;

    _mode_light_ = GO_LIGHT;
    _motor_initial_speed_ = 100;

    light_environnement();
    start_process(go_light_stop(20));

    while(_go_light_touch_running_)
    {
        bmp = bumper_detection();

        if(bmp != 0 && (bmp != BMP_BACK))
        {
            stop_process(_go_light_stop_running_);
            wait_process(_go_light_stop_running_);
            escape(bmp);
            start_process(go_light_stop(20));
        }
    }

    stop_process(_go_light_stop_running_);
    wait_process(_go_light_stop_running_);
    _go_light_touch_running_ = -1;
}