Project

General

Profile

Revision 6fab3966

ID6fab3966a8c664beb8621d6ef145904cceef783a

Added by Alex Zirbel over 11 years ago

Fixed the line following code.

Now works with new units
Fixed a bug with reading the line location, correctly centering the line between -3.5 and 3.5 rather than -4 and 3.
Also fixed a bug caused by overflow in absolute speeds sent to motor control, which fixed bouncing in line following.

View differences:

scout/libscout/src/behaviors/line_follow.cpp
38 38
    {
39 39
        double line_loc = linesensor->readline();
40 40

  
41
        motor_l = -MOTOR_BASE + SCALE * line_loc;
42
        motor_r = -MOTOR_BASE - SCALE * line_loc;
41
        ROS_INFO("Line location: %lf.\n", line_loc);
42

  
43
        motor_l = min(max((int) (-MOTOR_BASE + SCALE * line_loc), -128), 127);
44
        motor_r = min(max((int) (-MOTOR_BASE - SCALE * line_loc), -128), 127);
43 45

  
44 46
        motors->set_sides(motor_l, motor_r, MOTOR_ABSOLUTE);
45 47
    }

Also available in: Unified diff