mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Add gyro and accelerometer simulator wrappers (#1183)
This commit is contained in:
committed by
Peter Johnson
parent
0a0d9245e2
commit
c2ceebfb9c
@@ -0,0 +1,52 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. 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 the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "lowfisim/wpisimulators/ADXLThreeAxisAccelerometerSim.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
namespace lowfi {
|
||||
|
||||
ADXLThreeAxisAccelerometerSim::ADXLThreeAxisAccelerometerSim(
|
||||
hal::ThreeAxisAccelerometerData& accelerometerWrapper)
|
||||
: m_accelerometerWrapper(accelerometerWrapper),
|
||||
m_xWrapper(std::function<void(double)>(
|
||||
std::bind(&hal::ThreeAxisAccelerometerData::SetX,
|
||||
&m_accelerometerWrapper, std::placeholders::_1)),
|
||||
std::function<double(void)>(
|
||||
std::bind(&hal::ThreeAxisAccelerometerData::GetX,
|
||||
&m_accelerometerWrapper))),
|
||||
|
||||
m_yWrapper(std::function<void(double)>(
|
||||
std::bind(&hal::ThreeAxisAccelerometerData::SetY,
|
||||
&m_accelerometerWrapper, std::placeholders::_1)),
|
||||
std::function<double(void)>(
|
||||
std::bind(&hal::ThreeAxisAccelerometerData::GetY,
|
||||
&m_accelerometerWrapper))),
|
||||
|
||||
m_zWrapper(std::function<void(double)>(
|
||||
std::bind(&hal::ThreeAxisAccelerometerData::SetZ,
|
||||
&m_accelerometerWrapper, std::placeholders::_1)),
|
||||
std::function<double(void)>(
|
||||
std::bind(&hal::ThreeAxisAccelerometerData::GetZ,
|
||||
&m_accelerometerWrapper))) {}
|
||||
|
||||
AccelerometerSim& ADXLThreeAxisAccelerometerSim::GetXWrapper() {
|
||||
return m_xWrapper;
|
||||
}
|
||||
|
||||
AccelerometerSim& ADXLThreeAxisAccelerometerSim::GetYWrapper() {
|
||||
return m_yWrapper;
|
||||
}
|
||||
|
||||
AccelerometerSim& ADXLThreeAxisAccelerometerSim::GetZWrapper() {
|
||||
return m_zWrapper;
|
||||
}
|
||||
|
||||
} // namespace lowfi
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
@@ -0,0 +1,25 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. 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 the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "lowfisim/wpisimulators/ADXRS450_SpiGyroSim.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
namespace lowfi {
|
||||
|
||||
ADXRS450_SpiGyroSim::ADXRS450_SpiGyroSim(int spiPort)
|
||||
: m_gyroWrapper(spiPort) {}
|
||||
|
||||
void ADXRS450_SpiGyroSim::SetAngle(double angle) {
|
||||
m_gyroWrapper.SetAngle(angle);
|
||||
}
|
||||
|
||||
double ADXRS450_SpiGyroSim::GetAngle() { return m_gyroWrapper.GetAngle(); }
|
||||
|
||||
} // namespace lowfi
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
@@ -0,0 +1,24 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. 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 the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "lowfisim/wpisimulators/WpiAnalogGyroSim.h"
|
||||
|
||||
namespace frc {
|
||||
namespace sim {
|
||||
namespace lowfi {
|
||||
|
||||
WpiAnalogGyroSim::WpiAnalogGyroSim(int index) : m_gyroSimulator(index) {}
|
||||
|
||||
void WpiAnalogGyroSim::SetAngle(double angle) {
|
||||
m_gyroSimulator.SetAngle(angle);
|
||||
}
|
||||
|
||||
double WpiAnalogGyroSim::GetAngle() { return m_gyroSimulator.GetAngle(); }
|
||||
|
||||
} // namespace lowfi
|
||||
} // namespace sim
|
||||
} // namespace frc
|
||||
Reference in New Issue
Block a user