Skip to content

Commit

Permalink
uncommented canandcocer
Browse files Browse the repository at this point in the history
  • Loading branch information
DanPeled committed Aug 28, 2024
1 parent a2316ce commit 8f4f369
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 105 deletions.
90 changes: 45 additions & 45 deletions src/main/native/cpp/encoders/CanAndCoderSwerve.cpp
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
120 changes: 60 additions & 60 deletions src/main/native/include/encoders/CanAndCoderSwerve.h
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

0 comments on commit 8f4f369

Please sign in to comment.