Revision 659
Added virtual wall support in server
trunk/code/projects/colonet/robot/colonet_dragonfly/colonet_dragonfly.c | ||
---|---|---|
130 | 130 |
// sprintf(buf,"ex:%d ey:%d vx:%d vy:%d\n", e_x, e_y, v_x, v_y); |
131 | 131 |
// usb_puts(buf); |
132 | 132 |
|
133 |
return 150;
|
|
133 |
return 250;
|
|
134 | 134 |
|
135 | 135 |
/* |
136 | 136 |
long e_mag = sqrt_100_approx(e_x*e_x + e_y*e_y); |
trunk/code/projects/colonet/server/Command.cpp | ||
---|---|---|
266 | 266 |
colonet_server->getPositionMonitor()->assignRealId(atoi(tokens[2]), atoi(tokens[3])); |
267 | 267 |
break; |
268 | 268 |
|
269 |
case CLIENT_SET_VIRTUAL_WALL: |
|
270 |
colonet_server->getVirtualWall()->set_coordinates(atoi(tokens[2]), atoi(tokens[3]), atoi(tokens[4]), atoi(tokens[5])); |
|
271 |
break; |
|
272 |
|
|
269 | 273 |
default: |
270 | 274 |
char* my_current_message = "Invalid request!\n"; |
271 | 275 |
//printf("Sending %s\n", my_current_message); |
trunk/code/projects/colonet/server/includes/ColonetServer.h | ||
---|---|---|
9 | 9 |
class ConnectionPool; |
10 | 10 |
|
11 | 11 |
#include <ConnectionPool.h> |
12 |
#include <Log.h> |
|
12 | 13 |
#include <PositionMonitor.h> |
13 |
#include <Log.h>
|
|
14 |
#include <VirtualWall.h>
|
|
14 | 15 |
|
15 | 16 |
class ColonetServer { |
16 | 17 |
public: |
... | ... | |
22 | 23 |
int run_server(void); |
23 | 24 |
int process_received_wireless_message(int dest, char* data, int len); |
24 | 25 |
PositionMonitor* getPositionMonitor(void); |
26 |
VirtualWall* getVirtualWall(void); |
|
25 | 27 |
int run_position_monitor(void); |
26 | 28 |
|
27 | 29 |
private: |
... | ... | |
29 | 31 |
Log* logger; |
30 | 32 |
int listen_socket; |
31 | 33 |
PositionMonitor position_monitor; |
34 |
VirtualWall virtual_wall; |
|
32 | 35 |
|
33 | 36 |
int initialize_wireless(void); |
34 | 37 |
int initialize_connection(int port); |
trunk/code/projects/colonet/server/includes/VirtualWall.h | ||
---|---|---|
1 |
/** |
|
2 |
* Eugene Marinelli |
|
3 |
* |
|
4 |
*/ |
|
5 |
|
|
6 |
#ifndef VIRTUALWALL_H |
|
7 |
#define VIRTUALWALL_H |
|
8 |
|
|
9 |
class VirtualWall { |
|
10 |
public: |
|
11 |
VirtualWall(void); |
|
12 |
~VirtualWall(void); |
|
13 |
|
|
14 |
int set_coordinates(int upper_x, int upper_y, int lower_x, int lower_y); |
|
15 |
void clear(void); |
|
16 |
int get_coordinates(int* upper_x, int* upper_y, int* lower_x, int* lower_y); |
|
17 |
|
|
18 |
private: |
|
19 |
bool wall_available; |
|
20 |
int upper_left_x, upper_left_y; |
|
21 |
int lower_right_x, lower_right_y; |
|
22 |
}; |
|
23 |
|
|
24 |
#endif |
trunk/code/projects/colonet/server/VirtualWall.cpp | ||
---|---|---|
1 |
/** |
|
2 |
* Eugene Marinelli |
|
3 |
*/ |
|
4 |
|
|
5 |
#include <VirtualWall.h> |
|
6 |
|
|
7 |
VirtualWall::VirtualWall(void) { |
|
8 |
wall_available = false; |
|
9 |
} |
|
10 |
|
|
11 |
VirtualWall::~VirtualWall(void) { |
|
12 |
} |
|
13 |
|
|
14 |
int VirtualWall::set_coordinates(int upper_x, int upper_y, int lower_x, int lower_y) { |
|
15 |
if (upper_x < 0 || upper_y < 0 || lower_x < 0 || lower_y < 0) { |
|
16 |
return -1; |
|
17 |
} |
|
18 |
|
|
19 |
upper_left_x = upper_x; |
|
20 |
upper_left_y = upper_y; |
|
21 |
lower_right_x = lower_x; |
|
22 |
lower_right_y = lower_y; |
|
23 |
|
|
24 |
wall_available = true; |
|
25 |
|
|
26 |
return 0; |
|
27 |
} |
|
28 |
|
|
29 |
void VirtualWall::clear() { |
|
30 |
wall_available = false; |
|
31 |
} |
|
32 |
|
|
33 |
int VirtualWall::get_coordinates(int* upper_x, int* upper_y, int* lower_x, int* lower_y) { |
|
34 |
if (wall_available) { |
|
35 |
*upper_x = upper_left_x; |
|
36 |
*upper_y = upper_left_y; |
|
37 |
*lower_x = lower_right_x; |
|
38 |
*lower_y = lower_right_y; |
|
39 |
|
|
40 |
return 0; |
|
41 |
} else { |
|
42 |
return -1; |
|
43 |
} |
|
44 |
} |
trunk/code/projects/colonet/server/ColonetServer.cpp | ||
---|---|---|
288 | 288 |
PositionMonitor* ColonetServer::getPositionMonitor() { |
289 | 289 |
return &position_monitor; |
290 | 290 |
} |
291 |
|
|
292 |
VirtualWall* ColonetServer::getVirtualWall() { |
|
293 |
return &virtual_wall; |
|
294 |
} |
trunk/code/projects/colonet/server/Makefile | ||
---|---|---|
6 | 6 |
CFLAGS = -Wall -Wshadow -Wextra -g |
7 | 7 |
VISIONFLAGS = -ggdb `pkg-config opencv --cflags --libs` |
8 | 8 |
|
9 |
COLONETCPPFILES = Main.cpp ColonetServer.cpp ConnectionPool.cpp Command.cpp colonet_wireless.cpp PositionMonitor.cpp |
|
9 |
COLONETCPPFILES = Main.cpp ColonetServer.cpp ConnectionPool.cpp Command.cpp colonet_wireless.cpp PositionMonitor.cpp VirtualWall.cpp
|
|
10 | 10 |
COLONETCPPOBJECTS = $(COLONETCPPFILES:.cpp=.o) |
11 | 11 |
COLONETFILES = options.c |
12 | 12 |
COLONETOBJECTS = $(COLONETFILES:.c=.o) |
trunk/code/projects/colonet/server/PositionMonitor.cpp | ||
---|---|---|
16 | 16 |
using namespace std; |
17 | 17 |
|
18 | 18 |
#define MAX_POSITIONS 20 |
19 |
#define SAME_ROBOT_DISTANCE_THRESHOLD 110
|
|
19 |
#define SAME_ROBOT_DISTANCE_THRESHOLD 150
|
|
20 | 20 |
#define ROBOT_DELETE_BUFFER 10 |
21 | 21 |
#define CAM_UPDATE_PERIOD 100000 |
22 | 22 |
|
trunk/code/projects/colonet/common/colonet_defs.h | ||
---|---|---|
151 | 151 |
|
152 | 152 |
#define SERVER_REPORT_ROBOT_LOST 0x58 |
153 | 153 |
|
154 |
#define CLIENT_SET_VIRTUAL_WALL 0x59 |
|
155 |
|
|
154 | 156 |
/* End low-level robot commands */ |
155 | 157 |
|
156 | 158 |
|
Also available in: Unified diff