Situation-aware headlights for USR robots. Re #263.

Uses different headhlights whether driving normal, pitting,
or avoiding an opponent.

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3752 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: e83844f016dc47f85b0cd3e1d050f40ce0f57cfc
Former-commit-id: 1ab3ac2d903ff948a769d96a434b95a8c3fccf71
This commit is contained in:
kmetykog 2011-07-28 12:32:49 +00:00
parent e8ef94dab7
commit 9188a8c350

View file

@ -60,7 +60,7 @@ enum { STUCK_REVERSE = 1, STUCK_FORWARD = 2 };
// Static variables.
Cardata *Driver::cardata = NULL;
static int current_light = RM_LIGHT_HEAD1 | RM_LIGHT_HEAD2;
Driver::Driver(int index, const int robot_type) :
NoTeamWaiting(0),
@ -871,9 +871,8 @@ void Driver::drive(tSituation *s)
/* USR stores pit positions in car->_lightCmd, so we shift
* that information 2 pos left and flip on the real
* light commands. (All lights on) */
car->_lightCmd = ((int)cmd_light << 2)
| RM_LIGHT_HEAD1 | RM_LIGHT_HEAD2;
* light commands. (Situation-aware) */
car->_lightCmd = ((int)cmd_light << 2) | current_light;
skipcount++;
@ -1270,6 +1269,18 @@ void Driver::setMode( int newmode )
avoidtime = simtime;
mode = newmode;
switch (newmode) {
case mode_normal:
current_light = RM_LIGHT_HEAD1 | RM_LIGHT_HEAD2;
break;
case mode_pitting:
current_light = RM_LIGHT_HEAD2;
break;
case mode_avoiding:
current_light = RM_LIGHT_HEAD1;
break;
}
}
void Driver::calcSkill()