Saturday, May 4, 2013

16. Auto Take-Off and Auto-Landing programming of the #UAV

For our Auto Take-Off and Auto-Landing - We went in the  waypoints.h file of Matrix-Pilot (in MPLab IDE) and entered the following waypoints:

const struct waypointDef waypoints[] = {
{ {   8000,   0, 500 } , F_TAKEOFF, CAM_VIEW_LAUNCH } ,  // return to, and loiter 75 meters above the start-up position
{ {   5000,   0, 300 } , F_NORMAL, CAM_VIEW_LAUNCH } ,
    { {   2000,   0, 150 } , F_LAND, CAM_VIEW_LAUNCH } ,
{ {   1000,   0, 50 } , F_LAND, CAM_VIEW_LAUNCH } ,
{ {   -3000,   0, 10 } , F_LAND, CAM_VIEW_LAUNCH } ,
} ;

Here F_TAKEOFF initiates the takeoff  (i.e quickly gain the altitude and the waypoint) code for its respective waypoint and F_LAND initiates the Landing Code (in this the throttle turns off at the waypoint prior to its own).

To switch fom Loiter waypoint/mode to next waypoint: 

Since the whole Auto-Pilot mode works on one waypoint only, hence to switch out from it we only need to move to the next waypoint. We opened the telemetry.c file (which controls the transmitting and receiving of serial data) and entered a new character 'N' in the following function. On sending 'N' from Happy Kill-more G.C.S to the micro-controller, our program  (and in turn our U.A.V.) will switch to the next waypoint with the help of next_waypoint function. 

All the above editions are shown below:

void udb_serial_callback_received_byte(uint8_t rxchar) // An interrupt, for serial data, being called in the seriall0_udb.c file
{
(* sio_parse) ( rxchar ) ; // parse the input byte i.e. address of character in function void sio_newMsg() will be loaded in this
return ;
}
void sio_newMsg( uint8_t inchar )
{
if ( inchar == 'V' )
{
sio_parse = &sio_voltage_high ;
}
else if ( inchar == 'N' )
{ next_waypoint();
}
#if ( FLIGHT_PLAN_TYPE == FP_LOGO )
else if ( inchar == 'L' )
#else
else if ( inchar == 'W' )
#endif


After this we entered the following waypoints to join/club both Auto-Pilot and Auto Take-Off & Landing Programs:

const struct waypointDef waypoints[] = {
{ {   0,   0, 500 } , F_LOITER, CAM_VIEW_LAUNCH },
{ {   8000,   0, 500 } , F_NORMAL, CAM_VIEW_LAUNCH } ,  // return to, and loiter 75 meters above the start-up position
{ {   5000,   0, 300 } , F_NORMAL, CAM_VIEW_LAUNCH } ,
    { {   2000,   0, 150 } , F_LAND, CAM_VIEW_LAUNCH } ,
{ {   1000,   0, 50 } , F_LAND, CAM_VIEW_LAUNCH } ,
{ {   -3000,   0, 10 } , F_LAND, CAM_VIEW_LAUNCH } ,
} ;

Here F_LOITER (Post 6. How are we going to build a more stable Loiter program?) initiates the Auto-Pilot code for its respective waypoint.