SPYSpheres
gsp.cpp File Reference
#include "comm.h"
#include "commands.h"
#include "control.h"
#include "gsp.h"
#include "gsp_task.h"
#include "gsp_internal.h"
#include "pads.h"
#include "prop.h"
#include "spheres_constants.h"
#include "spheres_physical_parameters.h"
#include "spheres_types.h"
#include "std_includes.h"
#include "system.h"
#include "util_memory.h"
#include "gsutil_checkout.h"
#include "ZRGameInternal.h"
#include "ZRGame.h"

Go to the source code of this file.

Defines

#define CHECKOUT_TESTNUM_OFFSET   (000)
#define ZERROBOTICS_TESTNUM_OFFSET   (100)
#define localPacket   packet

Typedefs

typedef enum _test_class test_class

Enumerations

enum  _test_class { invalid_test, checkout_tests, zerorobotics_tests }

Functions

test_class get_test_class (unsigned int test_num)
void gspIdentitySet ()
void gspInitProgram ()
void gspInitTest (unsigned int test_number)
void gspInitTask ()
void gspPadsInertial (IMU_sample *accel, IMU_sample *gyro, unsigned int num_samples)
void gspPadsGlobal (unsigned int beacon, beacon_measurement_matrix measurements)
void gspTaskRun (unsigned int gsp_task_trigger, unsigned int extra_data)
void gspControl (unsigned int test_number, unsigned int test_time, unsigned int maneuver_number, unsigned int maneuver_time)
void gspProcessRXData (default_rfm_packet packet)

Variables

const unsigned int refTestNumber [] = {101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 199}
static int testclass
static unsigned int testnum = 0
static ZeroRoboticsGameImplgameImplRef = ZeroRoboticsGameImpl::instance()

Define Documentation

#define CHECKOUT_TESTNUM_OFFSET   (000)

Definition at line 40 of file gsp.cpp.

#define localPacket   packet
#define ZERROBOTICS_TESTNUM_OFFSET   (100)

Definition at line 41 of file gsp.cpp.


Typedef Documentation

typedef enum _test_class test_class

Enumeration Type Documentation

Enumerator:
invalid_test 
checkout_tests 
zerorobotics_tests 

Definition at line 47 of file gsp.cpp.


Function Documentation

test_class get_test_class ( unsigned int  test_num)

Definition at line 53 of file gsp.cpp.

{
  if ((test_num > CHECKOUT_TESTNUM_OFFSET) && (test_num <= ZERROBOTICS_TESTNUM_OFFSET))
    return checkout_tests;

  if ((test_num > ZERROBOTICS_TESTNUM_OFFSET))
    return zerorobotics_tests;
    
  return invalid_test;
}
void gspControl ( unsigned int  test_number,
unsigned int  test_time,
unsigned int  maneuver_number,
unsigned int  maneuver_time 
)

Definition at line 143 of file gsp.cpp.

{
  switch (testclass)
  {
    case checkout_tests:
      gspControl_Checkout(testnum, test_time, maneuver_number, maneuver_time); 
      break;
    case zerorobotics_tests:
      gameImplRef.gspControl(test_number,test_time,maneuver_number,maneuver_time);
      break;
  }
}
void gspIdentitySet ( )

Definition at line 65 of file gsp.cpp.

{
   // set the logical identifier (SPHERE#) for this vehicle
   sysIdentitySet(SPHERE_ID);
}
void gspInitProgram ( )

Definition at line 72 of file gsp.cpp.

{
   // set the unique program identifier (to be assigned by MIT)
   sysProgramIDSet(9998);

   // set up communications TDMA frames
   commTdmaStandardInit(COMM_CHANNEL_STL, sysIdentityGet(), NUM_SPHERES);
   commTdmaStandardInit(COMM_CHANNEL_STS, sysIdentityGet(), NUM_SPHERES);

   // enable communications channels
   commTdmaEnable(COMM_CHANNEL_STL);
   commTdmaEnable(COMM_CHANNEL_STS);   
   
   // allocate storage space for IMU samples
   padsInertialAllocateBuffers(50);

   // inform system of highest beacon number in use
   padsInitializeFPGA(NUM_BEACONS);
}
void gspInitTask ( )

Definition at line 116 of file gsp.cpp.

{
}
void gspInitTest ( unsigned int  test_number)

Definition at line 92 of file gsp.cpp.

{
  // make a zero-offset index
  unsigned int index;
  
  index = test_number-1;
  
  testclass = get_test_class(refTestNumber[index]);
  testnum = refTestNumber[index] % 100;

  switch (testclass)
  {
    case checkout_tests:
      gspInitTest_Checkout(testnum);
      break;
    case zerorobotics_tests:
      gameImplRef.gspInitTest(test_number);
      break;
    default:
      ctrlTestTerminate(TEST_RESULT_UNKNOWN_TEST);
      break;
  }
}
void gspPadsGlobal ( unsigned int  beacon,
beacon_measurement_matrix  measurements 
)

Definition at line 126 of file gsp.cpp.

{
}
void gspPadsInertial ( IMU_sample *  accel,
IMU_sample *  gyro,
unsigned int  num_samples 
)

Definition at line 121 of file gsp.cpp.

{
}
void gspProcessRXData ( default_rfm_packet  packet)

Definition at line 157 of file gsp.cpp.

{
  //USED TO AVOID CHECKS IN MUDFLAP
  #ifdef ZRSIMULATION
    default_rfm_packet localPacket;
    unchecked_memcpy(localPacket,packet,37);
  #else
    #define localPacket packet
  #endif
  switch(testclass)
  {
    case zerorobotics_tests:
      gameImplRef.gspProcessRXData(packet);
    break;
  
  }
  #ifndef ZRSIMULATION
  #undef localPacket
  #endif
}
void gspTaskRun ( unsigned int  gsp_task_trigger,
unsigned int  extra_data 
)

Definition at line 131 of file gsp.cpp.

{
  switch (testclass)
  {
    case checkout_tests:
      gspTaskRun_Checkout(gsp_task_trigger,extra_data);
      break;
  }

}

Variable Documentation

Definition at line 51 of file gsp.cpp.

const unsigned int refTestNumber[] = {101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 199}

Definition at line 44 of file gsp.cpp.

int testclass [static]

Definition at line 46 of file gsp.cpp.

unsigned int testnum = 0 [static]

Definition at line 49 of file gsp.cpp.