ardupilot/libraries/AP_Gripper/AP_Gripper_EPM.h

63 lines
1.7 KiB
C
Raw Normal View History

2013-12-17 00:59:14 -04:00
/*
* AP_EPM.h
*
* Created on: DEC 06, 2013
* Author: Andreas Jochum
2016-06-23 20:48:29 -03:00
* Pavel Kirienko <pavel.kirienko@zubax.com> - UAVCAN support
*
* Set-up Wiki: https://copter.ardupilot.org/wiki/common-electro-permanent-magnet-gripper/
2016-06-23 20:48:29 -03:00
* EPM docs: https://docs.zubax.com/opengrab_epm_v3
2013-12-17 00:59:14 -04:00
*/
/// @file AP_EPM.h
/// @brief AP_EPM control class
#pragma once
2013-12-17 00:59:14 -04:00
#include "AP_Gripper.h"
#include "AP_Gripper_Backend.h"
2017-01-06 21:06:40 -04:00
#include <SRV_Channel/SRV_Channel.h>
#define EPM_RETURN_TO_NEUTRAL_MS 500 // EPM PWM returns to neutral position this many milliseconds after grab or release
2013-12-17 00:59:14 -04:00
/// @class AP_Gripper_EPM
2013-12-17 00:59:14 -04:00
/// @brief Class to manage the EPM_CargoGripper
class AP_Gripper_EPM : public AP_Gripper_Backend {
2013-12-17 00:59:14 -04:00
public:
AP_Gripper_EPM(struct AP_Gripper::Backend_Config &_config);
2013-12-17 00:59:14 -04:00
// initialise the EPM
void init_gripper() override;
2013-12-17 00:59:14 -04:00
// grab - move the EPM pwm output to the grab position
void grab() override;
2013-12-17 00:59:14 -04:00
// release - move the EPM pwm output to the release position
void release() override;
2013-12-17 00:59:14 -04:00
// grabbed - returns true if gripper in grabbed state
bool grabbed() const override;
// released - returns true if gripper in released state
bool released() const override;
// update - moves the pwm back to neutral after the timeout has passed
// should be called at at least 10hz
void update_gripper() override;
2013-12-17 00:59:14 -04:00
private:
// neutral - return the EPM pwm output to the neutral position
void neutral();
2016-06-23 20:48:29 -03:00
bool should_use_uavcan() const { return _uavcan_fd >= 0; }
struct UAVCANCommand make_uavcan_command(uint16_t command) const;
2016-06-23 20:48:29 -03:00
// UAVCAN driver fd
int _uavcan_fd = -1;
// internal variables
uint32_t _last_grab_or_release;
2013-12-17 00:59:14 -04:00
};