MotorInterface.cpp

00001
00002 /***************************************************************************
00003  *  MotorInterface.cpp - Fawkes BlackBoard Interface - MotorInterface
00004  *
00005  *  Templated created:   Thu Oct 12 10:49:19 2006
00006  *  Copyright  2007  Martin Liebenberg, Tim Niemueller
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023
00024 #include <interfaces/MotorInterface.h>
00025
00026 #include <core/exceptions/software.h>
00027
00028 #include <cstring>
00029 #include <cstdlib>
00030
00031 namespace fawkes {
00032 
00033 /** @class MotorInterface <interfaces/MotorInterface.h>
00034  * MotorInterface Fawkes BlackBoard Interface.
00035  * This interface is currently prepared best for a holonomic robot.
00036       It will need modifications or a split to support differential drives.
00037     
00038  * @ingroup FawkesInterfaces
00039  */
00040
00041 
00042 /** MOTOR_ENABLED constant */
00043 const unsigned int MotorInterface::MOTOR_ENABLED = 0;
00044 /** MOTOR_DISABLED constant */
00045 const unsigned int MotorInterface::MOTOR_DISABLED = 1;
00046 /** DRIVE_MODE_RPM constant */
00047 const unsigned int MotorInterface::DRIVE_MODE_RPM = 1;
00048 /** DRIVE_MODE_TRANS constant */
00049 const unsigned int MotorInterface::DRIVE_MODE_TRANS = 2;
00050 /** DRIVE_MODE_ROT constant */
00051 const unsigned int MotorInterface::DRIVE_MODE_ROT = 3;
00052 /** DRIVE_MODE_TRANS_ROT constant */
00053 const unsigned int MotorInterface::DRIVE_MODE_TRANS_ROT = 4;
00054 /** DRIVE_MODE_ORBIT constant */
00055 const unsigned int MotorInterface::DRIVE_MODE_ORBIT = 5;
00056 /** DRIVE_MODE_LINE_TRANS_ROT constant */
00057 const unsigned int MotorInterface::DRIVE_MODE_LINE_TRANS_ROT = 6;
00058 
00059 /** Constructor */
00060 MotorInterface::MotorInterface() : Interface()
00061 {
00062   data_size = sizeof(MotorInterface_data_t);
00063   data_ptr  = malloc(data_size);
00064   data      = (MotorInterface_data_t *)data_ptr;
00065   memset(data_ptr, 0, data_size);
00066   add_fieldinfo(IFT_UINT, "motor_state", 1, &data->motor_state);
00067   add_fieldinfo(IFT_UINT, "drive_mode", 1, &data->drive_mode);
00068   add_fieldinfo(IFT_INT, "right_rpm", 1, &data->right_rpm);
00069   add_fieldinfo(IFT_INT, "rear_rpm", 1, &data->rear_rpm);
00070   add_fieldinfo(IFT_INT, "left_rpm", 1, &data->left_rpm);
00071   add_fieldinfo(IFT_FLOAT, "odometry_path_length", 1, &data->odometry_path_length);
00072   add_fieldinfo(IFT_FLOAT, "odometry_position_x", 1, &data->odometry_position_x);
00073   add_fieldinfo(IFT_FLOAT, "odometry_position_y", 1, &data->odometry_position_y);
00074   add_fieldinfo(IFT_FLOAT, "odometry_orientation", 1, &data->odometry_orientation);
00075   add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
00076   add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
00077   add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
00078   add_fieldinfo(IFT_UINT, "controller", 1, &data->controller);
00079   add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
00080   add_messageinfo("SetMotorStateMessage");
00081   add_messageinfo("AcquireControlMessage");
00082   add_messageinfo("ResetOdometryMessage");
00083   add_messageinfo("DriveRPMMessage");
00084   add_messageinfo("GotoMessage");
00085   add_messageinfo("TransMessage");
00086   add_messageinfo("RotMessage");
00087   add_messageinfo("TransRotMessage");
00088   add_messageinfo("OrbitMessage");
00089   add_messageinfo("LinTransRotMessage");
00090   unsigned char tmp_hash[] = {0x60, 0x28, 0x2b, 0x64, 0x6d, 0xe1, 0x7d, 0xba, 0x1b, 0x43, 0xad, 0x7e, 0x38, 0xa9, 0x76, 0x38};
00091   set_hash(tmp_hash);
00092 }
00093 
00094 /** Destructor */
00095 MotorInterface::~MotorInterface()
00096 {
00097   free(data_ptr);
00098 }
00099 /* Methods */
00100 /** Get motor_state value.
00101  * 
00102       The current state of the motor.
00103     
00104  * @return motor_state value
00105  */
00106 unsigned int
00107 MotorInterface::motor_state() const
00108 {
00109   return data->motor_state;
00110 }
00111 
00112 /** Get maximum length of motor_state value.
00113  * @return length of motor_state value, can be length of the array or number of 
00114  * maximum number of characters for a string
00115  */
00116 size_t
00117 MotorInterface::maxlenof_motor_state() const
00118 {
00119   return 1;
00120 }
00121 
00122 /** Set motor_state value.
00123  * 
00124       The current state of the motor.
00125     
00126  * @param new_motor_state new motor_state value
00127  */
00128 void
00129 MotorInterface::set_motor_state(const unsigned int new_motor_state)
00130 {
00131   data->motor_state = new_motor_state;
00132 }
00133 
00134 /** Get drive_mode value.
00135  * 
00136       The current drive mode of the motor.
00137     
00138  * @return drive_mode value
00139  */
00140 unsigned int
00141 MotorInterface::drive_mode() const
00142 {
00143   return data->drive_mode;
00144 }
00145 
00146 /** Get maximum length of drive_mode value.
00147  * @return length of drive_mode value, can be length of the array or number of 
00148  * maximum number of characters for a string
00149  */
00150 size_t
00151 MotorInterface::maxlenof_drive_mode() const
00152 {
00153   return 1;
00154 }
00155 
00156 /** Set drive_mode value.
00157  * 
00158       The current drive mode of the motor.
00159     
00160  * @param new_drive_mode new drive_mode value
00161  */
00162 void
00163 MotorInterface::set_drive_mode(const unsigned int new_drive_mode)
00164 {
00165   data->drive_mode = new_drive_mode;
00166 }
00167 
00168 /** Get right_rpm value.
00169  * 
00170       RPM of the motor on the right front of the robot.
00171     
00172  * @return right_rpm value
00173  */
00174 int
00175 MotorInterface::right_rpm() const
00176 {
00177   return data->right_rpm;
00178 }
00179 
00180 /** Get maximum length of right_rpm value.
00181  * @return length of right_rpm value, can be length of the array or number of 
00182  * maximum number of characters for a string
00183  */
00184 size_t
00185 MotorInterface::maxlenof_right_rpm() const
00186 {
00187   return 1;
00188 }
00189 
00190 /** Set right_rpm value.
00191  * 
00192       RPM of the motor on the right front of the robot.
00193     
00194  * @param new_right_rpm new right_rpm value
00195  */
00196 void
00197 MotorInterface::set_right_rpm(const int new_right_rpm)
00198 {
00199   data->right_rpm = new_right_rpm;
00200 }
00201 
00202 /** Get rear_rpm value.
00203  * 
00204       RPM of motor on the rear of the robot.
00205     
00206  * @return rear_rpm value
00207  */
00208 int
00209 MotorInterface::rear_rpm() const
00210 {
00211   return data->rear_rpm;
00212 }
00213 
00214 /** Get maximum length of rear_rpm value.
00215  * @return length of rear_rpm value, can be length of the array or number of 
00216  * maximum number of characters for a string
00217  */
00218 size_t
00219 MotorInterface::maxlenof_rear_rpm() const
00220 {
00221   return 1;
00222 }
00223 
00224 /** Set rear_rpm value.
00225  * 
00226       RPM of motor on the rear of the robot.
00227     
00228  * @param new_rear_rpm new rear_rpm value
00229  */
00230 void
00231 MotorInterface::set_rear_rpm(const int new_rear_rpm)
00232 {
00233   data->rear_rpm = new_rear_rpm;
00234 }
00235 
00236 /** Get left_rpm value.
00237  * 
00238       RPM of the motor on the left front of the robot.
00239     
00240  * @return left_rpm value
00241  */
00242 int
00243 MotorInterface::left_rpm() const
00244 {
00245   return data->left_rpm;
00246 }
00247 
00248 /** Get maximum length of left_rpm value.
00249  * @return length of left_rpm value, can be length of the array or number of 
00250  * maximum number of characters for a string
00251  */
00252 size_t
00253 MotorInterface::maxlenof_left_rpm() const
00254 {
00255   return 1;
00256 }
00257 
00258 /** Set left_rpm value.
00259  * 
00260       RPM of the motor on the left front of the robot.
00261     
00262  * @param new_left_rpm new left_rpm value
00263  */
00264 void
00265 MotorInterface::set_left_rpm(const int new_left_rpm)
00266 {
00267   data->left_rpm = new_left_rpm;
00268 }
00269 
00270 /** Get odometry_path_length value.
00271  * 
00272       The actual length of the robot's trajectory since the last ResetOdometry.
00273     
00274  * @return odometry_path_length value
00275  */
00276 float
00277 MotorInterface::odometry_path_length() const
00278 {
00279   return data->odometry_path_length;
00280 }
00281 
00282 /** Get maximum length of odometry_path_length value.
00283  * @return length of odometry_path_length value, can be length of the array or number of 
00284  * maximum number of characters for a string
00285  */
00286 size_t
00287 MotorInterface::maxlenof_odometry_path_length() const
00288 {
00289   return 1;
00290 }
00291 
00292 /** Set odometry_path_length value.
00293  * 
00294       The actual length of the robot's trajectory since the last ResetOdometry.
00295     
00296  * @param new_odometry_path_length new odometry_path_length value
00297  */
00298 void
00299 MotorInterface::set_odometry_path_length(const float new_odometry_path_length)
00300 {
00301   data->odometry_path_length = new_odometry_path_length;
00302 }
00303 
00304 /** Get odometry_position_x value.
00305  * 
00306       The actual position of the robot relative to the position at the last ResetOdometry.
00307     
00308  * @return odometry_position_x value
00309  */
00310 float
00311 MotorInterface::odometry_position_x() const
00312 {
00313   return data->odometry_position_x;
00314 }
00315 
00316 /** Get maximum length of odometry_position_x value.
00317  * @return length of odometry_position_x value, can be length of the array or number of 
00318  * maximum number of characters for a string
00319  */
00320 size_t
00321 MotorInterface::maxlenof_odometry_position_x() const
00322 {
00323   return 1;
00324 }
00325 
00326 /** Set odometry_position_x value.
00327  * 
00328       The actual position of the robot relative to the position at the last ResetOdometry.
00329     
00330  * @param new_odometry_position_x new odometry_position_x value
00331  */
00332 void
00333 MotorInterface::set_odometry_position_x(const float new_odometry_position_x)
00334 {
00335   data->odometry_position_x = new_odometry_position_x;
00336 }
00337 
00338 /** Get odometry_position_y value.
00339  * 
00340       The actual position of the robot relative to the position at the last ResetOdometry.
00341     
00342  * @return odometry_position_y value
00343  */
00344 float
00345 MotorInterface::odometry_position_y() const
00346 {
00347   return data->odometry_position_y;
00348 }
00349 
00350 /** Get maximum length of odometry_position_y value.
00351  * @return length of odometry_position_y value, can be length of the array or number of 
00352  * maximum number of characters for a string
00353  */
00354 size_t
00355 MotorInterface::maxlenof_odometry_position_y() const
00356 {
00357   return 1;
00358 }
00359 
00360 /** Set odometry_position_y value.
00361  * 
00362       The actual position of the robot relative to the position at the last ResetOdometry.
00363     
00364  * @param new_odometry_position_y new odometry_position_y value
00365  */
00366 void
00367 MotorInterface::set_odometry_position_y(const float new_odometry_position_y)
00368 {
00369   data->odometry_position_y = new_odometry_position_y;
00370 }
00371 
00372 /** Get odometry_orientation value.
00373  * 
00374       The actual orientation of the robot relative to the orientation at the last ResetOdometry.
00375     
00376  * @return odometry_orientation value
00377  */
00378 float
00379 MotorInterface::odometry_orientation() const
00380 {
00381   return data->odometry_orientation;
00382 }
00383 
00384 /** Get maximum length of odometry_orientation value.
00385  * @return length of odometry_orientation value, can be length of the array or number of 
00386  * maximum number of characters for a string
00387  */
00388 size_t
00389 MotorInterface::maxlenof_odometry_orientation() const
00390 {
00391   return 1;
00392 }
00393 
00394 /** Set odometry_orientation value.
00395  * 
00396       The actual orientation of the robot relative to the orientation at the last ResetOdometry.
00397     
00398  * @param new_odometry_orientation new odometry_orientation value
00399  */
00400 void
00401 MotorInterface::set_odometry_orientation(const float new_odometry_orientation)
00402 {
00403   data->odometry_orientation = new_odometry_orientation;
00404 }
00405 
00406 /** Get vx value.
00407  * 
00408       VX of the robot in m/s. Forward.
00409     
00410  * @return vx value
00411  */
00412 float
00413 MotorInterface::vx() const
00414 {
00415   return data->vx;
00416 }
00417 
00418 /** Get maximum length of vx value.
00419  * @return length of vx value, can be length of the array or number of 
00420  * maximum number of characters for a string
00421  */
00422 size_t
00423 MotorInterface::maxlenof_vx() const
00424 {
00425   return 1;
00426 }
00427 
00428 /** Set vx value.
00429  * 
00430       VX of the robot in m/s. Forward.
00431     
00432  * @param new_vx new vx value
00433  */
00434 void
00435 MotorInterface::set_vx(const float new_vx)
00436 {
00437   data->vx = new_vx;
00438 }
00439 
00440 /** Get vy value.
00441  * 
00442       VY of the robot in m/s. Left.
00443     
00444  * @return vy value
00445  */
00446 float
00447 MotorInterface::vy() const
00448 {
00449   return data->vy;
00450 }
00451 
00452 /** Get maximum length of vy value.
00453  * @return length of vy value, can be length of the array or number of 
00454  * maximum number of characters for a string
00455  */
00456 size_t
00457 MotorInterface::maxlenof_vy() const
00458 {
00459   return 1;
00460 }
00461 
00462 /** Set vy value.
00463  * 
00464       VY of the robot in m/s. Left.
00465     
00466  * @param new_vy new vy value
00467  */
00468 void
00469 MotorInterface::set_vy(const float new_vy)
00470 {
00471   data->vy = new_vy;
00472 }
00473 
00474 /** Get omega value.
00475  * 
00476       Rotation speed of the robot in rad/s.
00477     
00478  * @return omega value
00479  */
00480 float
00481 MotorInterface::omega() const
00482 {
00483   return data->omega;
00484 }
00485 
00486 /** Get maximum length of omega value.
00487  * @return length of omega value, can be length of the array or number of 
00488  * maximum number of characters for a string
00489  */
00490 size_t
00491 MotorInterface::maxlenof_omega() const
00492 {
00493   return 1;
00494 }
00495 
00496 /** Set omega value.
00497  * 
00498       Rotation speed of the robot in rad/s.
00499     
00500  * @param new_omega new omega value
00501  */
00502 void
00503 MotorInterface::set_omega(const float new_omega)
00504 {
00505   data->omega = new_omega;
00506 }
00507 
00508 /** Get controller value.
00509  * 
00510      The ID of the controller. The controller ID is the instance serial of the sending
00511      interface. Only from this interface instance command messages are accepted.
00512     
00513  * @return controller value
00514  */
00515 unsigned int
00516 MotorInterface::controller() const
00517 {
00518   return data->controller;
00519 }
00520 
00521 /** Get maximum length of controller value.
00522  * @return length of controller value, can be length of the array or number of 
00523  * maximum number of characters for a string
00524  */
00525 size_t
00526 MotorInterface::maxlenof_controller() const
00527 {
00528   return 1;
00529 }
00530 
00531 /** Set controller value.
00532  * 
00533      The ID of the controller. The controller ID is the instance serial of the sending
00534      interface. Only from this interface instance command messages are accepted.
00535     
00536  * @param new_controller new controller value
00537  */
00538 void
00539 MotorInterface::set_controller(const unsigned int new_controller)
00540 {
00541   data->controller = new_controller;
00542 }
00543 
00544 /** Get controller_thread_name value.
00545  * 
00546      The name of the controlling thread, for easier debugging. This is informative only
00547      and actually two threads may share an interface instance (although this should be
00548      avoided since the interface locking has to be reproduced for these threads then).
00549   
00550  * @return controller_thread_name value
00551  */
00552 char *
00553 MotorInterface::controller_thread_name() const
00554 {
00555   return data->controller_thread_name;
00556 }
00557 
00558 /** Get maximum length of controller_thread_name value.
00559  * @return length of controller_thread_name value, can be length of the array or number of 
00560  * maximum number of characters for a string
00561  */
00562 size_t
00563 MotorInterface::maxlenof_controller_thread_name() const
00564 {
00565   return 64;
00566 }
00567 
00568 /** Set controller_thread_name value.
00569  * 
00570      The name of the controlling thread, for easier debugging. This is informative only
00571      and actually two threads may share an interface instance (although this should be
00572      avoided since the interface locking has to be reproduced for these threads then).
00573   
00574  * @param new_controller_thread_name new controller_thread_name value
00575  */
00576 void
00577 MotorInterface::set_controller_thread_name(const char * new_controller_thread_name)
00578 {
00579   strncpy(data->controller_thread_name, new_controller_thread_name, sizeof(data->controller_thread_name));
00580 }
00581
00582 /* =========== message create =========== */
00583 Message *
00584 MotorInterface::create_message(const char *type) const
00585 {
00586   if ( strncmp("SetMotorStateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00587     return new SetMotorStateMessage();
00588   } else if ( strncmp("AcquireControlMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00589     return new AcquireControlMessage();
00590   } else if ( strncmp("ResetOdometryMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00591     return new ResetOdometryMessage();
00592   } else if ( strncmp("DriveRPMMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00593     return new DriveRPMMessage();
00594   } else if ( strncmp("GotoMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00595     return new GotoMessage();
00596   } else if ( strncmp("TransMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00597     return new TransMessage();
00598   } else if ( strncmp("RotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00599     return new RotMessage();
00600   } else if ( strncmp("TransRotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00601     return new TransRotMessage();
00602   } else if ( strncmp("OrbitMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00603     return new OrbitMessage();
00604   } else if ( strncmp("LinTransRotMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00605     return new LinTransRotMessage();
00606   } else {
00607     throw UnknownTypeException("The given type '%s' does not match any known "
00608                                "message type for this interface type.", type);
00609   }
00610 }
00611
00612 
00613 /** Copy values from other interface.
00614  * @param other other interface to copy values from
00615  */
00616 void
00617 MotorInterface::copy_values(const Interface *other)
00618 {
00619   const MotorInterface *oi = dynamic_cast<const MotorInterface *>(other);
00620   if (oi == NULL) {
00621     throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00622                                 type(), other->type());
00623   }
00624   memcpy(data, oi->data, sizeof(MotorInterface_data_t));
00625 }
00626
00627 /* =========== messages =========== */
00628 /** @class MotorInterface::SetMotorStateMessage <interfaces/MotorInterface.h>
00629  * SetMotorStateMessage Fawkes BlackBoard Interface Message.
00630  * 
00631     
00632  */
00633
00634 
00635 /** Constructor with initial values.
00636  * @param ini_motor_state initial value for motor_state
00637  */
00638 MotorInterface::SetMotorStateMessage::SetMotorStateMessage(const unsigned int ini_motor_state) : Message("SetMotorStateMessage")
00639 {
00640   data_size = sizeof(SetMotorStateMessage_data_t);
00641   data_ptr  = malloc(data_size);
00642   memset(data_ptr, 0, data_size);
00643   data      = (SetMotorStateMessage_data_t *)data_ptr;
00644   data->motor_state = ini_motor_state;
00645   add_fieldinfo(IFT_UINT, "motor_state", 1, &data->motor_state);
00646 }
00647 /** Constructor */
00648 MotorInterface::SetMotorStateMessage::SetMotorStateMessage() : Message("SetMotorStateMessage")
00649 {
00650   data_size = sizeof(SetMotorStateMessage_data_t);
00651   data_ptr  = malloc(data_size);
00652   memset(data_ptr, 0, data_size);
00653   data      = (SetMotorStateMessage_data_t *)data_ptr;
00654   add_fieldinfo(IFT_UINT, "motor_state", 1, &data->motor_state);
00655 }
00656 
00657 /** Destructor */
00658 MotorInterface::SetMotorStateMessage::~SetMotorStateMessage()
00659 {
00660   free(data_ptr);
00661 }
00662 
00663 /** Copy constructor.
00664  * @param m message to copy from
00665  */
00666 MotorInterface::SetMotorStateMessage::SetMotorStateMessage(const SetMotorStateMessage *m) : Message("SetMotorStateMessage")
00667 {
00668   data_size = m->data_size;
00669   data_ptr  = malloc(data_size);
00670   memcpy(data_ptr, m->data_ptr, data_size);
00671   data      = (SetMotorStateMessage_data_t *)data_ptr;
00672 }
00673
00674 /* Methods */
00675 /** Get motor_state value.
00676  * 
00677       The new motor state to set. Use the MOTOR_* constants.
00678     
00679  * @return motor_state value
00680  */
00681 unsigned int
00682 MotorInterface::SetMotorStateMessage::motor_state() const
00683 {
00684   return data->motor_state;
00685 }
00686 
00687 /** Get maximum length of motor_state value.
00688  * @return length of motor_state value, can be length of the array or number of 
00689  * maximum number of characters for a string
00690  */
00691 size_t
00692 MotorInterface::SetMotorStateMessage::maxlenof_motor_state() const
00693 {
00694   return 1;
00695 }
00696 
00697 /** Set motor_state value.
00698  * 
00699       The new motor state to set. Use the MOTOR_* constants.
00700     
00701  * @param new_motor_state new motor_state value
00702  */
00703 void
00704 MotorInterface::SetMotorStateMessage::set_motor_state(const unsigned int new_motor_state)
00705 {
00706   data->motor_state = new_motor_state;
00707 }
00708 
00709 /** Clone this message.
00710  * Produces a message of the same type as this message and copies the
00711  * data to the new message.
00712  * @return clone of this message
00713  */
00714 Message *
00715 MotorInterface::SetMotorStateMessage::clone() const
00716 {
00717   return new MotorInterface::SetMotorStateMessage(this);
00718 }
00719 /** @class MotorInterface::AcquireControlMessage <interfaces/MotorInterface.h>
00720  * AcquireControlMessage Fawkes BlackBoard Interface Message.
00721  * 
00722     
00723  */
00724
00725 
00726 /** Constructor with initial values.
00727  * @param ini_controller initial value for controller
00728  * @param ini_controller_thread_name initial value for controller_thread_name
00729  */
00730 MotorInterface::AcquireControlMessage::AcquireControlMessage(const unsigned int ini_controller, const char * ini_controller_thread_name) : Message("AcquireControlMessage")
00731 {
00732   data_size = sizeof(AcquireControlMessage_data_t);
00733   data_ptr  = malloc(data_size);
00734   memset(data_ptr, 0, data_size);
00735   data      = (AcquireControlMessage_data_t *)data_ptr;
00736   data->controller = ini_controller;
00737   strncpy(data->controller_thread_name, ini_controller_thread_name, 64);
00738   add_fieldinfo(IFT_UINT, "controller", 1, &data->controller);
00739   add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
00740 }
00741 /** Constructor */
00742 MotorInterface::AcquireControlMessage::AcquireControlMessage() : Message("AcquireControlMessage")
00743 {
00744   data_size = sizeof(AcquireControlMessage_data_t);
00745   data_ptr  = malloc(data_size);
00746   memset(data_ptr, 0, data_size);
00747   data      = (AcquireControlMessage_data_t *)data_ptr;
00748   add_fieldinfo(IFT_UINT, "controller", 1, &data->controller);
00749   add_fieldinfo(IFT_STRING, "controller_thread_name", 64, data->controller_thread_name);
00750 }
00751 
00752 /** Destructor */
00753 MotorInterface::AcquireControlMessage::~AcquireControlMessage()
00754 {
00755   free(data_ptr);
00756 }
00757 
00758 /** Copy constructor.
00759  * @param m message to copy from
00760  */
00761 MotorInterface::AcquireControlMessage::AcquireControlMessage(const AcquireControlMessage *m) : Message("AcquireControlMessage")
00762 {
00763   data_size = m->data_size;
00764   data_ptr  = malloc(data_size);
00765   memcpy(data_ptr, m->data_ptr, data_size);
00766   data      = (AcquireControlMessage_data_t *)data_ptr;
00767 }
00768
00769 /* Methods */
00770 /** Get controller value.
00771  * 
00772      The ID of the controller. The controller ID is the instance serial of the sending
00773      interface. Only from this interface instance command messages are accepted.
00774     
00775  * @return controller value
00776  */
00777 unsigned int
00778 MotorInterface::AcquireControlMessage::controller() const
00779 {
00780   return data->controller;
00781 }
00782 
00783 /** Get maximum length of controller value.
00784  * @return length of controller value, can be length of the array or number of 
00785  * maximum number of characters for a string
00786  */
00787 size_t
00788 MotorInterface::AcquireControlMessage::maxlenof_controller() const
00789 {
00790   return 1;
00791 }
00792 
00793 /** Set controller value.
00794  * 
00795      The ID of the controller. The controller ID is the instance serial of the sending
00796      interface. Only from this interface instance command messages are accepted.
00797     
00798  * @param new_controller new controller value
00799  */
00800 void
00801 MotorInterface::AcquireControlMessage::set_controller(const unsigned int new_controller)
00802 {
00803   data->controller = new_controller;
00804 }
00805 
00806 /** Get controller_thread_name value.
00807  * 
00808      The name of the controlling thread, for easier debugging. This is informative only
00809      and actually two threads may share an interface instance (although this should be
00810      avoided since the interface locking has to be reproduced for these threads then).
00811   
00812  * @return controller_thread_name value
00813  */
00814 char *
00815 MotorInterface::AcquireControlMessage::controller_thread_name() const
00816 {
00817   return data->controller_thread_name;
00818 }
00819 
00820 /** Get maximum length of controller_thread_name value.
00821  * @return length of controller_thread_name value, can be length of the array or number of 
00822  * maximum number of characters for a string
00823  */
00824 size_t
00825 MotorInterface::AcquireControlMessage::maxlenof_controller_thread_name() const
00826 {
00827   return 64;
00828 }
00829 
00830 /** Set controller_thread_name value.
00831  * 
00832      The name of the controlling thread, for easier debugging. This is informative only
00833      and actually two threads may share an interface instance (although this should be
00834      avoided since the interface locking has to be reproduced for these threads then).
00835   
00836  * @param new_controller_thread_name new controller_thread_name value
00837  */
00838 void
00839 MotorInterface::AcquireControlMessage::set_controller_thread_name(const char * new_controller_thread_name)
00840 {
00841   strncpy(data->controller_thread_name, new_controller_thread_name, sizeof(data->controller_thread_name));
00842 }
00843 
00844 /** Clone this message.
00845  * Produces a message of the same type as this message and copies the
00846  * data to the new message.
00847  * @return clone of this message
00848  */
00849 Message *
00850 MotorInterface::AcquireControlMessage::clone() const
00851 {
00852   return new MotorInterface::AcquireControlMessage(this);
00853 }
00854 /** @class MotorInterface::ResetOdometryMessage <interfaces/MotorInterface.h>
00855  * ResetOdometryMessage Fawkes BlackBoard Interface Message.
00856  * 
00857     
00858  */
00859
00860 
00861 /** Constructor */
00862 MotorInterface::ResetOdometryMessage::ResetOdometryMessage() : Message("ResetOdometryMessage")
00863 {
00864   data_size = 0;
00865   data_ptr  = NULL;
00866 }
00867 
00868 /** Destructor */
00869 MotorInterface::ResetOdometryMessage::~ResetOdometryMessage()
00870 {
00871 }
00872 
00873 /** Copy constructor.
00874  * @param m message to copy from
00875  */
00876 MotorInterface::ResetOdometryMessage::ResetOdometryMessage(const ResetOdometryMessage *m) : Message("ResetOdometryMessage")
00877 {
00878   data_size = 0;
00879   data_ptr  = NULL;
00880 }
00881
00882 /* Methods */
00883 /** Clone this message.
00884  * Produces a message of the same type as this message and copies the
00885  * data to the new message.
00886  * @return clone of this message
00887  */
00888 Message *
00889 MotorInterface::ResetOdometryMessage::clone() const
00890 {
00891   return new MotorInterface::ResetOdometryMessage(this);
00892 }
00893 /** @class MotorInterface::DriveRPMMessage <interfaces/MotorInterface.h>
00894  * DriveRPMMessage Fawkes BlackBoard Interface Message.
00895  * 
00896     
00897  */
00898
00899 
00900 /** Constructor with initial values.
00901  * @param ini_front_right initial value for front_right
00902  * @param ini_front_left initial value for front_left
00903  * @param ini_rear initial value for rear
00904  */
00905 MotorInterface::DriveRPMMessage::DriveRPMMessage(const float ini_front_right, const float ini_front_left, const float ini_rear) : Message("DriveRPMMessage")
00906 {
00907   data_size = sizeof(DriveRPMMessage_data_t);
00908   data_ptr  = malloc(data_size);
00909   memset(data_ptr, 0, data_size);
00910   data      = (DriveRPMMessage_data_t *)data_ptr;
00911   data->front_right = ini_front_right;
00912   data->front_left = ini_front_left;
00913   data->rear = ini_rear;
00914   add_fieldinfo(IFT_FLOAT, "front_right", 1, &data->front_right);
00915   add_fieldinfo(IFT_FLOAT, "front_left", 1, &data->front_left);
00916   add_fieldinfo(IFT_FLOAT, "rear", 1, &data->rear);
00917 }
00918 /** Constructor */
00919 MotorInterface::DriveRPMMessage::DriveRPMMessage() : Message("DriveRPMMessage")
00920 {
00921   data_size = sizeof(DriveRPMMessage_data_t);
00922   data_ptr  = malloc(data_size);
00923   memset(data_ptr, 0, data_size);
00924   data      = (DriveRPMMessage_data_t *)data_ptr;
00925   add_fieldinfo(IFT_FLOAT, "front_right", 1, &data->front_right);
00926   add_fieldinfo(IFT_FLOAT, "front_left", 1, &data->front_left);
00927   add_fieldinfo(IFT_FLOAT, "rear", 1, &data->rear);
00928 }
00929 
00930 /** Destructor */
00931 MotorInterface::DriveRPMMessage::~DriveRPMMessage()
00932 {
00933   free(data_ptr);
00934 }
00935 
00936 /** Copy constructor.
00937  * @param m message to copy from
00938  */
00939 MotorInterface::DriveRPMMessage::DriveRPMMessage(const DriveRPMMessage *m) : Message("DriveRPMMessage")
00940 {
00941   data_size = m->data_size;
00942   data_ptr  = malloc(data_size);
00943   memcpy(data_ptr, m->data_ptr, data_size);
00944   data      = (DriveRPMMessage_data_t *)data_ptr;
00945 }
00946
00947 /* Methods */
00948 /** Get front_right value.
00949  * Rotation in RPM of the right front wheel.
00950  * @return front_right value
00951  */
00952 float
00953 MotorInterface::DriveRPMMessage::front_right() const
00954 {
00955   return data->front_right;
00956 }
00957 
00958 /** Get maximum length of front_right value.
00959  * @return length of front_right value, can be length of the array or number of 
00960  * maximum number of characters for a string
00961  */
00962 size_t
00963 MotorInterface::DriveRPMMessage::maxlenof_front_right() const
00964 {
00965   return 1;
00966 }
00967 
00968 /** Set front_right value.
00969  * Rotation in RPM of the right front wheel.
00970  * @param new_front_right new front_right value
00971  */
00972 void
00973 MotorInterface::DriveRPMMessage::set_front_right(const float new_front_right)
00974 {
00975   data->front_right = new_front_right;
00976 }
00977 
00978 /** Get front_left value.
00979  * Rotation in RPM of the left front wheel.
00980  * @return front_left value
00981  */
00982 float
00983 MotorInterface::DriveRPMMessage::front_left() const
00984 {
00985   return data->front_left;
00986 }
00987 
00988 /** Get maximum length of front_left value.
00989  * @return length of front_left value, can be length of the array or number of 
00990  * maximum number of characters for a string
00991  */
00992 size_t
00993 MotorInterface::DriveRPMMessage::maxlenof_front_left() const
00994 {
00995   return 1;
00996 }
00997 
00998 /** Set front_left value.
00999  * Rotation in RPM of the left front wheel.
01000  * @param new_front_left new front_left value
01001  */
01002 void
01003 MotorInterface::DriveRPMMessage::set_front_left(const float new_front_left)
01004 {
01005   data->front_left = new_front_left;
01006 }
01007 
01008 /** Get rear value.
01009  * Rotation in RPM of the rear wheel.
01010  * @return rear value
01011  */
01012 float
01013 MotorInterface::DriveRPMMessage::rear() const
01014 {
01015   return data->rear;
01016 }
01017 
01018 /** Get maximum length of rear value.
01019  * @return length of rear value, can be length of the array or number of 
01020  * maximum number of characters for a string
01021  */
01022 size_t
01023 MotorInterface::DriveRPMMessage::maxlenof_rear() const
01024 {
01025   return 1;
01026 }
01027 
01028 /** Set rear value.
01029  * Rotation in RPM of the rear wheel.
01030  * @param new_rear new rear value
01031  */
01032 void
01033 MotorInterface::DriveRPMMessage::set_rear(const float new_rear)
01034 {
01035   data->rear = new_rear;
01036 }
01037 
01038 /** Clone this message.
01039  * Produces a message of the same type as this message and copies the
01040  * data to the new message.
01041  * @return clone of this message
01042  */
01043 Message *
01044 MotorInterface::DriveRPMMessage::clone() const
01045 {
01046   return new MotorInterface::DriveRPMMessage(this);
01047 }
01048 /** @class MotorInterface::GotoMessage <interfaces/MotorInterface.h>
01049  * GotoMessage Fawkes BlackBoard Interface Message.
01050  * 
01051     
01052  */
01053
01054 
01055 /** Constructor with initial values.
01056  * @param ini_x initial value for x
01057  * @param ini_y initial value for y
01058  * @param ini_phi initial value for phi
01059  * @param ini_time_sec initial value for time_sec
01060  */
01061 MotorInterface::GotoMessage::GotoMessage(const float ini_x, const float ini_y, const float ini_phi, const float ini_time_sec) : Message("GotoMessage")
01062 {
01063   data_size = sizeof(GotoMessage_data_t);
01064   data_ptr  = malloc(data_size);
01065   memset(data_ptr, 0, data_size);
01066   data      = (GotoMessage_data_t *)data_ptr;
01067   data->x = ini_x;
01068   data->y = ini_y;
01069   data->phi = ini_phi;
01070   data->time_sec = ini_time_sec;
01071   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
01072   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
01073   add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
01074   add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec);
01075 }
01076 /** Constructor */
01077 MotorInterface::GotoMessage::GotoMessage() : Message("GotoMessage")
01078 {
01079   data_size = sizeof(GotoMessage_data_t);
01080   data_ptr  = malloc(data_size);
01081   memset(data_ptr, 0, data_size);
01082   data      = (GotoMessage_data_t *)data_ptr;
01083   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
01084   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
01085   add_fieldinfo(IFT_FLOAT, "phi", 1, &data->phi);
01086   add_fieldinfo(IFT_FLOAT, "time_sec", 1, &data->time_sec);
01087 }
01088 
01089 /** Destructor */
01090 MotorInterface::GotoMessage::~GotoMessage()
01091 {
01092   free(data_ptr);
01093 }
01094 
01095 /** Copy constructor.
01096  * @param m message to copy from
01097  */
01098 MotorInterface::GotoMessage::GotoMessage(const GotoMessage *m) : Message("GotoMessage")
01099 {
01100   data_size = m->data_size;
01101   data_ptr  = malloc(data_size);
01102   memcpy(data_ptr, m->data_ptr, data_size);
01103   data      = (GotoMessage_data_t *)data_ptr;
01104 }
01105
01106 /* Methods */
01107 /** Get x value.
01108  * X distance in m.
01109  * @return x value
01110  */
01111 float
01112 MotorInterface::GotoMessage::x() const
01113 {
01114   return data->x;
01115 }
01116 
01117 /** Get maximum length of x value.
01118  * @return length of x value, can be length of the array or number of 
01119  * maximum number of characters for a string
01120  */
01121 size_t
01122 MotorInterface::GotoMessage::maxlenof_x() const
01123 {
01124   return 1;
01125 }
01126 
01127 /** Set x value.
01128  * X distance in m.
01129  * @param new_x new x value
01130  */
01131 void
01132 MotorInterface::GotoMessage::set_x(const float new_x)
01133 {
01134   data->x = new_x;
01135 }
01136 
01137 /** Get y value.
01138  * Y distance in m.
01139  * @return y value
01140  */
01141 float
01142 MotorInterface::GotoMessage::y() const
01143 {
01144   return data->y;
01145 }
01146 
01147 /** Get maximum length of y value.
01148  * @return length of y value, can be length of the array or number of 
01149  * maximum number of characters for a string
01150  */
01151 size_t
01152 MotorInterface::GotoMessage::maxlenof_y() const
01153 {
01154   return 1;
01155 }
01156 
01157 /** Set y value.
01158  * Y distance in m.
01159  * @param new_y new y value
01160  */
01161 void
01162 MotorInterface::GotoMessage::set_y(const float new_y)
01163 {
01164   data->y = new_y;
01165 }
01166 
01167 /** Get phi value.
01168  * Angle relative to current angle in rad.
01169  * @return phi value
01170  */
01171 float
01172 MotorInterface::GotoMessage::phi() const
01173 {
01174   return data->phi;
01175 }
01176 
01177 /** Get maximum length of phi value.
01178  * @return length of phi value, can be length of the array or number of 
01179  * maximum number of characters for a string
01180  */
01181 size_t
01182 MotorInterface::GotoMessage::maxlenof_phi() const
01183 {
01184   return 1;
01185 }
01186 
01187 /** Set phi value.
01188  * Angle relative to current angle in rad.
01189  * @param new_phi new phi value
01190  */
01191 void
01192 MotorInterface::GotoMessage::set_phi(const float new_phi)
01193 {
01194   data->phi = new_phi;
01195 }
01196 
01197 /** Get time_sec value.
01198  * When to reach the desired location.
01199  * @return time_sec value
01200  */
01201 float
01202 MotorInterface::GotoMessage::time_sec() const
01203 {
01204   return data->time_sec;
01205 }
01206 
01207 /** Get maximum length of time_sec value.
01208  * @return length of time_sec value, can be length of the array or number of 
01209  * maximum number of characters for a string
01210  */
01211 size_t
01212 MotorInterface::GotoMessage::maxlenof_time_sec() const
01213 {
01214   return 1;
01215 }
01216 
01217 /** Set time_sec value.
01218  * When to reach the desired location.
01219  * @param new_time_sec new time_sec value
01220  */
01221 void
01222 MotorInterface::GotoMessage::set_time_sec(const float new_time_sec)
01223 {
01224   data->time_sec = new_time_sec;
01225 }
01226 
01227 /** Clone this message.
01228  * Produces a message of the same type as this message and copies the
01229  * data to the new message.
01230  * @return clone of this message
01231  */
01232 Message *
01233 MotorInterface::GotoMessage::clone() const
01234 {
01235   return new MotorInterface::GotoMessage(this);
01236 }
01237 /** @class MotorInterface::TransMessage <interfaces/MotorInterface.h>
01238  * TransMessage Fawkes BlackBoard Interface Message.
01239  * 
01240     
01241  */
01242
01243 
01244 /** Constructor with initial values.
01245  * @param ini_vx initial value for vx
01246  * @param ini_vy initial value for vy
01247  */
01248 MotorInterface::TransMessage::TransMessage(const float ini_vx, const float ini_vy) : Message("TransMessage")
01249 {
01250   data_size = sizeof(TransMessage_data_t);
01251   data_ptr  = malloc(data_size);
01252   memset(data_ptr, 0, data_size);
01253   data      = (TransMessage_data_t *)data_ptr;
01254   data->vx = ini_vx;
01255   data->vy = ini_vy;
01256   add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01257   add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01258 }
01259 /** Constructor */
01260 MotorInterface::TransMessage::TransMessage() : Message("TransMessage")
01261 {
01262   data_size = sizeof(TransMessage_data_t);
01263   data_ptr  = malloc(data_size);
01264   memset(data_ptr, 0, data_size);
01265   data      = (TransMessage_data_t *)data_ptr;
01266   add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01267   add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01268 }
01269 
01270 /** Destructor */
01271 MotorInterface::TransMessage::~TransMessage()
01272 {
01273   free(data_ptr);
01274 }
01275 
01276 /** Copy constructor.
01277  * @param m message to copy from
01278  */
01279 MotorInterface::TransMessage::TransMessage(const TransMessage *m) : Message("TransMessage")
01280 {
01281   data_size = m->data_size;
01282   data_ptr  = malloc(data_size);
01283   memcpy(data_ptr, m->data_ptr, data_size);
01284   data      = (TransMessage_data_t *)data_ptr;
01285 }
01286
01287 /* Methods */
01288 /** Get vx value.
01289  * Speed in X direction in m/s.
01290  * @return vx value
01291  */
01292 float
01293 MotorInterface::TransMessage::vx() const
01294 {
01295   return data->vx;
01296 }
01297 
01298 /** Get maximum length of vx value.
01299  * @return length of vx value, can be length of the array or number of 
01300  * maximum number of characters for a string
01301  */
01302 size_t
01303 MotorInterface::TransMessage::maxlenof_vx() const
01304 {
01305   return 1;
01306 }
01307 
01308 /** Set vx value.
01309  * Speed in X direction in m/s.
01310  * @param new_vx new vx value
01311  */
01312 void
01313 MotorInterface::TransMessage::set_vx(const float new_vx)
01314 {
01315   data->vx = new_vx;
01316 }
01317 
01318 /** Get vy value.
01319  * Speed in Y direction in m/s.
01320  * @return vy value
01321  */
01322 float
01323 MotorInterface::TransMessage::vy() const
01324 {
01325   return data->vy;
01326 }
01327 
01328 /** Get maximum length of vy value.
01329  * @return length of vy value, can be length of the array or number of 
01330  * maximum number of characters for a string
01331  */
01332 size_t
01333 MotorInterface::TransMessage::maxlenof_vy() const
01334 {
01335   return 1;
01336 }
01337 
01338 /** Set vy value.
01339  * Speed in Y direction in m/s.
01340  * @param new_vy new vy value
01341  */
01342 void
01343 MotorInterface::TransMessage::set_vy(const float new_vy)
01344 {
01345   data->vy = new_vy;
01346 }
01347 
01348 /** Clone this message.
01349  * Produces a message of the same type as this message and copies the
01350  * data to the new message.
01351  * @return clone of this message
01352  */
01353 Message *
01354 MotorInterface::TransMessage::clone() const
01355 {
01356   return new MotorInterface::TransMessage(this);
01357 }
01358 /** @class MotorInterface::RotMessage <interfaces/MotorInterface.h>
01359  * RotMessage Fawkes BlackBoard Interface Message.
01360  * 
01361     
01362  */
01363
01364 
01365 /** Constructor with initial values.
01366  * @param ini_omega initial value for omega
01367  */
01368 MotorInterface::RotMessage::RotMessage(const float ini_omega) : Message("RotMessage")
01369 {
01370   data_size = sizeof(RotMessage_data_t);
01371   data_ptr  = malloc(data_size);
01372   memset(data_ptr, 0, data_size);
01373   data      = (RotMessage_data_t *)data_ptr;
01374   data->omega = ini_omega;
01375   add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01376 }
01377 /** Constructor */
01378 MotorInterface::RotMessage::RotMessage() : Message("RotMessage")
01379 {
01380   data_size = sizeof(RotMessage_data_t);
01381   data_ptr  = malloc(data_size);
01382   memset(data_ptr, 0, data_size);
01383   data      = (RotMessage_data_t *)data_ptr;
01384   add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01385 }
01386 
01387 /** Destructor */
01388 MotorInterface::RotMessage::~RotMessage()
01389 {
01390   free(data_ptr);
01391 }
01392 
01393 /** Copy constructor.
01394  * @param m message to copy from
01395  */
01396 MotorInterface::RotMessage::RotMessage(const RotMessage *m) : Message("RotMessage")
01397 {
01398   data_size = m->data_size;
01399   data_ptr  = malloc(data_size);
01400   memcpy(data_ptr, m->data_ptr, data_size);
01401   data      = (RotMessage_data_t *)data_ptr;
01402 }
01403
01404 /* Methods */
01405 /** Get omega value.
01406  * Angle rotation in rad/s.
01407  * @return omega value
01408  */
01409 float
01410 MotorInterface::RotMessage::omega() const
01411 {
01412   return data->omega;
01413 }
01414 
01415 /** Get maximum length of omega value.
01416  * @return length of omega value, can be length of the array or number of 
01417  * maximum number of characters for a string
01418  */
01419 size_t
01420 MotorInterface::RotMessage::maxlenof_omega() const
01421 {
01422   return 1;
01423 }
01424 
01425 /** Set omega value.
01426  * Angle rotation in rad/s.
01427  * @param new_omega new omega value
01428  */
01429 void
01430 MotorInterface::RotMessage::set_omega(const float new_omega)
01431 {
01432   data->omega = new_omega;
01433 }
01434 
01435 /** Clone this message.
01436  * Produces a message of the same type as this message and copies the
01437  * data to the new message.
01438  * @return clone of this message
01439  */
01440 Message *
01441 MotorInterface::RotMessage::clone() const
01442 {
01443   return new MotorInterface::RotMessage(this);
01444 }
01445 /** @class MotorInterface::TransRotMessage <interfaces/MotorInterface.h>
01446  * TransRotMessage Fawkes BlackBoard Interface Message.
01447  * 
01448     
01449  */
01450
01451 
01452 /** Constructor with initial values.
01453  * @param ini_vx initial value for vx
01454  * @param ini_vy initial value for vy
01455  * @param ini_omega initial value for omega
01456  */
01457 MotorInterface::TransRotMessage::TransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega) : Message("TransRotMessage")
01458 {
01459   data_size = sizeof(TransRotMessage_data_t);
01460   data_ptr  = malloc(data_size);
01461   memset(data_ptr, 0, data_size);
01462   data      = (TransRotMessage_data_t *)data_ptr;
01463   data->vx = ini_vx;
01464   data->vy = ini_vy;
01465   data->omega = ini_omega;
01466   add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01467   add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01468   add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01469 }
01470 /** Constructor */
01471 MotorInterface::TransRotMessage::TransRotMessage() : Message("TransRotMessage")
01472 {
01473   data_size = sizeof(TransRotMessage_data_t);
01474   data_ptr  = malloc(data_size);
01475   memset(data_ptr, 0, data_size);
01476   data      = (TransRotMessage_data_t *)data_ptr;
01477   add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01478   add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01479   add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01480 }
01481 
01482 /** Destructor */
01483 MotorInterface::TransRotMessage::~TransRotMessage()
01484 {
01485   free(data_ptr);
01486 }
01487 
01488 /** Copy constructor.
01489  * @param m message to copy from
01490  */
01491 MotorInterface::TransRotMessage::TransRotMessage(const TransRotMessage *m) : Message("TransRotMessage")
01492 {
01493   data_size = m->data_size;
01494   data_ptr  = malloc(data_size);
01495   memcpy(data_ptr, m->data_ptr, data_size);
01496   data      = (TransRotMessage_data_t *)data_ptr;
01497 }
01498
01499 /* Methods */
01500 /** Get vx value.
01501  * Speed in X direction in m/s.
01502  * @return vx value
01503  */
01504 float
01505 MotorInterface::TransRotMessage::vx() const
01506 {
01507   return data->vx;
01508 }
01509 
01510 /** Get maximum length of vx value.
01511  * @return length of vx value, can be length of the array or number of 
01512  * maximum number of characters for a string
01513  */
01514 size_t
01515 MotorInterface::TransRotMessage::maxlenof_vx() const
01516 {
01517   return 1;
01518 }
01519 
01520 /** Set vx value.
01521  * Speed in X direction in m/s.
01522  * @param new_vx new vx value
01523  */
01524 void
01525 MotorInterface::TransRotMessage::set_vx(const float new_vx)
01526 {
01527   data->vx = new_vx;
01528 }
01529 
01530 /** Get vy value.
01531  * Speed in Y direction in m/s.
01532  * @return vy value
01533  */
01534 float
01535 MotorInterface::TransRotMessage::vy() const
01536 {
01537   return data->vy;
01538 }
01539 
01540 /** Get maximum length of vy value.
01541  * @return length of vy value, can be length of the array or number of 
01542  * maximum number of characters for a string
01543  */
01544 size_t
01545 MotorInterface::TransRotMessage::maxlenof_vy() const
01546 {
01547   return 1;
01548 }
01549 
01550 /** Set vy value.
01551  * Speed in Y direction in m/s.
01552  * @param new_vy new vy value
01553  */
01554 void
01555 MotorInterface::TransRotMessage::set_vy(const float new_vy)
01556 {
01557   data->vy = new_vy;
01558 }
01559 
01560 /** Get omega value.
01561  * Angle rotation in rad/s.
01562  * @return omega value
01563  */
01564 float
01565 MotorInterface::TransRotMessage::omega() const
01566 {
01567   return data->omega;
01568 }
01569 
01570 /** Get maximum length of omega value.
01571  * @return length of omega value, can be length of the array or number of 
01572  * maximum number of characters for a string
01573  */
01574 size_t
01575 MotorInterface::TransRotMessage::maxlenof_omega() const
01576 {
01577   return 1;
01578 }
01579 
01580 /** Set omega value.
01581  * Angle rotation in rad/s.
01582  * @param new_omega new omega value
01583  */
01584 void
01585 MotorInterface::TransRotMessage::set_omega(const float new_omega)
01586 {
01587   data->omega = new_omega;
01588 }
01589 
01590 /** Clone this message.
01591  * Produces a message of the same type as this message and copies the
01592  * data to the new message.
01593  * @return clone of this message
01594  */
01595 Message *
01596 MotorInterface::TransRotMessage::clone() const
01597 {
01598   return new MotorInterface::TransRotMessage(this);
01599 }
01600 /** @class MotorInterface::OrbitMessage <interfaces/MotorInterface.h>
01601  * OrbitMessage Fawkes BlackBoard Interface Message.
01602  * 
01603     
01604  */
01605
01606 
01607 /** Constructor with initial values.
01608  * @param ini_px initial value for px
01609  * @param ini_py initial value for py
01610  * @param ini_omega initial value for omega
01611  */
01612 MotorInterface::OrbitMessage::OrbitMessage(const float ini_px, const float ini_py, const float ini_omega) : Message("OrbitMessage")
01613 {
01614   data_size = sizeof(OrbitMessage_data_t);
01615   data_ptr  = malloc(data_size);
01616   memset(data_ptr, 0, data_size);
01617   data      = (OrbitMessage_data_t *)data_ptr;
01618   data->px = ini_px;
01619   data->py = ini_py;
01620   data->omega = ini_omega;
01621   add_fieldinfo(IFT_FLOAT, "px", 1, &data->px);
01622   add_fieldinfo(IFT_FLOAT, "py", 1, &data->py);
01623   add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01624 }
01625 /** Constructor */
01626 MotorInterface::OrbitMessage::OrbitMessage() : Message("OrbitMessage")
01627 {
01628   data_size = sizeof(OrbitMessage_data_t);
01629   data_ptr  = malloc(data_size);
01630   memset(data_ptr, 0, data_size);
01631   data      = (OrbitMessage_data_t *)data_ptr;
01632   add_fieldinfo(IFT_FLOAT, "px", 1, &data->px);
01633   add_fieldinfo(IFT_FLOAT, "py", 1, &data->py);
01634   add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01635 }
01636 
01637 /** Destructor */
01638 MotorInterface::OrbitMessage::~OrbitMessage()
01639 {
01640   free(data_ptr);
01641 }
01642 
01643 /** Copy constructor.
01644  * @param m message to copy from
01645  */
01646 MotorInterface::OrbitMessage::OrbitMessage(const OrbitMessage *m) : Message("OrbitMessage")
01647 {
01648   data_size = m->data_size;
01649   data_ptr  = malloc(data_size);
01650   memcpy(data_ptr, m->data_ptr, data_size);
01651   data      = (OrbitMessage_data_t *)data_ptr;
01652 }
01653
01654 /* Methods */
01655 /** Get px value.
01656  * Point's X coordinate to orbit.
01657  * @return px value
01658  */
01659 float
01660 MotorInterface::OrbitMessage::px() const
01661 {
01662   return data->px;
01663 }
01664 
01665 /** Get maximum length of px value.
01666  * @return length of px value, can be length of the array or number of 
01667  * maximum number of characters for a string
01668  */
01669 size_t
01670 MotorInterface::OrbitMessage::maxlenof_px() const
01671 {
01672   return 1;
01673 }
01674 
01675 /** Set px value.
01676  * Point's X coordinate to orbit.
01677  * @param new_px new px value
01678  */
01679 void
01680 MotorInterface::OrbitMessage::set_px(const float new_px)
01681 {
01682   data->px = new_px;
01683 }
01684 
01685 /** Get py value.
01686  * Point's Y coordinate to orbit.
01687  * @return py value
01688  */
01689 float
01690 MotorInterface::OrbitMessage::py() const
01691 {
01692   return data->py;
01693 }
01694 
01695 /** Get maximum length of py value.
01696  * @return length of py value, can be length of the array or number of 
01697  * maximum number of characters for a string
01698  */
01699 size_t
01700 MotorInterface::OrbitMessage::maxlenof_py() const
01701 {
01702   return 1;
01703 }
01704 
01705 /** Set py value.
01706  * Point's Y coordinate to orbit.
01707  * @param new_py new py value
01708  */
01709 void
01710 MotorInterface::OrbitMessage::set_py(const float new_py)
01711 {
01712   data->py = new_py;
01713 }
01714 
01715 /** Get omega value.
01716  * Angular speed around point in rad/s.
01717  * @return omega value
01718  */
01719 float
01720 MotorInterface::OrbitMessage::omega() const
01721 {
01722   return data->omega;
01723 }
01724 
01725 /** Get maximum length of omega value.
01726  * @return length of omega value, can be length of the array or number of 
01727  * maximum number of characters for a string
01728  */
01729 size_t
01730 MotorInterface::OrbitMessage::maxlenof_omega() const
01731 {
01732   return 1;
01733 }
01734 
01735 /** Set omega value.
01736  * Angular speed around point in rad/s.
01737  * @param new_omega new omega value
01738  */
01739 void
01740 MotorInterface::OrbitMessage::set_omega(const float new_omega)
01741 {
01742   data->omega = new_omega;
01743 }
01744 
01745 /** Clone this message.
01746  * Produces a message of the same type as this message and copies the
01747  * data to the new message.
01748  * @return clone of this message
01749  */
01750 Message *
01751 MotorInterface::OrbitMessage::clone() const
01752 {
01753   return new MotorInterface::OrbitMessage(this);
01754 }
01755 /** @class MotorInterface::LinTransRotMessage <interfaces/MotorInterface.h>
01756  * LinTransRotMessage Fawkes BlackBoard Interface Message.
01757  * 
01758     
01759  */
01760
01761 
01762 /** Constructor with initial values.
01763  * @param ini_vx initial value for vx
01764  * @param ini_vy initial value for vy
01765  * @param ini_omega initial value for omega
01766  */
01767 MotorInterface::LinTransRotMessage::LinTransRotMessage(const float ini_vx, const float ini_vy, const float ini_omega) : Message("LinTransRotMessage")
01768 {
01769   data_size = sizeof(LinTransRotMessage_data_t);
01770   data_ptr  = malloc(data_size);
01771   memset(data_ptr, 0, data_size);
01772   data      = (LinTransRotMessage_data_t *)data_ptr;
01773   data->vx = ini_vx;
01774   data->vy = ini_vy;
01775   data->omega = ini_omega;
01776   add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01777   add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01778   add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01779 }
01780 /** Constructor */
01781 MotorInterface::LinTransRotMessage::LinTransRotMessage() : Message("LinTransRotMessage")
01782 {
01783   data_size = sizeof(LinTransRotMessage_data_t);
01784   data_ptr  = malloc(data_size);
01785   memset(data_ptr, 0, data_size);
01786   data      = (LinTransRotMessage_data_t *)data_ptr;
01787   add_fieldinfo(IFT_FLOAT, "vx", 1, &data->vx);
01788   add_fieldinfo(IFT_FLOAT, "vy", 1, &data->vy);
01789   add_fieldinfo(IFT_FLOAT, "omega", 1, &data->omega);
01790 }
01791 
01792 /** Destructor */
01793 MotorInterface::LinTransRotMessage::~LinTransRotMessage()
01794 {
01795   free(data_ptr);
01796 }
01797 
01798 /** Copy constructor.
01799  * @param m message to copy from
01800  */
01801 MotorInterface::LinTransRotMessage::LinTransRotMessage(const LinTransRotMessage *m) : Message("LinTransRotMessage")
01802 {
01803   data_size = m->data_size;
01804   data_ptr  = malloc(data_size);
01805   memcpy(data_ptr, m->data_ptr, data_size);
01806   data      = (LinTransRotMessage_data_t *)data_ptr;
01807 }
01808
01809 /* Methods */
01810 /** Get vx value.
01811  * Speed for translation in X direction in m/s.
01812  * @return vx value
01813  */
01814 float
01815 MotorInterface::LinTransRotMessage::vx() const
01816 {
01817   return data->vx;
01818 }
01819 
01820 /** Get maximum length of vx value.
01821  * @return length of vx value, can be length of the array or number of 
01822  * maximum number of characters for a string
01823  */
01824 size_t
01825 MotorInterface::LinTransRotMessage::maxlenof_vx() const
01826 {
01827   return 1;
01828 }
01829 
01830 /** Set vx value.
01831  * Speed for translation in X direction in m/s.
01832  * @param new_vx new vx value
01833  */
01834 void
01835 MotorInterface::LinTransRotMessage::set_vx(const float new_vx)
01836 {
01837   data->vx = new_vx;
01838 }
01839 
01840 /** Get vy value.
01841  * Speed for translation in Y direction in m/s.
01842  * @return vy value
01843  */
01844 float
01845 MotorInterface::LinTransRotMessage::vy() const
01846 {
01847   return data->vy;
01848 }
01849 
01850 /** Get maximum length of vy value.
01851  * @return length of vy value, can be length of the array or number of 
01852  * maximum number of characters for a string
01853  */
01854 size_t
01855 MotorInterface::LinTransRotMessage::maxlenof_vy() const
01856 {
01857   return 1;
01858 }
01859 
01860 /** Set vy value.
01861  * Speed for translation in Y direction in m/s.
01862  * @param new_vy new vy value
01863  */
01864 void
01865 MotorInterface::LinTransRotMessage::set_vy(const float new_vy)
01866 {
01867   data->vy = new_vy;
01868 }
01869 
01870 /** Get omega value.
01871  * Rotational speed in rad/s.
01872  * @return omega value
01873  */
01874 float
01875 MotorInterface::LinTransRotMessage::omega() const
01876 {
01877   return data->omega;
01878 }
01879 
01880 /** Get maximum length of omega value.
01881  * @return length of omega value, can be length of the array or number of 
01882  * maximum number of characters for a string
01883  */
01884 size_t
01885 MotorInterface::LinTransRotMessage::maxlenof_omega() const
01886 {
01887   return 1;
01888 }
01889 
01890 /** Set omega value.
01891  * Rotational speed in rad/s.
01892  * @param new_omega new omega value
01893  */
01894 void
01895 MotorInterface::LinTransRotMessage::set_omega(const float new_omega)
01896 {
01897   data->omega = new_omega;
01898 }
01899 
01900 /** Clone this message.
01901  * Produces a message of the same type as this message and copies the
01902  * data to the new message.
01903  * @return clone of this message
01904  */
01905 Message *
01906 MotorInterface::LinTransRotMessage::clone() const
01907 {
01908   return new MotorInterface::LinTransRotMessage(this);
01909 }
01910 /** Check if message is valid and can be enqueued.
01911  * @param message Message to check
01912  */
01913 bool
01914 MotorInterface::message_valid(const Message *message) const
01915 {
01916   const SetMotorStateMessage *m0 = dynamic_cast<const SetMotorStateMessage *>(message);
01917   if ( m0 != NULL ) {
01918     return true;
01919   }
01920   const AcquireControlMessage *m1 = dynamic_cast<const AcquireControlMessage *>(message);
01921   if ( m1 != NULL ) {
01922     return true;
01923   }
01924   const ResetOdometryMessage *m2 = dynamic_cast<const ResetOdometryMessage *>(message);
01925   if ( m2 != NULL ) {
01926     return true;
01927   }
01928   const DriveRPMMessage *m3 = dynamic_cast<const DriveRPMMessage *>(message);
01929   if ( m3 != NULL ) {
01930     return true;
01931   }
01932   const GotoMessage *m4 = dynamic_cast<const GotoMessage *>(message);
01933   if ( m4 != NULL ) {
01934     return true;
01935   }
01936   const TransMessage *m5 = dynamic_cast<const TransMessage *>(message);
01937   if ( m5 != NULL ) {
01938     return true;
01939   }
01940   const RotMessage *m6 = dynamic_cast<const RotMessage *>(message);
01941   if ( m6 != NULL ) {
01942     return true;
01943   }
01944   const TransRotMessage *m7 = dynamic_cast<const TransRotMessage *>(message);
01945   if ( m7 != NULL ) {
01946     return true;
01947   }
01948   const OrbitMessage *m8 = dynamic_cast<const OrbitMessage *>(message);
01949   if ( m8 != NULL ) {
01950     return true;
01951   }
01952   const LinTransRotMessage *m9 = dynamic_cast<const LinTransRotMessage *>(message);
01953   if ( m9 != NULL ) {
01954     return true;
01955   }
01956   return false;
01957 }
01958 
01959 /// @cond INTERNALS
01960 EXPORT_INTERFACE(MotorInterface)
01961 /// @endcond
01962 
01963
01964 } // end namespace fawkes