Project

General

Profile

Revision 5d0687a9

ID5d0687a9991d806c94fc7c21405334e6717e3611
Parent 1487bc56
Child 26562d0c, d37cfc69

Added by Priya almost 12 years ago

Small changes to wireless, and starting turning with line following.

View differences:

scout/libscout/src/LinesensorControl.cpp
35 35

  
36 36
using namespace std;
37 37

  
38
static double last_ret;
39

  
38 40
/**
39 41
 * @brief Initialize the line following module of libscout.
40 42
 */
......
62 64
    return srv.response.readings;
63 65
}
64 66

  
67
/** 
68
 *  @brief Returns the average readings of the line following sensors. 
69
 */
70
double LinesensorControl::readline()
71
{
72
    unsigned int total_read = 0;
73
    unsigned int weighted_total = 0;
74

  
75
    vector<uint32_t> readings = query();
76

  
77
    for (int i = 0; i < 8; i++)
78
    {
79
        total_read += readings[i];
80
        weighted_total += i * readings[i];
81
    }
82

  
83
    if (total_read == 0)
84
    {
85
        return last_ret;
86
    }
87
    
88
    double ret_val = last_ret = ((double) weighted_total / total_read) - 4;
89
    return ret_val;
90
}
91

  
92
bool LinesensorControl::fullline()
93
{
94
    return false; 
95
}
96

  
97
void LinesensorControl::turnLeft()
98
{
99
    vector<uint32_t> readings = query();
100
}
101

  
102
void LinesensorControl::turnRight()
103
{
104
    vector<uint32_t> readings = query();
105

  
106
}

Also available in: Unified diff