sip.h
Go to the documentation of this file.
00001 /*
00002  *  P2OS for ROS
00003  *  Copyright (C) 2009
00004  *     David Feil-Seifer, Brian Gerkey, Kasper Stoy, 
00005  *      Richard Vaughan, & Andrew Howard
00006  *
00007  *
00008  *  This program is free software; you can redistribute it and/or modify
00009  *  it under the terms of the GNU General Public License as published by
00010  *  the Free Software Foundation; either version 2 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  This program is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *  GNU General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU General Public License
00019  *  along with this program; if not, write to the Free Software
00020  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00024 #ifndef _SIP_H
00025 #define _SIP_H
00026 
00027 #include <limits.h>
00028 #include <stdint.h>
00029 #include <p2os_driver/p2os.h>
00030 
00031 typedef struct ArmJoint
00032 {
00033         char speed;
00034         unsigned char home;
00035         unsigned char min;
00036         unsigned char centre;
00037         unsigned char max;
00038         unsigned char ticksPer90;
00039 } ArmJoint;
00040 
00041 enum PlayerGripperStates {
00042     PLAYER_GRIPPER_STATE_OPEN = 1,
00043     PLAYER_GRIPPER_STATE_CLOSED,
00044     PLAYER_GRIPPER_STATE_MOVING,
00045     PLAYER_GRIPPER_STATE_ERROR
00046 };
00047 
00048 enum PlayerActArrayStates {
00049     PLAYER_ACTARRAY_ACTSTATE_IDLE = 1,
00050     PLAYER_ACTARRAY_ACTSTATE_MOVING,
00051     PLAYER_ACTARRAY_ACTSTATE_STALLED
00052 };
00053 
00054 class SIP
00055 {
00056   private:
00057     int PositionChange( unsigned short, unsigned short );
00058     int param_idx; // index of our robot's data in the parameter table
00059 
00060   public:
00061     // these values are returned in every standard SIP
00062     bool lwstall, rwstall;
00063                 unsigned char  motors_enabled, sonar_flag;
00064     unsigned char status, battery, sonarreadings, analog, digin, digout;
00065     unsigned short ptu, compass, timer, rawxpos;
00066     unsigned short rawypos, frontbumpers, rearbumpers;
00067     short angle, lvel, rvel, control;
00068     unsigned short *sonars;
00069     int xpos, ypos;
00070     int x_offset,y_offset,angle_offset;
00071 
00072     // these values are returned in a CMUcam serial string extended SIP
00073     // (in host byte-order)
00074     unsigned short blobmx, blobmy;      // Centroid
00075     unsigned short blobx1, blobx2, bloby1, bloby2;      // Bounding box
00076     unsigned short blobarea, blobconf;  // Area and confidence
00077     unsigned int         blobcolor;
00078 
00079     // This value is filled by ParseGyro()
00080     int32_t gyro_rate;
00081 
00082     // This information comes from the ARMpac and ARMINFOpac packets
00083     bool armPowerOn, armConnected;
00084     bool armJointMoving[6];
00085     unsigned char armJointPos[6];
00086     double armJointPosRads[6];
00087     unsigned char armJointTargetPos[6];
00088     char *armVersionString;
00089     unsigned char armNumJoints;
00090     ArmJoint *armJoints;
00091 
00092     // Need this value to calculate approx position of lift when in between up
00093     // and down
00094     double lastLiftPos;
00095 
00096     //Timestamping SIP packets
00097     //double timeStandardSIP, timeGyro, timeSERAUX, timeArm;
00098 
00099     /* returns 0 if Parsed correctly otherwise 1 */
00100     void ParseStandard( unsigned char *buffer );
00101     void ParseSERAUX( unsigned char *buffer );
00102     void ParseGyro(unsigned char* buffer);
00103     void ParseArm (unsigned char *buffer);
00104     void ParseArmInfo (unsigned char *buffer);
00105     void Print();
00106     void PrintSonars();
00107     void PrintArm ();
00108     void PrintArmInfo ();
00109     void FillStandard(ros_p2os_data_t* data);
00110     //void FillSERAUX(player_p2os_data_t* data);
00111     //void FillGyro(player_p2os_data_t* data);
00112     //void FillArm(player_p2os_data_t* data);
00113 
00114     SIP(int idx) :
00115             param_idx(idx), sonarreadings(0), sonars(NULL),
00116             xpos(0), ypos(0), x_offset(0), y_offset(0), angle_offset(0),
00117             blobmx(0), blobmy(0), blobx1(0), blobx2(0), bloby1(0), bloby2(0),
00118             blobarea(0), blobconf(0), blobcolor(0),
00119             armPowerOn(false), armConnected(false), armVersionString(NULL),
00120             armNumJoints(0), armJoints(NULL),
00121             lastLiftPos(0.0f)
00122     {
00123         for (int i = 0; i < 6; ++i)
00124         {
00125             armJointMoving[i] = false;
00126             armJointPos[i] = 0;
00127             armJointPosRads[i] = 0;
00128             armJointTargetPos[i] = 0;
00129         }
00130     }
00131 
00132     ~SIP(void)
00133     {
00134         delete[] sonars;
00135     }
00136 };
00137 
00138 #endif


p2os_driver
Author(s): Hunter Allen , David Feil-Seifer , Aris Synodinos , Brian Gerkey, Kasper Stoy, Richard Vaughan, Andrew Howard, Tucker Hermans, ActivMedia Robotics LLC, MobileRobots Inc.
autogenerated on Mon Oct 6 2014 03:12:45