Project

General

Profile

Revision 5866cb38

ID5866cb38bf3954babc911a0d0bea69b8dc696cba

Added by Alex Zirbel about 12 years ago

Linesensor tested and done!

View differences:

scout/libscout/src/LinesensorControl.cpp
52 52
 * @todo This shouldn't be returning void. These functions, in general, should
53 53
 *       be changed to be more useful.
54 54
 */
55
void LinesensorControl::query()
55
vector<uint32_t> LinesensorControl::query()
56 56
{
57 57
    // Set scan range
58 58
    linesensor::query_linesensor srv;
......
62 62
        ROS_ERROR("LinesensorControl query failed.");
63 63
    }
64 64

  
65
    for (int i = 0; i < 8; i++)
66
    {
67
        cout << "[" << i << "]: " << srv.response.readings[i] << ", ";
68
    }
69

  
70
    cout << endl;
65
    return srv.response.readings;
71 66
}
72 67

  
scout/libscout/src/LinesensorControl.h
47 47
                          std::string scoutname);
48 48

  
49 49
        /** Use ROS to get the current readings. */
50
        void query();
50
        std::vector<uint32_t> query();
51 51

  
52 52
    private:
53 53
        /* ROS publisher and client declaration */
scout/libscout/src/behaviors/sim_line.cpp
25 25

  
26 26
#include "sim_line.h"
27 27

  
28
using namespace std;
29

  
28 30
void sim_line::run()
29 31
{
30 32
    while(ok())
31 33
    {
32 34
        motors->set_sides(10, 20, MOTOR_ABSOLUTE);
33 35

  
34
        linesensor->query();
36
        vector<uint32_t> readings = linesensor->query();
37

  
38
        for (int i = 0; i < 8; i++)
39
        {
40
            cout << "[" << i << "]" << ": " << readings[i] << ", ";
41
        }
42
        cout << endl;
35 43

  
36 44
        spinOnce();
37 45
        loop_rate->sleep();
scout/scoutsim/src/scout.cpp
200 200
            int sensor_x = (int) (x - LNSNSR_D * cos(theta) - offset * sin(theta));
201 201
            int sensor_y = (int) (y + LNSNSR_D * sin(theta) - offset * cos(theta));
202 202

  
203
            /*
204
            if (s == 0)
205
            {
206
                cout << "s: " << s << ", offset: " << offset << ", scout: (" << x <<
207
                        ", " << y << "), sensor: (" << sensor_x <<
208
                        ", " << sensor_y << ")" << endl;
209
            }
210
            */
211

  
212 203
            unsigned char r = lines_image.GetRed(sensor_x, sensor_y);
213 204
            unsigned char g = lines_image.GetGreen(sensor_x, sensor_y);
214 205
            unsigned char b = lines_image.GetBlue(sensor_x, sensor_y);

Also available in: Unified diff