Documentation improvements, no functional changes (only comments)

This commit is contained in:
Amilcar Lucas 2012-06-17 22:53:54 +02:00
parent f4e9587aca
commit 594cedd324
4 changed files with 56 additions and 41 deletions

View File

@ -12,13 +12,19 @@ extern AP_Relay relay;
#define CAM_DEBUG DISABLED #define CAM_DEBUG DISABLED
const AP_Param::GroupInfo AP_Camera::var_info[] PROGMEM = { const AP_Param::GroupInfo AP_Camera::var_info[] PROGMEM = {
// @Param: TRIGG_TYPE
// @DisplayName: Camera shutter (trigger) type
// @Description: how to trigger the camera to take a picture
// @Values: 0:Servo,1:relay,2:throttle_off_time,3:throttle_off_waypoint,4:transistor
// @User: Standard
AP_GROUPINFO("TRIGG_TYPE", 0, AP_Camera, trigger_type), AP_GROUPINFO("TRIGG_TYPE", 0, AP_Camera, trigger_type),
AP_GROUPEND AP_GROUPEND
}; };
/// Servo operated camera
void void
AP_Camera::servo_pic() // Servo operated camera AP_Camera::servo_pic()
{ {
if (g_rc_function[RC_Channel_aux::k_cam_trigger]) if (g_rc_function[RC_Channel_aux::k_cam_trigger])
{ {
@ -27,15 +33,17 @@ AP_Camera::servo_pic() // Servo operated camera
} }
} }
/// basic relay activation
void void
AP_Camera::relay_pic() // basic relay activation AP_Camera::relay_pic()
{ {
relay.on(); relay.on();
keep_cam_trigg_active_cycles = 2; // leave a message that it should be active for two event loop cycles keep_cam_trigg_active_cycles = 2; // leave a message that it should be active for two event loop cycles
} }
/// pictures blurry? use this trigger. Turns off the throttle until for # of cycles of medium loop then takes the picture and re-enables the throttle.
void void
AP_Camera::throttle_pic() // pictures blurry? use this trigger. Turns off the throttle until for # of cycles of medium loop then takes the picture and re-enables the throttle. AP_Camera::throttle_pic()
{ {
// TODO find a way to do this without using the global parameter g // TODO find a way to do this without using the global parameter g
// g.channel_throttle.radio_out = g.throttle_min; // g.channel_throttle.radio_out = g.throttle_min;
@ -47,8 +55,9 @@ AP_Camera::throttle_pic() // pictures blurry? use this trigger. Turns off the t
thr_pic++; thr_pic++;
} }
/// pictures blurry? use this trigger. Turns off the throttle until closer to waypoint then takes the picture and re-enables the throttle.
void void
AP_Camera::distance_pic() // pictures blurry? use this trigger. Turns off the throttle until closer to waypoint then takes the picture and re-enables the throttle. AP_Camera::distance_pic()
{ {
// TODO find a way to do this without using the global parameter g // TODO find a way to do this without using the global parameter g
// g.channel_throttle.radio_out = g.throttle_min; // g.channel_throttle.radio_out = g.throttle_min;
@ -58,15 +67,16 @@ AP_Camera::distance_pic() // pictures blurry? use this trigger. Turns off the t
} }
} }
/// hacked the circuit to run a transistor? use this trigger to send output.
void void
AP_Camera::NPN_pic() // hacked the circuit to run a transistor? use this trigger to send output. AP_Camera::NPN_pic()
{ {
// TODO: Assign pin spare pin for output // TODO: Assign pin spare pin for output
digitalWrite(camtrig, HIGH); digitalWrite(camtrig, HIGH);
keep_cam_trigg_active_cycles = 1; // leave a message that it should be active for two event loop cycles keep_cam_trigg_active_cycles = 1; // leave a message that it should be active for two event loop cycles
} }
// single entry point to take pictures /// single entry point to take pictures
void void
AP_Camera::trigger_pic() AP_Camera::trigger_pic()
{ {
@ -90,7 +100,7 @@ AP_Camera::trigger_pic()
} }
} }
// de-activate the trigger after some delay, but without using a delay() function /// de-activate the trigger after some delay, but without using a delay() function
void void
AP_Camera::trigger_pic_cleanup() AP_Camera::trigger_pic_cleanup()
{ {
@ -116,6 +126,8 @@ AP_Camera::trigger_pic_cleanup()
} }
} }
} }
/// decode MavLink that configures camera
void void
AP_Camera::configure_msg(mavlink_message_t* msg) AP_Camera::configure_msg(mavlink_message_t* msg)
{ {
@ -143,6 +155,7 @@ AP_Camera::configure_msg(mavlink_message_t* msg)
mavlink_msg_digicam_configure_send(MAVLINK_COMM_3, packet.target_system, packet.target_component, packet.mode, packet.shutter_speed, packet.aperture, packet.iso, packet.exposure_type, packet.command_id, packet.engine_cut_off, packet.extra_param, packet.extra_value); mavlink_msg_digicam_configure_send(MAVLINK_COMM_3, packet.target_system, packet.target_component, packet.mode, packet.shutter_speed, packet.aperture, packet.iso, packet.exposure_type, packet.command_id, packet.engine_cut_off, packet.extra_param, packet.extra_value);
} }
/// decode MavLink that controls camera
void void
AP_Camera::control_msg(mavlink_message_t* msg) AP_Camera::control_msg(mavlink_message_t* msg)
{ {

View File

@ -2,6 +2,7 @@
/// @file AP_Camera.h /// @file AP_Camera.h
/// @brief Photo or video camera manager, with EEPROM-backed storage of constants. /// @brief Photo or video camera manager, with EEPROM-backed storage of constants.
/// @author Amilcar Lucas
#ifndef AP_CAMERA_H #ifndef AP_CAMERA_H
#define AP_CAMERA_H #define AP_CAMERA_H
@ -35,17 +36,17 @@ public:
void configure_msg(mavlink_message_t* msg); void configure_msg(mavlink_message_t* msg);
void control_msg(mavlink_message_t* msg); void control_msg(mavlink_message_t* msg);
int picture_time; // waypoint trigger variable int picture_time; ///< waypoint trigger variable
long wp_distance_min; // take picture if distance to WP is smaller than this long wp_distance_min; ///< take picture if distance to WP is smaller than this
static const struct AP_Param::GroupInfo var_info[]; static const struct AP_Param::GroupInfo var_info[];
private: private:
uint8_t keep_cam_trigg_active_cycles; // event loop cycles to keep trigger active uint8_t keep_cam_trigg_active_cycles; ///< event loop cycles to keep trigger active
int thr_pic; // timer variable for throttle_pic int thr_pic; ///< timer variable for throttle_pic
int camtrig; // PK6 chosen as it not near anything so safer for soldering int camtrig; ///< PK6 chosen as it not near anything so safer for soldering
AP_Int8 trigger_type; // 0=Servo, 1=relay, 2=throttle_off time, 3=throttle_off waypoint 4=transistor AP_Int8 trigger_type; ///< 0=Servo, 1=relay, 2=throttle_off time, 3=throttle_off waypoint, 4=transistor
void servo_pic(); // Servo operated camera void servo_pic(); // Servo operated camera
void relay_pic(); // basic relay activation void relay_pic(); // basic relay activation

View File

@ -30,9 +30,10 @@ const AP_Param::GroupInfo RC_Channel_aux::var_info[] PROGMEM = {
AP_GROUPEND AP_GROUPEND
}; };
// Global pointer array, indexed by a "RC function enum" and points to the RC channel output assigned to that function/operation /// Global pointer array, indexed by a "RC function enum" and points to the RC channel output assigned to that function/operation
RC_Channel_aux* g_rc_function[RC_Channel_aux::k_nr_aux_servo_functions]; RC_Channel_aux* g_rc_function[RC_Channel_aux::k_nr_aux_servo_functions];
/// saturate to the closest angle limit if outside of min max angle interval
int16_t int16_t
RC_Channel_aux::closest_limit(int16_t angle) RC_Channel_aux::closest_limit(int16_t angle)
{ {
@ -69,8 +70,8 @@ RC_Channel_aux::closest_limit(int16_t angle)
return angle; return angle;
} }
// Gets the RC and integrates and then compares with the servo out angles to limit control input to servo travel. /// Gets the RC and integrates and then compares with the servo out angles to limit control input to servo travel.
// That way the user doesn't get lost. Rotationally. /// That way the user doesn't get lost. Rotationally.
void void
RC_Channel_aux::rc_input(float *control_angle, int16_t angle) RC_Channel_aux::rc_input(float *control_angle, int16_t angle)
{ {
@ -79,8 +80,8 @@ RC_Channel_aux::rc_input(float *control_angle, int16_t angle)
} }
} }
// Takes the desired servo angle(deg) and converts to microSeconds for PWM /// Takes the desired servo angle(deg) and converts to microSeconds for PWM
// Like this: 45 deg = 2000 us ; -45 deg/1000 us. 1000us/(90*100 deg) = 0.1111111111111 /// Like this: 45 deg = 2000 us ; -45 deg/1000 us. 1000us/(90*100 deg) = 0.1111111111111
void void
RC_Channel_aux::angle_out(int16_t angle) RC_Channel_aux::angle_out(int16_t angle)
{ {
@ -94,7 +95,7 @@ RC_Channel_aux::angle_out(int16_t angle)
radio_out = (/*_reverse * */ angle * 0.1111111) + 1500; radio_out = (/*_reverse * */ angle * 0.1111111) + 1500;
} }
// map a function to a servo channel and output it /// map a function to a servo channel and output it
void void
RC_Channel_aux::output_ch(unsigned char ch_nr) RC_Channel_aux::output_ch(unsigned char ch_nr)
{ {
@ -112,10 +113,10 @@ RC_Channel_aux::output_ch(unsigned char ch_nr)
_apm_rc->OutputCh(ch_nr, radio_out); _apm_rc->OutputCh(ch_nr, radio_out);
} }
// Update the g_rc_function array of pointers to rc_x channels /// Update the g_rc_function array of pointers to rc_x channels
// This is to be done before rc_init so that the channels get correctly initialized. /// This is to be done before rc_init so that the channels get correctly initialized.
// It also should be called periodically because the user might change the configuration and /// It also should be called periodically because the user might change the configuration and
// expects the changes to take effect instantly /// expects the changes to take effect instantly
void update_aux_servo_function(RC_Channel_aux* rc_5, RC_Channel_aux* rc_6, RC_Channel_aux* rc_7, RC_Channel_aux* rc_8) void update_aux_servo_function(RC_Channel_aux* rc_5, RC_Channel_aux* rc_6, RC_Channel_aux* rc_7, RC_Channel_aux* rc_8)
{ {
// positions 0..3 of this array never get used, but this is a stack array, so the entire array gets freed at the end of the function // positions 0..3 of this array never get used, but this is a stack array, so the entire array gets freed at the end of the function

View File

@ -32,32 +32,32 @@ public:
typedef enum typedef enum
{ {
k_none = 0, // disabled k_none = 0, ///< disabled
k_manual = 1, // manual, just pass-thru the RC in signal k_manual = 1, ///< manual, just pass-thru the RC in signal
k_flap = 2, // flap k_flap = 2, ///< flap
k_flap_auto = 3, // flap automated k_flap_auto = 3, ///< flap automated
k_aileron = 4, // aileron k_aileron = 4, ///< aileron
k_flaperon = 5, // flaperon (flaps and aileron combined, needs two independent servos one for each wing) k_flaperon = 5, ///< flaperon (flaps and aileron combined, needs two independent servos one for each wing)
k_mount_yaw = 6, // mount yaw (pan) k_mount_yaw = 6, ///< mount yaw (pan)
k_mount_pitch = 7, // mount pitch (tilt) k_mount_pitch = 7, ///< mount pitch (tilt)
k_mount_roll = 8, // mount roll k_mount_roll = 8, ///< mount roll
k_mount_open = 9, // mount open (deploy) / close (retract) k_mount_open = 9, ///< mount open (deploy) / close (retract)
k_cam_trigger = 10, // camera trigger k_cam_trigger = 10, ///< camera trigger
k_egg_drop = 11, // egg drop k_egg_drop = 11, ///< egg drop
k_nr_aux_servo_functions // This must be the last enum value (only add new values _before_ this one) k_nr_aux_servo_functions ///< This must be the last enum value (only add new values _before_ this one)
} Aux_servo_function_t; } Aux_servo_function_t;
AP_Int8 function; // 0=disabled, 1=manual, 2=flap, 3=flap auto, 4=aileron, 5=flaperon, 6=mount yaw (pan), 7=mount pitch (tilt), 8=mount roll, 9=camera trigger, 10=camera open, 11=egg drop AP_Int8 function; ///< see Aux_servo_function_t enum
AP_Int16 angle_min; // min angle limit of actuated surface in 0.01 degree units AP_Int16 angle_min; ///< min angle limit of actuated surface in 0.01 degree units
AP_Int16 angle_max; // max angle limit of actuated surface in 0.01 degree units AP_Int16 angle_max; ///< max angle limit of actuated surface in 0.01 degree units
int16_t closest_limit(int16_t angle); // saturate to the closest angle limit if outside of min max angle interval int16_t closest_limit(int16_t angle);
void angle_out(int16_t angle); void angle_out(int16_t angle);
void rc_input(float *control_angle, int16_t angle); void rc_input(float *control_angle, int16_t angle);
void output_ch(unsigned char ch_nr); // map a function to a servo channel and output it void output_ch(unsigned char ch_nr);
static const struct AP_Param::GroupInfo var_info[]; static const struct AP_Param::GroupInfo var_info[];
}; };