GTMAX Final Exam FAQ

How to add variables to the GTMAX Link component

Note the procedure explained below is not supported. It is purely there so that if there are variables in the simulation that you need but are not yet a part of the GTMaxlink you may add them and verify your simulation needs, before making a request to Georgia Tech to make them a part of the official release of the GTMaxlink OCP component.

Two steps need to be undertaken

Adding the variables to the GTMax simulation

  
	%Dir datalinkMessageIPC0_ref {
	uchar sync1 = 0xa1 : ;
	uchar sync2 = 0xb0 : ;
	uchar sync3 = 0xca : ;
	uchar hcsum = 0 : ;
	uchar csum = 0 : ;
	int messageID = 0 :id #;
	int messageSize = 0 :including header;
	char navStatus = 0 :status of nav system;
	char gpsStatus = 0 :status of gps;
	char sonarStatus = 0 :status of sonar;
	char radarStatus = 0 :status of radar;
	char magnetStatus = 0 :status of magnetometer;
	char overrun = 0 :frame overrun;
	char wow = 0 :weight on skids;
	char autopilot = 0 :autopilot engaged;
	char lavoid = 0 :limit avoidance;
	int k = 0 : discrete time onboard;
	float time = 0 :onboard time;
	int kdelay = 0 : discrete time delay;
	float timedelay = 0 : time delay;
	float pos[3] = {0,0,50} :position of vehicle;
	float vel[3] = {0,0,0} :velocity of vehicle;
	float q[4] = {0,0,0,0} :attitude;
	float w[3] = {0,0,0} :vehicle angular rate;
	float altitudeAGL = 0 :altitude above terrain;
	float rpm = 0 :main rotor rpm;
	float delfhat[1] = {0} :estimate of collective position;
	float delm[3] = {0,0,0} : actuator command when the state is measured;
	float delf[1] = {0} : actuator command when the state is measured;
	float adelm[3] = {0,0,0} : moment actuator commands going to vehicle
	float adelf[1] = {0}     : force actuator commands going to vehicle
	};
  
  
	void updateDatalink( struct onboard_ref *ob )
  
  
		if( data->set->sendIPC0 ) if( nav->out->time >= 
			data->work->lastUpdateIPC0 + data->set->updateDtIPC0 ) {
			.....
  
  
		for( i=0; i<4; i++ ) {
			data->ipc0->q[i] = (float)nav->out->q[i];
		}
		data->ipc0->rpm = (float)(sen->ycs->out->rpm);
		data->ipc0->altitudeAGL = (float)nav->out->altitudeAGL;
		data->ipc0->wow = nav->out->wow;
		data->ipc0->autopilot = con->work->mode;
		data->ipc0->lavoid = ob->trajectory->work->lavoidStatus;
		data->ipc0->delfhat[0] = (float)ob->control->ol->delhat[0];
		data->ipc0->adelm[0] = (float)ob->actuators->work->delm[0];
		data->ipc0->adelm[1] = (float)ob->actuators->work->delm[1];
		data->ipc0->adelm[2] = (float)ob->actuators->work->delm[2];
		data->ipc0->adelf[0] = (float)ob->actuators->work->delf[0];
  

This will copy over the actuator commands being send to the helicopter into the data packet being sent to the second computer. On the second computer the data is mem copied in to the structure so one does not have to explicitly decipher each variable.
Now test that you are getting the data correctly in the second computer by cleaning and rebuilding the simulation (rebuild all must be done to process the new dbh file).

Editing the GTMAX Link

In the componentinfo.txt file find the GtmaxState structure definition and add the following

  
	Signal GtmaxState
	Data
	  char navStatus
	  char gpsStatus
	  char sonarStatus
	  char radarStatus
	  char magnetStatus
	  char overrun
	  char wow
	  char autopilot
	  char lavoid
	  double time
	  double x
	  double y
	  double z
	  double vx
	  double vy
	  double vz
	  double q1
	  double q2
	  double q3
	  double q4
	  double p
	  double q
	  double r
	  double rpm
	  double altitudeAGL
	  double adelm1
	  double adelm2
	  double adelm3
	  double adelf
  

In the GtmaxLink.cpp file find the GtmaxLink::SendStateOut method modify the coherent set function call to

  
sigGtmaxState->CoherentSet(ipc0->navStatus, ipc0->gpsStatus, ipc0->sonarStatus, ipc0->radarStatus, ipc0->magnetStatus,
ipc0->overrun, ipc0->wow, ipc0->autopilot, ipc0->lavoid, ipc0->time,ipc0->pos[0],ipc0->pos[1],ipc0->pos[2],
ipc0->vel[0],ipc0->vel[1],ipc0->vel[2], ipc0->q[0], ipc0->q[1], ipc0->q[2], ipc0->q[3], ipc0->w[0], ipc0->w[1], ipc0->w[2],
ipc0->rpm, ipc0->altitudeAGL,ipc0->adelm[0],ipc0->adelm[1],ipc0->adelm[2],ipc0->adelf[0]);
  

This concludes the modifications you need to make to the GtmaxLink component. Regenerate your ocp workspace and the commands (normalized) that are being sent to the actuators will be available to you.