generated from wpilibsuite/vendor-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
105 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
// #include "encoders/CanAndCoderSwerve.h" | ||
|
||
// namespace yagsl | ||
// { | ||
// CanAndCoderSwerve::CanAndCoderSwerve(int canid) | ||
// : encoder(canid) | ||
// { | ||
// } | ||
|
||
// void CanAndCoderSwerve::FactoryDefault() | ||
// { | ||
// encoder.resetFactoryDefaults(false); | ||
// } | ||
|
||
// void CanAndCoderSwerve::ClearStickyFaults() | ||
// { | ||
// encoder.clearStickyFaults(); | ||
// } | ||
|
||
// void CanAndCoderSwerve::Configure(bool inverted) | ||
// { | ||
// encoder.setSettings(Canandcoder::Settings().setInvertDirection(inverted)); | ||
// } | ||
|
||
// double CanAndCoderSwerve::GetAbsolutePosition() const | ||
// { | ||
// return encoder.getAbsPosition() * 360.0; | ||
// } | ||
|
||
// void *CanAndCoderSwerve::GetAbsoluteEncoder() const | ||
// { | ||
// return &encoder; | ||
// } | ||
|
||
// bool CanAndCoderSwerve::SetAbsoluteEncoderOffset(double offset) | ||
// { | ||
// return encoder.setSettings(Canandcoder::Settings().setZeroOffset(offset)); | ||
// } | ||
|
||
// double CanAndCoderSwerve::GetVelocity() | ||
// { | ||
// return encoder.getVelocity() * 360.0; | ||
// } | ||
|
||
// } // namespace yagsl | ||
#include "encoders/CanAndCoderSwerve.h" | ||
|
||
namespace yagsl | ||
{ | ||
CanAndCoderSwerve::CanAndCoderSwerve(int canid) | ||
: encoder(canid) | ||
{ | ||
} | ||
|
||
void CanAndCoderSwerve::FactoryDefault() | ||
{ | ||
encoder.resetFactoryDefaults(false); | ||
} | ||
|
||
void CanAndCoderSwerve::ClearStickyFaults() | ||
{ | ||
encoder.clearStickyFaults(); | ||
} | ||
|
||
void CanAndCoderSwerve::Configure(bool inverted) | ||
{ | ||
encoder.setSettings(Canandcoder::Settings().setInvertDirection(inverted)); | ||
} | ||
|
||
double CanAndCoderSwerve::GetAbsolutePosition() const | ||
{ | ||
return encoder.getAbsPosition() * 360.0; | ||
} | ||
|
||
void *CanAndCoderSwerve::GetAbsoluteEncoder() const | ||
{ | ||
return &encoder; | ||
} | ||
|
||
bool CanAndCoderSwerve::SetAbsoluteEncoderOffset(double offset) | ||
{ | ||
return encoder.setSettings(Canandcoder::Settings().setZeroOffset(offset)); | ||
} | ||
|
||
double CanAndCoderSwerve::GetVelocity() | ||
{ | ||
return encoder.getVelocity() * 360.0; | ||
} | ||
|
||
} // namespace yagsl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,71 @@ | ||
// #pragma once | ||
#pragma once | ||
|
||
// #include "SwerveAbsoluteEncoder.h" | ||
// #include <Canandcoder.h> | ||
#include "SwerveAbsoluteEncoder.h" | ||
#include <Canandcoder.h> | ||
|
||
// namespace yagsl | ||
// { | ||
// /** | ||
// * @brief HELIUM Canandcoder from ReduxRobotics absolute encoder, attached through the CAN bus. | ||
// */ | ||
// class CanAndCoderSwerve : public SwerveAbsoluteEncoder | ||
// { | ||
// public: | ||
// /** | ||
// * @brief Create the Canandcoder. | ||
// * | ||
// * @param canid The CAN ID whenever the CANandCoder is operating on the CANBus. | ||
// */ | ||
// CanAndCoderSwerve(int canid); | ||
namespace yagsl | ||
{ | ||
/** | ||
* @brief HELIUM Canandcoder from ReduxRobotics absolute encoder, attached through the CAN bus. | ||
*/ | ||
class CanAndCoderSwerve : public SwerveAbsoluteEncoder | ||
{ | ||
public: | ||
/** | ||
* @brief Create the Canandcoder. | ||
* | ||
* @param canid The CAN ID whenever the CANandCoder is operating on the CANBus. | ||
*/ | ||
CanAndCoderSwerve(int canid); | ||
|
||
// /** | ||
// * @brief Reset the encoder to factory defaults. This will not clear the stored zero offset. | ||
// */ | ||
// void FactoryDefault() override; | ||
/** | ||
* @brief Reset the encoder to factory defaults. This will not clear the stored zero offset. | ||
*/ | ||
void FactoryDefault() override; | ||
|
||
// /** | ||
// * @brief Clear sticky faults on the encoder. | ||
// */ | ||
// void ClearStickyFaults() override; | ||
/** | ||
* @brief Clear sticky faults on the encoder. | ||
*/ | ||
void ClearStickyFaults() override; | ||
|
||
// /** | ||
// * @brief Configure the Canandcoder to read from [0, 360) per second. | ||
// * | ||
// * @param inverted Whether the encoder is inverted. | ||
// */ | ||
// void Configure(bool inverted) override; | ||
/** | ||
* @brief Configure the Canandcoder to read from [0, 360) per second. | ||
* | ||
* @param inverted Whether the encoder is inverted. | ||
*/ | ||
void Configure(bool inverted) override; | ||
|
||
// /** | ||
// * @brief Get the absolute position of the encoder. | ||
// * | ||
// * @return Absolute position in degrees from [0, 360). | ||
// */ | ||
// double GetAbsolutePosition() const override; | ||
/** | ||
* @brief Get the absolute position of the encoder. | ||
* | ||
* @return Absolute position in degrees from [0, 360). | ||
*/ | ||
double GetAbsolutePosition() const override; | ||
|
||
// /** | ||
// * @brief Get the instantiated absolute encoder Object. | ||
// * | ||
// * @return Pointer to the absolute encoder object. | ||
// */ | ||
// void *GetAbsoluteEncoder() const override; | ||
/** | ||
* @brief Get the instantiated absolute encoder Object. | ||
* | ||
* @return Pointer to the absolute encoder object. | ||
*/ | ||
void *GetAbsoluteEncoder() const override; | ||
|
||
// /** | ||
// * @brief Set the offset of the Canandcoder. | ||
// * | ||
// * @param offset The offset the Absolute Encoder uses as the zero point. | ||
// * @return true if setting the zero point succeeded, false otherwise. | ||
// */ | ||
// bool SetAbsoluteEncoderOffset(double offset) override; | ||
/** | ||
* @brief Set the offset of the Canandcoder. | ||
* | ||
* @param offset The offset the Absolute Encoder uses as the zero point. | ||
* @return true if setting the zero point succeeded, false otherwise. | ||
*/ | ||
bool SetAbsoluteEncoderOffset(double offset) override; | ||
|
||
// /** | ||
// * @brief Get the velocity in degrees/sec. | ||
// * | ||
// * @return Velocity in degrees/sec. | ||
// */ | ||
// double GetVelocity() override; | ||
/** | ||
* @brief Get the velocity in degrees/sec. | ||
* | ||
* @return Velocity in degrees/sec. | ||
*/ | ||
double GetVelocity() override; | ||
|
||
// private: | ||
// Canandcoder encoder; | ||
// }; | ||
private: | ||
Canandcoder encoder; | ||
}; | ||
|
||
// } // namespace yagsl | ||
} // namespace yagsl |