MotorInterface.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __INTERFACES_MOTORINTERFACE_H_
00025 #define __INTERFACES_MOTORINTERFACE_H_
00026
00027 #include <interface/interface.h>
00028 #include <interface/message.h>
00029 #include <interface/field_iterator.h>
00030
00031 namespace fawkes {
00032
00033 class MotorInterface : public Interface
00034 {
00035
00036 INTERFACE_MGMT_FRIENDS(MotorInterface)
00037
00038 public:
00039
00040 static const unsigned int MOTOR_ENABLED;
00041 static const unsigned int MOTOR_DISABLED;
00042 static const unsigned int DRIVE_MODE_RPM;
00043 static const unsigned int DRIVE_MODE_TRANS;
00044 static const unsigned int DRIVE_MODE_ROT;
00045 static const unsigned int DRIVE_MODE_TRANS_ROT;
00046 static const unsigned int DRIVE_MODE_ORBIT;
00047 static const unsigned int DRIVE_MODE_LINE_TRANS_ROT;
00048
00049 private:
00050
00051 typedef struct {
00052 unsigned int motor_state;
00053
00054
00055 unsigned int drive_mode;
00056
00057
00058 unsigned int controller;
00059
00060
00061
00062 int right_rpm;
00063
00064
00065 int rear_rpm;
00066
00067
00068 int left_rpm;
00069
00070
00071 float odometry_path_length;
00072
00073
00074 float odometry_position_x;
00075
00076
00077 float odometry_position_y;
00078
00079
00080 float odometry_orientation;
00081
00082
00083 float vx;
00084
00085
00086 float vy;
00087
00088
00089 float omega;
00090
00091
00092 char controller_thread_name[64];
00093
00094
00095
00096
00097 } MotorInterface_data_t;
00098
00099 MotorInterface_data_t *data;
00100
00101 public:
00102
00103 class SetMotorStateMessage : public Message
00104 {
00105 private:
00106
00107 typedef struct {
00108 unsigned int motor_state;
00109
00110
00111 } SetMotorStateMessage_data_t;
00112
00113 SetMotorStateMessage_data_t *data;
00114
00115 public:
00116 SetMotorStateMessage(const unsigned int ini_motor_state);
00117 SetMotorStateMessage();
00118 ~SetMotorStateMessage();
00119
00120 SetMotorStateMessage(const SetMotorStateMessage *m);
00121
00122 unsigned int motor_state() const;
00123 void set_motor_state(const unsigned int new_motor_state);
00124 size_t maxlenof_motor_state() const;
00125 virtual Message * clone() const;
00126 };
00127
00128 class AcquireControlMessage : public Message
00129 {
00130 private:
00131
00132 typedef struct {
00133 unsigned int controller;
00134
00135
00136
00137 char controller_thread_name[64];
00138
00139
00140
00141
00142 } AcquireControlMessage_data_t;
00143
00144 AcquireControlMessage_data_t *data;
00145
00146 public:
00147 AcquireControlMessage(const unsigned int ini_controller, const char * ini_controller_thread_name);
00148 AcquireControlMessage();
00149 ~AcquireControlMessage();
00150
00151 AcquireControlMessage(const AcquireControlMessage *m);
00152
00153 unsigned int controller() const;
00154 void set_controller(const unsigned int new_controller);
00155 size_t maxlenof_controller() const;
00156 char * controller_thread_name() const;
00157 void set_controller_thread_name(const char * new_controller_thread_name);
00158 size_t maxlenof_controller_thread_name() const;
00159 virtual Message * clone() const;
00160 };
00161
00162 class ResetOdometryMessage : public Message
00163 {
00164 public:
00165 ResetOdometryMessage();
00166 ~ResetOdometryMessage();
00167
00168 ResetOdometryMessage(const ResetOdometryMessage *m);
00169
00170 virtual Message * clone() const;
00171 };
00172
00173 class DriveRPMMessage : public Message
00174 {
00175 private:
00176
00177 typedef struct {
00178 float front_right;
00179 float front_left;
00180 float rear;
00181 } DriveRPMMessage_data_t;
00182
00183 DriveRPMMessage_data_t *data;
00184
00185 public:
00186 DriveRPMMessage(const float ini_front_right, const float ini_front_left, const float ini_rear);
00187 DriveRPMMessage();
00188 ~DriveRPMMessage();
00189
00190 DriveRPMMessage(const DriveRPMMessage *m);
00191
00192 float front_right() const;
00193 void set_front_right(const float new_front_right);
00194 size_t maxlenof_front_right() const;
00195 float front_left() const;
00196 void set_front_left(const float new_front_left);
00197 size_t maxlenof_front_left() const;
00198 float rear() const;
00199 void set_rear(const float new_rear);
00200 size_t maxlenof_rear() const;
00201 virtual Message * clone() const;
00202 };
00203
00204 class GotoMessage : public Message
00205 {
00206 private:
00207
00208 typedef struct {
00209 float x;
00210 float y;
00211 float phi;
00212 float time_sec;
00213 } GotoMessage_data_t;
00214
00215 GotoMessage_data_t *data;
00216
00217 public:
00218 GotoMessage(const float ini_x, const float ini_y, const float ini_phi, const float ini_time_sec);
00219 GotoMessage();
00220 ~GotoMessage();
00221
00222 GotoMessage(const GotoMessage *m);
00223
00224 float x() const;
00225 void set_x(const float new_x);
00226 size_t maxlenof_x() const;
00227 float y() const;
00228 void set_y(const float new_y);
00229 size_t maxlenof_y() const;
00230 float phi() const;
00231 void set_phi(const float new_phi);
00232 size_t maxlenof_phi() const;
00233 float time_sec() const;
00234 void set_time_sec(const float new_time_sec);
00235 size_t maxlenof_time_sec() const;
00236 virtual Message * clone() const;
00237 };
00238
00239 class TransMessage : public Message
00240 {
00241 private:
00242
00243 typedef struct {
00244 float vx;
00245 float vy;
00246 } TransMessage_data_t;
00247
00248 TransMessage_data_t *data;
00249
00250 public:
00251 TransMessage(const float ini_vx, const float ini_vy);
00252 TransMessage();
00253 ~TransMessage();
00254
00255 TransMessage(const TransMessage *m);
00256
00257 float vx() const;
00258 void set_vx(const float new_vx);
00259 size_t maxlenof_vx() const;
00260 float vy() const;
00261 void set_vy(const float new_vy);
00262 size_t maxlenof_vy() const;
00263 virtual Message * clone() const;
00264 };
00265
00266 class RotMessage : public Message
00267 {
00268 private:
00269
00270 typedef struct {
00271 float omega;
00272 } RotMessage_data_t;
00273
00274 RotMessage_data_t *data;
00275
00276 public:
00277 RotMessage(const float ini_omega);
00278 RotMessage();
00279 ~RotMessage();
00280
00281 RotMessage(const RotMessage *m);
00282
00283 float omega() const;
00284 void set_omega(const float new_omega);
00285 size_t maxlenof_omega() const;
00286 virtual Message * clone() const;
00287 };
00288
00289 class TransRotMessage : public Message
00290 {
00291 private:
00292
00293 typedef struct {
00294 float vx;
00295 float vy;
00296 float omega;
00297 } TransRotMessage_data_t;
00298
00299 TransRotMessage_data_t *data;
00300
00301 public:
00302 TransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega);
00303 TransRotMessage();
00304 ~TransRotMessage();
00305
00306 TransRotMessage(const TransRotMessage *m);
00307
00308 float vx() const;
00309 void set_vx(const float new_vx);
00310 size_t maxlenof_vx() const;
00311 float vy() const;
00312 void set_vy(const float new_vy);
00313 size_t maxlenof_vy() const;
00314 float omega() const;
00315 void set_omega(const float new_omega);
00316 size_t maxlenof_omega() const;
00317 virtual Message * clone() const;
00318 };
00319
00320 class OrbitMessage : public Message
00321 {
00322 private:
00323
00324 typedef struct {
00325 float px;
00326 float py;
00327 float omega;
00328 } OrbitMessage_data_t;
00329
00330 OrbitMessage_data_t *data;
00331
00332 public:
00333 OrbitMessage(const float ini_px, const float ini_py, const float ini_omega);
00334 OrbitMessage();
00335 ~OrbitMessage();
00336
00337 OrbitMessage(const OrbitMessage *m);
00338
00339 float px() const;
00340 void set_px(const float new_px);
00341 size_t maxlenof_px() const;
00342 float py() const;
00343 void set_py(const float new_py);
00344 size_t maxlenof_py() const;
00345 float omega() const;
00346 void set_omega(const float new_omega);
00347 size_t maxlenof_omega() const;
00348 virtual Message * clone() const;
00349 };
00350
00351 class LinTransRotMessage : public Message
00352 {
00353 private:
00354
00355 typedef struct {
00356 float vx;
00357 float vy;
00358 float omega;
00359 } LinTransRotMessage_data_t;
00360
00361 LinTransRotMessage_data_t *data;
00362
00363 public:
00364 LinTransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega);
00365 LinTransRotMessage();
00366 ~LinTransRotMessage();
00367
00368 LinTransRotMessage(const LinTransRotMessage *m);
00369
00370 float vx() const;
00371 void set_vx(const float new_vx);
00372 size_t maxlenof_vx() const;
00373 float vy() const;
00374 void set_vy(const float new_vy);
00375 size_t maxlenof_vy() const;
00376 float omega() const;
00377 void set_omega(const float new_omega);
00378 size_t maxlenof_omega() const;
00379 virtual Message * clone() const;
00380 };
00381
00382 virtual bool message_valid(const Message *message) const;
00383 private:
00384 MotorInterface();
00385 ~MotorInterface();
00386
00387 public:
00388
00389 unsigned int motor_state() const;
00390 void set_motor_state(const unsigned int new_motor_state);
00391 size_t maxlenof_motor_state() const;
00392 unsigned int drive_mode() const;
00393 void set_drive_mode(const unsigned int new_drive_mode);
00394 size_t maxlenof_drive_mode() const;
00395 int right_rpm() const;
00396 void set_right_rpm(const int new_right_rpm);
00397 size_t maxlenof_right_rpm() const;
00398 int rear_rpm() const;
00399 void set_rear_rpm(const int new_rear_rpm);
00400 size_t maxlenof_rear_rpm() const;
00401 int left_rpm() const;
00402 void set_left_rpm(const int new_left_rpm);
00403 size_t maxlenof_left_rpm() const;
00404 float odometry_path_length() const;
00405 void set_odometry_path_length(const float new_odometry_path_length);
00406 size_t maxlenof_odometry_path_length() const;
00407 float odometry_position_x() const;
00408 void set_odometry_position_x(const float new_odometry_position_x);
00409 size_t maxlenof_odometry_position_x() const;
00410 float odometry_position_y() const;
00411 void set_odometry_position_y(const float new_odometry_position_y);
00412 size_t maxlenof_odometry_position_y() const;
00413 float odometry_orientation() const;
00414 void set_odometry_orientation(const float new_odometry_orientation);
00415 size_t maxlenof_odometry_orientation() const;
00416 float vx() const;
00417 void set_vx(const float new_vx);
00418 size_t maxlenof_vx() const;
00419 float vy() const;
00420 void set_vy(const float new_vy);
00421 size_t maxlenof_vy() const;
00422 float omega() const;
00423 void set_omega(const float new_omega);
00424 size_t maxlenof_omega() const;
00425 unsigned int controller() const;
00426 void set_controller(const unsigned int new_controller);
00427 size_t maxlenof_controller() const;
00428 char * controller_thread_name() const;
00429 void set_controller_thread_name(const char * new_controller_thread_name);
00430 size_t maxlenof_controller_thread_name() const;
00431 virtual Message * create_message(const char *type) const;
00432
00433 virtual void copy_values(const Interface *other);
00434
00435 };
00436
00437 }
00438
00439 #endif