Project

General

Profile

Statistics
| Revision:

root / branches / autonomous_recharging / code / projects / autonomous_recharging / dragonfly / departing.c @ 93

History | View | Annotate | Download (691 Bytes)

1
#include "departing.h"
2

    
3
#include <range.h>
4
#include <move.h>
5

    
6
/**
7
 * Leaves the charging station. The robot will
8
 * continue to back up until it collides with
9
 * a wall. range_init must be called before this
10
 * function may be used.
11
 *
12
 * @return nonzero if the departure is complete, 
13
 * zero otherwise
14
 **/
15
int depart_station(void)
16
{
17
        int front_distance = read_distance(IR2);
18

    
19
        if(front_distance > LEAVE_HIT_WALL_DIST_THRESH)
20
                seek_leave_dist_count++;
21
        else
22
                seek_leave_dist_count = 0;
23

    
24
        if(seek_leave_dist_count > 5)
25
        {
26
                //stop
27
                move(0,0);
28
                return 1; 
29
        }
30

    
31
        // continue moving backwards
32
        move(SEEK_LEAVE_STATION_VELOCITY_HIT_WALL, 0);
33
        return 0;
34
}
35