Project

General

Profile

Revision 434

Added by Rich Hong over 16 years ago

update assigning bay based on battery reading (seeking robot), also fix some bugs

View differences:

branches/autonomous_recharging/code/projects/autonomous_recharging/charging_station/charging.c
8 8
#include <wl_token_ring.h>
9 9
#include "wl_charging_station.h"
10 10

  
11
#define BATTERY_LOWV 152
12

  
11 13
//set this to the number of bays
12 14
#define NUM_BAYS 2
13 15

  
......
383 385
 **/
384 386
void update_battery(int robot, int battery)
385 387
{
386
	if (robot < robotSize && robots[robot] != NULL)
388
	if (robot < robotsSize && robots[robot] != NULL)
387 389
		robots[robot]->battery = battery;
388 390
}
389 391
void check_battery(int robot, int battery)
390 392
{
391 393
	if (charging_is_space_available()) return;
392
	// 152 low voltage
393
	// 179 charging voltage
394
	// there's no way to tell the voltage of a charging robot, so we just eject the first one
394
	// there's no way to read the voltage of a charging robot
395
	// so just eject the seeking robot if there's one, or the last charging robot
395 396
	charging_robot_iterator_init();
396
	int r = charging_robot_iterator_next();
397
	int b = robots[r]->battery;
398
	if (battery<153){
397
	int r,b;
398
	while (charging_robot_iterator_has_next())
399
	{
400
		r = charging_robot_iterator_next();
401
		b = robots[r]->battery;
402
		if (robots[r]->state==STATE_SEEKING) break;
403
	}
404
	if (battery<=BATTERY_LOWV&&b>BATTERY_LOWV)
405
	{
399 406
		//cancel robot r
400 407
		wl_charging_send_cancel(r);
401 408
		charging_cancel(r);
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/wl_recharge_group.c
237 237
void wl_recharge_send_battery(int dest)
238 238
{
239 239
	wl_send_robot_to_robot_global_packet(WL_RECHARGE_GROUP, WL_BATTERY_REQUEST,
240
				battery(), 0, dest, 0);
240
				(char*)battery(), 1, dest, 0);
241 241
}
242 242

  
243 243
/**
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/recharge_defs.h
1 1
//#define RECHARGE_DEBUG
2 2

  
3
#define WL_BATTERY_REQUEST 11
3 4
#ifdef RECHARGE_DEBUG
4
#define WL_BATTERY_REQUEST 11
5 5
#define RECHARGE_DEBUG_PRINT( s ) usb_puts( s )
6 6
#define RECHARGE_DEBUG_PUTI( i ) usb_puti( i )
7 7
#else

Also available in: Unified diff