Revision 6ee555a3
ID | 6ee555a311a763c3209c167ad843b2a8137b52c9 |
Changed scout constants to refresh faster. Also retuned linefollowing for faster refresh rate.
scout/libscout/src/behaviors/line_follow.cpp | ||
---|---|---|
30 | 30 |
static int motor_l; |
31 | 31 |
static int motor_r; |
32 | 32 |
|
33 |
Duration init_turn_time(1.5);
|
|
33 |
Duration init_turn_time(0.4);
|
|
34 | 34 |
|
35 | 35 |
void line_follow::follow_line() |
36 | 36 |
{ |
... | ... | |
38 | 38 |
{ |
39 | 39 |
double line_loc = linesensor->readline(); |
40 | 40 |
|
41 |
motor_l = min(max((int) (-MOTOR_BASE + SCALE * line_loc), -128), 127); |
|
42 |
motor_r = min(max((int) (-MOTOR_BASE - SCALE * line_loc), -128), 127); |
|
41 |
if (line_loc == 0.0) |
|
42 |
{ |
|
43 |
motors->set_sides(-60, -60, MOTOR_ABSOLUTE); |
|
44 |
continue; |
|
45 |
} |
|
46 |
|
|
47 |
motor_l = min(max((int) (-MOTOR_BASE + KP * line_loc), -128), 127); |
|
48 |
motor_r = min(max((int) (-MOTOR_BASE - KP * line_loc), -128), 127); |
|
43 | 49 |
|
44 | 50 |
motors->set_sides(motor_l, motor_r, MOTOR_ABSOLUTE); |
45 | 51 |
} |
46 | 52 |
while(!linesensor->fullline()); |
47 | 53 |
halt(); |
48 |
ROS_INFO("Intersection reached!"); |
|
49 | 54 |
} |
50 | 55 |
|
51 | 56 |
void line_follow::turn_straight() |
... | ... | |
67 | 72 |
do |
68 | 73 |
{ |
69 | 74 |
motor_l = -MOTOR_BASE; |
70 |
motor_r = 3*MOTOR_BASE/5;
|
|
75 |
motor_r = 2*MOTOR_BASE/5;
|
|
71 | 76 |
|
72 | 77 |
motors->set_sides(motor_l, motor_r, MOTOR_ABSOLUTE); |
73 | 78 |
|
... | ... | |
119 | 124 |
float line_loc; |
120 | 125 |
do |
121 | 126 |
{ |
122 |
motor_l = 3*MOTOR_BASE/5;
|
|
127 |
motor_l = 2*MOTOR_BASE/5;
|
|
123 | 128 |
motor_r = -MOTOR_BASE; |
124 | 129 |
|
125 | 130 |
motors->set_sides(motor_l, motor_r, MOTOR_ABSOLUTE); |
scout/libscout/src/behaviors/line_follow.h | ||
---|---|---|
30 | 30 |
#include "../Sensors.h" |
31 | 31 |
|
32 | 32 |
#define MOTOR_BASE 40.0f |
33 |
#define SCALE 40.0f
|
|
33 |
#define KP 20.0f
|
|
34 | 34 |
|
35 | 35 |
class line_follow : public Behavior |
36 | 36 |
{ |
scout/libscout/src/behaviors/maze_solve.cpp | ||
---|---|---|
43 | 43 |
#define DOWN 2 |
44 | 44 |
#define LEFT 3 |
45 | 45 |
|
46 |
Duration sonar_update_time(1.0);
|
|
46 |
Duration sonar_update_time(1.5);
|
|
47 | 47 |
|
48 | 48 |
void maze_solve::run(){ |
49 | 49 |
|
... | ... | |
167 | 167 |
dir = LEFT; |
168 | 168 |
} |
169 | 169 |
} |
170 |
|
|
171 |
ROS_INFO("DEAD END FOUND, TURNING BACK."); |
|
170 | 172 |
// we have exhausted all the options. This path is clearly a |
171 | 173 |
// dead end. go back to where we come from and return false. |
172 | 174 |
turn_from_to(dir, initial_dir); |
scout/scoutsim/GUI.py | ||
---|---|---|
5 | 5 |
# shell subprocess libs |
6 | 6 |
import subprocess |
7 | 7 |
import shlex #for converting string commands to tokens |
8 |
import sys |
|
8 | 9 |
|
9 | 10 |
# GUI libs |
10 | 11 |
import wx |
... | ... | |
33 | 34 |
# this takes advantage of the fact that our behavior list start at 1 |
34 | 35 |
behaviors = ["Pause", "CW Circle", "CCW Circle", "Odometry", |
35 | 36 |
"Navigation Map", "Scheduler", "Warehouse", |
36 |
"Line Follow", "WL Test"] |
|
37 |
"Line Follow", "WL Test", "Maze Solve"]
|
|
37 | 38 |
@classmethod |
38 | 39 |
def getNumber(self, behaviorName): |
39 | 40 |
if (behaviorName in Behaviors.behaviors): |
... | ... | |
178 | 179 |
style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER, size=(600, 600)) |
179 | 180 |
|
180 | 181 |
# open up scoutsim race |
181 |
command = shlex.split("rosrun scoutsim scoutsim_node race") |
|
182 |
if len(sys.argv) > 1: |
|
183 |
map_name = sys.argv[1] |
|
184 |
else: |
|
185 |
map_name = "race" |
|
186 |
command = shlex.split("rosrun scoutsim scoutsim_node " + map_name) |
|
182 | 187 |
self.simWindowProcess = subprocess.Popen(command, shell=False) |
183 | 188 |
#rospy.wait_for_service('/spawn') #don't know why this is here |
184 | 189 |
|
scout/scoutsim/src/scout_constants.h | ||
---|---|---|
84 | 84 |
// Time it takes for the sonar to spin from position 0 to position 23 |
85 | 85 |
const float SONAR_HALF_SPIN_TIME = 0.5; |
86 | 86 |
|
87 |
const float REAL_TIME_REFRESH_RATE = 0.08; // s
|
|
88 |
const float SIM_TIME_REFRESH_RATE = 0.05; // s
|
|
87 |
const float REAL_TIME_REFRESH_RATE = 0.05; // s
|
|
88 |
const float SIM_TIME_REFRESH_RATE = 0.02; // s
|
|
89 | 89 |
} |
90 | 90 |
|
91 | 91 |
#endif |
Also available in: Unified diff