Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / diagnostic_station / station / robot_comm.c @ 1181

History | View | Annotate | Download (1.91 KB)

1
#include <dragonfly_lib.h>
2
#include <wireless.h>
3

    
4
#include "robot_comm.h"
5
#include "../common/comm_station_robot.h"
6

    
7
// A packet that is followed by a "done" packet from the robot.
8
static void send_command_packet (char type, char *data, int len)
9
{
10
        wl_send_global_packet (station_robot_group, type, data, len, 0);
11
        
12
        // TODO: is it guaranteed that the package will be sent on the next call to wl_do, or
13
        // do we have to call wl_do in a loop?
14

    
15
        // TODO: wait for "done" from robot.
16

    
17
        wl_do ();
18
}
19

    
20
// A packet that is followed by a data packet from the robot
21
//static void send_request_packet
22
//{
23
//
24
//}
25

    
26

    
27

    
28

    
29
void robot_set_orbs (uint8_t red1, uint8_t green1, uint8_t blue1, uint8_t red2, uint8_t green2, uint8_t blue2)
30
{
31
        char data[6];
32

    
33
        data[0]=red1;
34
        data[1]=green1;
35
        data[2]=blue1;
36
        
37
        data[3]=red2;
38
        data[4]=green2;
39
        data[5]=blue2;
40

    
41
        send_command_packet (station_robot_set_orbs, data, 6);
42
}
43

    
44
void robot_set_motors (uint8_t direction1, uint8_t speed1, uint8_t direction2, uint8_t speed2)
45
{
46
        char data[4];
47
        
48
        data[0]=direction1;
49
        data[1]=speed1;
50
        data[2]=direction2;
51
        data[3]=speed2;
52
        
53
        send_command_packet (station_robot_set_motors, data, 4);
54
}
55

    
56
void robot_set_motors_time (uint8_t direction1, uint8_t speed1, uint8_t direction2, uint8_t speed2, uint16_t time_ms)
57
{
58
        char data[6];
59
        
60
        data[0]=direction1;
61
        data[1]=speed1;
62
        data[2]=direction2;
63
        data[3]=speed2;
64
        data[4]=WORD_BYTE_0(time_ms);
65
        data[5]=WORD_BYTE_1(time_ms);
66
        
67
        send_command_packet (station_robot_set_motors, data, 6);
68
}
69

    
70
void robot_set_motors_off (void)
71
{
72
        send_command_packet (station_robot_set_motors_off, NULL, 0);
73
}
74

    
75
void robot_set_bom (uint16_t bitmask)
76
{
77
        char data[2];
78
        
79
        data[0]=WORD_BYTE_0(bitmask);
80
        data[1]=WORD_BYTE_1(bitmask);
81
        
82
        send_command_packet (station_robot_set_bom, data, 2);
83
}
84

    
85
//void robot_read_encoders ()
86
//{
87
//        send_request_packet (station_robot_read_enocders, NULL, 0);
88
//}