|
[DPRG] Robot Code: subsumption addenda
Subject: [DPRG] Robot Code: subsumption addenda
From: David P. Anderson
dpa at io.isem.smu.edu
Date: Thu Mar 15 16:17:52 CDT 2007
Howdy,
I've had a request for a description of the sensor loops
loops for the SR04 and jBot robots mentioned in the writeup
about arbitration code in the previous post:
<http://list.dprg.org/archive/2007-March/030422.html>
Here's the sensor loop from SR04:
/* ---------------------------------------------------------------------- */
/* 20 Hz sensor loop */
void sensors(int x)
{
INT32 t;
mseconds(&t);
while(1) {
sonar_task(); /* always */
if (srat_system & ARBITRATE) {
if (!(line_follow)) feelers();
speedctrl();
slewspeed_task();
prowl_task();
bumper_task();
photo_task();
ir_task();
motion_task();
xlate_task();
behaviors_task();
passive_task();
seek_task();
boundary_task();
arbitrate();
}
tsleep(&t,50);
}
}
/* ---------------------------------------------------------------------- */
The tsleep() function is a special form of msleep() that takes into
account the execution time of the entire loop in calculating
how long to delay. So the repetition rate, (and sample rate for
any included tasks) remains constant.
These tasks are not all running at any given time. For example, the motion
task only deploys the robot's motion detector when the robot is not moving,
which it determines by monitoring the robot's average velocity. Each task
has an associated enable flag which is read from a set of microswitches on
the robot, so all of the behaviors can be selectively enabled/disabled.
jBot is optimised for outdoor navigation and has fewer, more complex
tasks than SR04. Here's the sensor loop from jBot:
/* ---------------------------------------------------------------------- */
void sensors ()
{
int t = mseconds(); /* set timer */
while (1) { /* endless loop */
knob_task();
radio_task();
xlate_task();
prowl_task();
escape_task();
obstacle_task();
perimeter_task();
navmode_task();
arbitrator();
t = tsleep(t,50);
}
}
/* ---------------------------------------------------------------------- */
Several of these tasks read jBot's IMU sensor, it's Sonar Array, and it's
GPS data stream. These and the quadrature encoders on the two drive motors
are currently the robot's only sensors.
If you'd like to examine videos of these behaviors, the web page for SR04 is
<http://www.geology.smu.edu/~dpa-www/robots/sr04/>
and the web page for jBot is
<http://www.geology.smu.edu/~dpa-www/robo/jbot/>
Hope this is useful.
best,
dpa
More information about the DPRG mailing list
|