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     std::string odom_frame_id;
00072     std::string base_link_frame_id;
00073 
00074     // these values are returned in a CMUcam serial string extended SIP
00075     // (in host byte-order)
00076     unsigned short blobmx, blobmy;      // Centroid
00077     unsigned short blobx1, blobx2, bloby1, bloby2;      // Bounding box
00078     unsigned short blobarea, blobconf;  // Area and confidence
00079     unsigned int         blobcolor;
00080 
00081     // This value is filled by ParseGyro()
00082     int32_t gyro_rate;
00083 
00084     // This information comes from the ARMpac and ARMINFOpac packets
00085     bool armPowerOn, armConnected;
00086     bool armJointMoving[6];
00087     unsigned char armJointPos[6];
00088     double armJointPosRads[6];
00089     unsigned char armJointTargetPos[6];
00090     char *armVersionString;
00091     unsigned char armNumJoints;
00092     ArmJoint *armJoints;
00093 
00094     // Need this value to calculate approx position of lift when in between up
00095     // and down
00096     double lastLiftPos;
00097 
00098     //Timestamping SIP packets
00099     //double timeStandardSIP, timeGyro, timeSERAUX, timeArm;
00100 
00101     /* returns 0 if Parsed correctly otherwise 1 */
00102     void ParseStandard( unsigned char *buffer );
00103     void ParseSERAUX( unsigned char *buffer );
00104     void ParseGyro(unsigned char* buffer);
00105     void ParseArm (unsigned char *buffer);
00106     void ParseArmInfo (unsigned char *buffer);
00107     void Print();
00108     void PrintSonars();
00109     void PrintArm ();
00110     void PrintArmInfo ();
00111     void FillStandard(ros_p2os_data_t* data);
00112     //void FillSERAUX(player_p2os_data_t* data);
00113     //void FillGyro(player_p2os_data_t* data);
00114     //void FillArm(player_p2os_data_t* data);
00115 
00116     SIP(int idx) :
00117             param_idx(idx), sonarreadings(0), sonars(NULL),
00118             xpos(0), ypos(0), x_offset(0), y_offset(0), angle_offset(0),
00119             blobmx(0), blobmy(0), blobx1(0), blobx2(0), bloby1(0), bloby2(0),
00120             blobarea(0), blobconf(0), blobcolor(0),
00121             armPowerOn(false), armConnected(false), armVersionString(NULL),
00122             armNumJoints(0), armJoints(NULL),
00123             lastLiftPos(0.0f)
00124     {
00125         for (int i = 0; i < 6; ++i)
00126         {
00127             armJointMoving[i] = false;
00128             armJointPos[i] = 0;
00129             armJointPosRads[i] = 0;
00130             armJointTargetPos[i] = 0;
00131         }
00132     }
00133 
00134     ~SIP(void)
00135     {
00136         delete[] sonars;
00137     }
00138 };
00139 
00140 #endif


p2os_driver
Author(s): Hunter L. Allen , David Feil-Seifer , Aris Synodinos , Brian Gerkey, Kasper Stoy, Richard Vaughan, Andrew Howard, Tucker Hermans, ActivMedia Robotics LLC, MobileRobots Inc.
autogenerated on Sat Aug 5 2017 02:20:17