2011-08-21 16:55:54 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
* AP_mount -- library to control a 2 or 3 axis mount. *
|
|
|
|
* *
|
|
|
|
* Author: Joe Holdsworth; *
|
|
|
|
* Ritchie Wilson; *
|
2011-09-09 11:18:38 -03:00
|
|
|
* Amilcar Lucas; *
|
2011-08-21 16:55:54 -03:00
|
|
|
* *
|
|
|
|
* Purpose: Move a 2 or 3 axis mount attached to vehicle, *
|
|
|
|
* Used for mount to track targets or stabilise *
|
|
|
|
* camera plus other modes. *
|
|
|
|
* *
|
|
|
|
* Usage: Use in main code to control mounts attached to *
|
|
|
|
* vehicle. *
|
|
|
|
* *
|
|
|
|
*Comments: All angles in degrees * 100, distances in meters*
|
|
|
|
* unless otherwise stated. *
|
|
|
|
************************************************************/
|
2011-08-21 15:33:39 -03:00
|
|
|
#ifndef AP_Mount_H
|
|
|
|
#define AP_Mount_H
|
|
|
|
|
2011-09-09 11:18:38 -03:00
|
|
|
//#include <AP_Common.h>
|
2011-08-21 15:33:39 -03:00
|
|
|
#include <AP_Math.h>
|
|
|
|
#include <AP_GPS.h>
|
|
|
|
#include <AP_DCM.h>
|
|
|
|
|
|
|
|
class AP_Mount
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//Constructors
|
2011-09-09 11:18:38 -03:00
|
|
|
AP_Mount(GPS *gps, AP_DCM *dcm);
|
2011-08-21 15:33:39 -03:00
|
|
|
|
|
|
|
//enums
|
|
|
|
enum MountMode{
|
2011-09-09 11:18:38 -03:00
|
|
|
k_gps_target = 0,
|
|
|
|
k_stabilise = 1, //note the correct English spelling :)
|
|
|
|
k_roam = 2,
|
|
|
|
k_assisted = 3,
|
|
|
|
k_landing = 4,
|
|
|
|
k_none = 5,
|
|
|
|
k_manual = 6
|
2011-08-21 15:33:39 -03:00
|
|
|
};
|
2011-08-21 15:48:28 -03:00
|
|
|
|
|
|
|
enum MountType{
|
2011-09-09 11:18:38 -03:00
|
|
|
k_pan_tilt = 0, //yaw-pitch
|
|
|
|
k_tilt_roll = 1, //pitch-roll
|
|
|
|
k_pan_tilt_roll = 2, //yaw-pitch-roll
|
2011-08-21 15:48:28 -03:00
|
|
|
};
|
2011-08-21 15:33:39 -03:00
|
|
|
|
|
|
|
//Accessors
|
2011-09-09 11:18:38 -03:00
|
|
|
void set_pitch_yaw(int pitchCh, int yawCh);
|
|
|
|
void set_pitch_roll(int pitchCh, int rollCh);
|
|
|
|
void set_pitch_roll_yaw(int pitchCh, int rollCh, int yawCh);
|
2011-08-22 18:50:11 -03:00
|
|
|
|
2011-09-09 11:18:38 -03:00
|
|
|
void set_GPS_target(Location targetGPSLocation); //used to tell the mount to track GPS location
|
|
|
|
void set_assisted(int roll, int pitch, int yaw);
|
|
|
|
void set_mount_free_roam(int roll, int pitch, int yaw);//used in the FPV for example,
|
|
|
|
void set_mount_landing(int roll, int pitch, int yaw); //set mount landing position
|
|
|
|
void set_none();
|
2011-08-21 15:33:39 -03:00
|
|
|
|
|
|
|
//methods
|
2011-09-09 11:18:38 -03:00
|
|
|
void update_mount();
|
|
|
|
void update_mount_type(); //Auto-detect the mount gimbal type depending on the functions assigned to the servos
|
|
|
|
void set_mode(MountMode mode);
|
2011-08-21 15:33:39 -03:00
|
|
|
|
2011-09-09 11:18:38 -03:00
|
|
|
int pitch_angle; //degrees*100
|
|
|
|
int roll_angle; //degrees*100
|
|
|
|
int yaw_angle; //degrees*100
|
|
|
|
protected:
|
2011-08-21 15:33:39 -03:00
|
|
|
//methods
|
2011-09-09 11:18:38 -03:00
|
|
|
void calc_GPS_target_vector(struct Location *target);
|
2011-08-21 15:33:39 -03:00
|
|
|
//void CalculateDCM(int roll, int pitch, int yaw);
|
|
|
|
//members
|
2011-08-22 18:50:11 -03:00
|
|
|
AP_DCM *_dcm;
|
2011-08-21 15:33:39 -03:00
|
|
|
GPS *_gps;
|
|
|
|
|
2011-09-09 11:18:38 -03:00
|
|
|
MountMode _mount_mode;
|
|
|
|
MountType _mount_type;
|
2011-08-22 18:50:11 -03:00
|
|
|
|
2011-09-09 11:18:38 -03:00
|
|
|
struct Location _target_GPS_location;
|
|
|
|
Vector3f _GPS_vector; //target vector calculated stored in meters
|
2011-08-22 18:50:11 -03:00
|
|
|
|
2011-09-09 11:18:38 -03:00
|
|
|
Vector3i _roam_angles; //used for roam mode vector.x = roll vector.y = pitch, vector.z=yaw
|
|
|
|
Vector3i _landing_angles; //landing position for mount, vector.x = roll vector.y = pitch, vector.z=yaw
|
2011-08-21 15:33:39 -03:00
|
|
|
|
2011-09-09 11:18:38 -03:00
|
|
|
Vector3i _assist_angles; //used to keep angles that user has supplied from assisted targeting
|
|
|
|
Vector3f _assist_vector; //used to keep vector calculated from _AssistAngles
|
2011-08-21 15:33:39 -03:00
|
|
|
};
|
|
|
|
#endif
|