motorpacket.h

00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2000  
00004  *     Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
00005  *  
00006  *  
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00023 /*
00024  * $Id: motorpacket.h 4308 2007-12-13 20:23:08Z gerkey $
00025  *
00026  * part of the P2OS parser.  methods for filling and parsing server
00027  * information packets (ErraticMotorPackets)
00028  */
00029 #ifndef _ErraticMotorPacket_H
00030 #define _ErraticMotorPacket_H
00031 
00032 #include <limits.h>
00033 
00034 #include "erratic.h"
00035 
00036 
00037 class ErraticMotorPacket 
00038 {
00039  private:
00040   int PositionChange( unsigned short, unsigned short );
00041   int param_idx; // index of our robot's data in the parameter table
00042 
00043  public:
00044   // these values are returned in every standard ErraticMotorPacket
00045   bool lwstall, rwstall;
00046   unsigned char status, battery;
00047   unsigned short ptu, timer, rawxpos; 
00048   unsigned short rawypos;
00049   short angle, lvel, rvel, control;
00050   int xpos, ypos;
00051   int x_offset,y_offset,angle_offset;
00052 
00053   bool Parse( unsigned char *buffer, int length );
00054   void Print();
00055   void Fill(player_erratic_data_t* data);
00056 
00057   ErraticMotorPacket(int idx) 
00058   {
00059     param_idx = idx;
00060 
00061     xpos = INT_MAX;
00062     ypos = INT_MAX;
00063   }
00064 };
00065 
00066 #endif

Last updated 12 September 2005 21:38:45