This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
miabot.h
141 lines (107 loc) · 3.56 KB
/
miabot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/* miabot.h
* Miabot Plugin for Player
* Copyright (C) - Joseph Baxter {joseph.lee.baxter@gmail.com}
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _MIABOTDEVICE_H
#define _MIABOTDEVICE_H
#include <libplayercore/playercore.h>
#include <string>
#include "miabot_params.h"
using namespace std;
#define CAM_IMAGE_WIDTH 176
#define CAM_IMAGE_HEIGHT 144
#define MAX_BLOBS 8
typedef struct
{
int redmin;
int greenmin;
int bluemin;
int redmax;
int greenmax;
int bluemax;
} color_config;
typedef struct player_miabot_data{
player_position2d_data_t position2d;
player_sonar_data_t sonar;
player_sonar_data_t photodiode;
player_gripper_data_t gripper;
player_gripper_data_t lift;
player_position2d_data_t compass;
player_blobfinder_data_t blobfinder;
}__attribute__((packed)) player_miabot_data_t;
class Miabot : public Driver
{
public:
Miabot(ConfigFile* cf, int section);
~Miabot (void);
virtual int Setup();
virtual int Shutdown();
virtual int Subscribe(player_devaddr_t id);
virtual int Unsubscribe(player_devaddr_t id);
virtual void Main();
virtual int ProcessMessage(QueuePointer & resp_queue, player_msghdr * hdr,
void * data);
private:
player_miabot_data_t miabot_data;
player_devaddr_t tracker_id;
player_devaddr_t position2d_id;
player_devaddr_t sonar_id;
player_devaddr_t gripper_id;
player_devaddr_t lift_id;
player_devaddr_t compass_id;
player_devaddr_t photodiode_id;
player_devaddr_t blobfinder_id;
int position2d_subscriptions;
int compass_subscriptions;
int sonar_subscriptions;
int gripper_subscriptions;
int lift_subscriptions;
int photodiode_subscriptions;
int blobfinder_subscriptions;
int set_cam;
bool s_cmap;
string bluetooth_mac;
string bluetooth_router;
string bluetooth_port;
int bluetooth_type;
color_config color[MAX_BLOBS];
int num_blobs;
int ping;
int prate, erate, swait; //ping rate, enc rate, socket wait
int white, adj, filt; // camera settings
bool tracker; // tacker plugin
int open_arg, close_arg; // gripper settings
int up_arg, down_arg; // lift settings
Device* position;
// current odom pose
double position_x, position_y, position_a;
bool buffer; // buffer last sonar echo received
//methods
void update_everything(player_miabot_data_t* d);
int HandleCommand(player_msghdr * hdr, void * data);
int HandleConfig(QueuePointer & resp_queue, player_msghdr * hdr,
void * data);
void reset_odometry();
void ToggleMotorPower(bool val);
int SetupPosition();
int ShutdownPosition();
void ProcessPositionData(player_position2d_data_t* data);
int HandleGripperCommand(player_msghdr * hdr, void * data);
int HandleLiftCommand(player_msghdr * hdr, void * data);
};
#endif