2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) FIRST 2008. All Rights Reserved. */
|
|
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
2014-05-02 17:54:01 -04:00
|
|
|
#pragma once
|
2013-12-15 18:30:16 -05:00
|
|
|
|
|
|
|
|
#include "SafePWM.h"
|
|
|
|
|
#include "SpeedController.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Standard hobby style servo.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* The range parameters default to the appropriate values for the Hitec HS-322HD servo provided
|
|
|
|
|
* in the FIRST Kit of Parts in 2008.
|
|
|
|
|
*/
|
|
|
|
|
class Servo : public SafePWM
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit Servo(uint32_t channel);
|
|
|
|
|
virtual ~Servo();
|
|
|
|
|
void Set(float value);
|
|
|
|
|
void SetOffline();
|
|
|
|
|
float Get();
|
|
|
|
|
void SetAngle(float angle);
|
|
|
|
|
float GetAngle();
|
2014-05-02 17:54:01 -04:00
|
|
|
static float GetMaxAngle()
|
|
|
|
|
{
|
|
|
|
|
return kMaxServoAngle;
|
|
|
|
|
}
|
|
|
|
|
static float GetMinAngle()
|
|
|
|
|
{
|
|
|
|
|
return kMinServoAngle;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
|
|
|
|
|
void UpdateTable();
|
|
|
|
|
void StartLiveWindowMode();
|
|
|
|
|
void StopLiveWindowMode();
|
|
|
|
|
std::string GetSmartDashboardType();
|
|
|
|
|
void InitTable(ITable *subTable);
|
|
|
|
|
ITable * GetTable();
|
2014-05-02 17:54:01 -04:00
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
ITable *m_table;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void InitServo();
|
2014-05-02 17:54:01 -04:00
|
|
|
float GetServoAngleRange()
|
|
|
|
|
{
|
|
|
|
|
return kMaxServoAngle - kMinServoAngle;
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2014-05-30 14:19:57 -04:00
|
|
|
static constexpr float kMaxServoAngle = 180.0;
|
2013-12-15 18:30:16 -05:00
|
|
|
static constexpr float kMinServoAngle = 0.0;
|
2014-05-30 14:19:57 -04:00
|
|
|
|
|
|
|
|
static constexpr float kDefaultMaxServoPWM = 2.4;
|
|
|
|
|
static constexpr float kDefaultMinServoPWM = .6;
|
2013-12-15 18:30:16 -05:00
|
|
|
};
|