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
|
2014-09-17 03:00:46 -03:00
|
|
|
*
|
2019-12-08 17:23:32 -04:00
|
|
|
* 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
|
2016-02-17 21:25:21 -04:00
|
|
|
#pragma once
|
2013-12-17 00:59:14 -04:00
|
|
|
|
2016-10-29 08:01:18 -03:00
|
|
|
#include "AP_Gripper.h"
|
|
|
|
#include "AP_Gripper_Backend.h"
|
|
|
|
|
2017-01-06 21:06:40 -04:00
|
|
|
#include <SRV_Channel/SRV_Channel.h>
|
2014-09-15 03:51:06 -03:00
|
|
|
|
2014-09-17 03:00:46 -03:00
|
|
|
#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
|
|
|
|
2016-10-29 08:01:18 -03:00
|
|
|
/// @class AP_Gripper_EPM
|
2013-12-17 00:59:14 -04:00
|
|
|
/// @brief Class to manage the EPM_CargoGripper
|
2016-10-29 08:01:18 -03:00
|
|
|
class AP_Gripper_EPM : public AP_Gripper_Backend {
|
2013-12-17 00:59:14 -04:00
|
|
|
public:
|
2016-10-29 08:01:18 -03:00
|
|
|
AP_Gripper_EPM(struct AP_Gripper::Backend_Config &_config);
|
2013-12-17 00:59:14 -04:00
|
|
|
|
2014-09-17 03:00:46 -03:00
|
|
|
// initialise the EPM
|
2016-10-29 08:01:18 -03:00
|
|
|
void init_gripper() override;
|
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
|
2016-10-29 08:01:18 -03:00
|
|
|
void grab() override;
|
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
|
2016-10-29 08:01:18 -03:00
|
|
|
void release() override;
|
2013-12-17 00:59:14 -04:00
|
|
|
|
2016-11-17 23:12:58 -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;
|
|
|
|
|
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
|
2016-10-29 08:01:18 -03:00
|
|
|
void update_gripper() override;
|
2013-12-17 00:59:14 -04:00
|
|
|
|
|
|
|
private:
|
2014-09-17 03:00:46 -03:00
|
|
|
|
|
|
|
// 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; }
|
|
|
|
|
2016-10-29 08:01:18 -03:00
|
|
|
struct UAVCANCommand make_uavcan_command(uint16_t command) const;
|
2014-09-17 03:00:46 -03:00
|
|
|
|
2016-06-23 20:48:29 -03:00
|
|
|
// UAVCAN driver fd
|
|
|
|
int _uavcan_fd = -1;
|
|
|
|
|
2014-09-15 03:51:06 -03:00
|
|
|
// internal variables
|
|
|
|
uint32_t _last_grab_or_release;
|
2013-12-17 00:59:14 -04:00
|
|
|
};
|