Skip to content

Commit a2a2428

Browse files
committedMar 15, 2019
Add NavX Reader Code
Tested - Robby S
1 parent 7cd39a9 commit a2a2428

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed
 

‎src/main/cpp/Robot.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ DriveSandstormStepWithHatch* Robot::m_DriveSandstormStepWithHatch;
4343
// Initialize JSON reader
4444
wpi::json Robot::m_JsonConfig;
4545

46+
// NavX
47+
AHRS Robot::m_AHRS{kNavxPin};
48+
4649
Robot::Robot() {
4750
// get the json config deployed onto the roborio
4851
std::ifstream jsonStream(CONFIGPATH);
@@ -124,6 +127,8 @@ void Robot::RobotPeriodic() {
124127
}
125128
m_UsingCamera1 = !m_UsingCamera1;
126129
}
130+
131+
std::cout << "Pitch: " << m_AHRS.GetPitch() << "\tRoll: " << m_AHRS.GetRoll() << "\tYaw: " << m_AHRS.GetYaw() << std::endl;
127132
}
128133

129134
void Robot::DisabledInit() {

‎src/main/include/Robot.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@
4343
#include "OI.h"
4444
#include "RobotMap.h"
4545

46+
// NavX
47+
#include "AHRS.h"
48+
4649
class Robot : public frc::TimedRobot {
4750
public:
4851
// Operator Interface
49-
static OI m_OI;
52+
static OI m_OI;
5053

5154
// Subsystems
5255
static DriveTrain* m_DriveTrain;
@@ -80,6 +83,9 @@ class Robot : public frc::TimedRobot {
8083

8184
// JSON Reader for Config (this should probably be moved later)
8285
static wpi::json m_JsonConfig;
86+
87+
// NavX
88+
static AHRS m_AHRS;
8389

8490
Robot();
8591
void RobotInit() override;

‎src/main/include/RobotMap.h

+1
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,5 @@
150150
// Cargo hatch cheesecake
151151
# define kCargoHatchCheesecakeMotor PWM_3
152152

153+
# define kNavxPin I2C::Port::kMXP
153154
#endif

‎vendordeps/navx_frc.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"fileName": "navx_frc.json",
3+
"name": "KauaiLabs_navX_FRC",
4+
"version": "3.1.366",
5+
"uuid": "cb311d09-36e9-4143-a032-55bb2b94443b",
6+
"mavenUrls": [
7+
"https://repo1.maven.org/maven2/"
8+
],
9+
"jsonUrl": "https://www.kauailabs.com/dist/frc/2019/navx_frc.json",
10+
"javaDependencies": [
11+
{
12+
"groupId": "com.kauailabs.navx.frc",
13+
"artifactId": "navx-java",
14+
"version": "3.1.366"
15+
}
16+
],
17+
"jniDependencies": [],
18+
"cppDependencies": [
19+
{
20+
"groupId": "com.kauailabs.navx.frc",
21+
"artifactId": "navx-cpp",
22+
"version": "3.1.366",
23+
"headerClassifier": "headers",
24+
"sourcesClassifier": "sources",
25+
"sharedLibrary": false,
26+
"libName": "navx_frc",
27+
"skipInvalidPlatforms": true,
28+
"binaryPlatforms": [
29+
"linuxathena"
30+
]
31+
}
32+
]
33+
}

0 commit comments

Comments
 (0)
Please sign in to comment.