Revision 519
fixed robot request position code
colonet_dragonfly.c | ||
---|---|---|
31 | 31 |
static void packet_string_to_struct(ColonetRobotServerPacket* dest_pkt, unsigned char* pkt_buf); |
32 | 32 |
static unsigned int two_bytes_to_int(char high, char low); |
33 | 33 |
static void colonet_handle_receive(char type, int source, unsigned char* packet, int length); |
34 |
static void request_abs_position(void); |
|
35 | 34 |
static void move_to_position_routine(int x, int y); |
36 | 35 |
|
37 | 36 |
static PacketGroupHandler colonet_pgh; |
... | ... | |
69 | 68 |
return 0; |
70 | 69 |
} |
71 | 70 |
|
72 |
static void request_abs_position() { |
|
73 |
if (server_xbee_id != -1) { // if -1, then we don't know the server's xbee id yet. |
|
74 |
ColonetRobotServerPacket pkt; |
|
75 |
pkt.client_id = -1; |
|
76 |
pkt.msg_code = ROBOT_REQUEST_POSITION_FROM_SERVER; |
|
77 |
wl_send_robot_to_robot_global_packet(colonet_pgh.groupCode, 0, (char*)&pkt, sizeof(pkt), server_xbee_id, 0); |
|
78 |
} |
|
71 |
void get_absolute_position(int* x, int* y) { |
|
72 |
*x = robot_x; |
|
73 |
*y = robot_y; |
|
79 | 74 |
} |
80 | 75 |
|
76 |
void request_abs_position() { |
|
77 |
//usb_puts("requesting_abs_position\n"); |
|
78 |
|
|
79 |
ColonetRobotServerPacket pkt; |
|
80 |
pkt.client_id = -1; |
|
81 |
pkt.msg_code = ROBOT_REQUEST_POSITION_FROM_SERVER; |
|
82 |
wl_send_global_packet(colonet_pgh.groupCode, 0, (char*)&pkt, sizeof(pkt), 0); |
|
83 |
} |
|
84 |
|
|
81 | 85 |
static void move_to_position_routine(int x, int y) { |
82 | 86 |
/* TODO emarinel - control algorithm */ |
83 | 87 |
motor1_set(1, 200); |
... | ... | |
194 | 198 |
robot_x = int_args[0]; |
195 | 199 |
robot_y = int_args[1]; |
196 | 200 |
|
197 |
sprintf(buf, "my position is: %d %d\n", robot_x, robot_y);
|
|
201 |
sprintf(buf, "pos is: %d %d\n", robot_x, robot_y);
|
|
198 | 202 |
usb_puts(buf); |
199 | 203 |
break; |
200 | 204 |
|
Also available in: Unified diff