2013-12-17 00:59:14 -04:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AP_EPM.h
|
|
|
|
*
|
|
|
|
* Created on: DEC 06, 2013
|
|
|
|
* Author: Andreas Jochum
|
2014-09-17 03:00:46 -03:00
|
|
|
*
|
|
|
|
* Set-up Wiki: http://copter.ardupilot.com/wiki/common-electro-permanent-magnet-gripper/
|
2013-12-17 00:59:14 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/// @file AP_EPM.h
|
|
|
|
/// @brief AP_EPM control class
|
2016-02-17 21:25:21 -04:00
|
|
|
#pragma once
|
2013-12-17 00:59:14 -04:00
|
|
|
|
2015-08-11 03:28:42 -03:00
|
|
|
#include <AP_Math/AP_Math.h>
|
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
#include <RC_Channel/RC_Channel.h>
|
2014-09-15 03:51:06 -03:00
|
|
|
|
|
|
|
// EPM PWM definitions
|
2014-09-17 03:00:46 -03:00
|
|
|
#define EPM_GRAB_PWM_DEFAULT 1900
|
|
|
|
#define EPM_RELEASE_PWM_DEFAULT 1100
|
|
|
|
#define EPM_NEUTRAL_PWM_DEFAULT 1500
|
|
|
|
#define EPM_RETURN_TO_NEUTRAL_MS 500 // EPM PWM returns to neutral position this many milliseconds after grab or release
|
|
|
|
#define EPM_REGRAB_DEFAULT 0 // default re-grab interval (in seconds) to ensure cargo is securely held
|
2013-12-17 00:59:14 -04:00
|
|
|
|
|
|
|
/// @class AP_EPM
|
|
|
|
/// @brief Class to manage the EPM_CargoGripper
|
|
|
|
class AP_EPM {
|
|
|
|
public:
|
|
|
|
AP_EPM();
|
|
|
|
|
2014-09-17 03:00:46 -03:00
|
|
|
// initialise the EPM
|
2013-12-17 00:59:14 -04:00
|
|
|
void init();
|
|
|
|
|
2014-09-17 03:00:46 -03:00
|
|
|
// enabled - true if the EPM is enabled
|
2014-09-15 03:51:06 -03:00
|
|
|
bool enabled() { return _enabled; }
|
2013-12-17 00:59:14 -04:00
|
|
|
|
2014-09-17 03:00:46 -03:00
|
|
|
// grab - move the EPM pwm output to the grab position
|
2014-09-15 03:51:06 -03:00
|
|
|
void grab();
|
2013-12-17 00:59:14 -04:00
|
|
|
|
2014-09-17 03:00:46 -03:00
|
|
|
// release - move the EPM pwm output to the release position
|
2014-09-15 03:51:06 -03:00
|
|
|
void release();
|
2013-12-17 00:59:14 -04:00
|
|
|
|
2014-09-15 03:51:06 -03:00
|
|
|
// update - moves the pwm back to neutral after the timeout has passed
|
|
|
|
// should be called at at least 10hz
|
|
|
|
void update();
|
|
|
|
|
2013-12-17 00:59:14 -04:00
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
|
|
|
private:
|
2014-09-17 03:00:46 -03:00
|
|
|
|
|
|
|
// neutral - return the EPM pwm output to the neutral position
|
|
|
|
void neutral();
|
|
|
|
|
|
|
|
// EPM flags
|
|
|
|
struct EPM_Flags {
|
|
|
|
uint8_t grab : 1; // true if we think we have grabbed onto cargo, false if we think we've released it
|
|
|
|
uint8_t active : 1; // true if we are actively sending grab or release PWM to EPM to activate grabbing or releasing, false if we are sending neutral pwm
|
|
|
|
} _flags;
|
|
|
|
|
2014-09-15 03:51:06 -03:00
|
|
|
// parameters
|
2014-09-17 03:00:46 -03:00
|
|
|
AP_Int8 _enabled; // EPM enable/disable
|
|
|
|
AP_Int16 _grab_pwm; // PWM value sent to EPM to initiate grabbing the cargo
|
|
|
|
AP_Int16 _release_pwm; // PWM value sent to EPM to release the cargo
|
|
|
|
AP_Int16 _neutral_pwm; // PWM value sent to EPM when not grabbing or releasing
|
|
|
|
AP_Int8 _regrab_interval; // Time in seconds that gripper will regrab the cargo to ensure grip has not weakend
|
2013-12-17 00:59:14 -04:00
|
|
|
|
2014-09-15 03:51:06 -03:00
|
|
|
// internal variables
|
|
|
|
uint32_t _last_grab_or_release;
|
2013-12-17 00:59:14 -04:00
|
|
|
};
|