From 15a7ee4cae6db05ab45147c8c821474ee0946620 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Sat, 6 Feb 2016 14:04:20 -0500 Subject: [PATCH 1/9] added more includes because I will need to do things like moving strings around, knowing what time it is, and vectors, because we already have enough spagetti. --- DriveBase/src/Robot.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/DriveBase/src/Robot.cpp b/DriveBase/src/Robot.cpp index 4a8ad95..1deee2e 100644 --- a/DriveBase/src/Robot.cpp +++ b/DriveBase/src/Robot.cpp @@ -1,6 +1,14 @@ #include "WPILib.h" #include "TankDrive.h" #include "Shooter.h" +#include +#include +#include +#include +#include +#include +#include +#include /** * This sample shows how to use the new CANTalon to just run a motor in a basic From d9137085c3f2550f5607320ab1450d29b8c9998c Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Sat, 6 Feb 2016 15:30:45 -0500 Subject: [PATCH 2/9] moar reformatting --- DriveBase/src/Robot.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/DriveBase/src/Robot.cpp b/DriveBase/src/Robot.cpp index 1deee2e..ae5a399 100644 --- a/DriveBase/src/Robot.cpp +++ b/DriveBase/src/Robot.cpp @@ -17,12 +17,9 @@ * */ class Robot: public IterativeRobot { - CANTalon r1_drive; - CANTalon r2_drive; - CANTalon l1_drive; - CANTalon l2_drive; - CANTalon shooter1; - CANTalon shooter2; + CANTalon r1_drive, r2_drive, + l1_drive, l2_drive, + shooter1, shooter2; TankDrive drive; Shooter shooter; Joystick rstick, lstick; From 370dc154c6b91aa60c274af6a0193ed25799063e Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Mon, 8 Feb 2016 18:43:18 -0500 Subject: [PATCH 3/9] started migrating LogData() from last year. not operational --- DriveBase/src/Robot.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/DriveBase/src/Robot.cpp b/DriveBase/src/Robot.cpp index ae5a399..55350c5 100644 --- a/DriveBase/src/Robot.cpp +++ b/DriveBase/src/Robot.cpp @@ -16,10 +16,12 @@ * controlled motor. * */ -class Robot: public IterativeRobot { +class Robot: public IterativeRobot +{ +private: CANTalon r1_drive, r2_drive, - l1_drive, l2_drive, - shooter1, shooter2; + l1_drive, l2_drive, + shooter1, shooter2; TankDrive drive; Shooter shooter; Joystick rstick, lstick; @@ -28,6 +30,12 @@ class Robot: public IterativeRobot { // The talon only receives control packets every 10ms. //double kUpdatePeriod = 0.010; + void LogData() + { + static PowerDistributionPanel pdp; + static DriverStation* ds = + } + public: Robot() : r1_drive(1), // right wheel 1 From 9ae56635ce90bd36fcd086fe85fa046e8e981803 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Wed, 10 Feb 2016 20:43:09 -0500 Subject: [PATCH 4/9] Lots of includes and a LogData() embryo --- Robot2016/src/Robot.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Robot2016/src/Robot.cpp b/Robot2016/src/Robot.cpp index 4913f17..2766c38 100644 --- a/Robot2016/src/Robot.cpp +++ b/Robot2016/src/Robot.cpp @@ -47,6 +47,12 @@ private: const std::string autoNameCustom = "My Auto"; std::string autoSelected; + void LogData() + { + static PowerDistributionPanel pdp; + static DriverStation* ds = DriverStation::GetInstance(); + } + void RobotInit() { chooser = new SendableChooser(); From 3be566a2be13c0d41292d408a096b0644148cfb1 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Wed, 10 Feb 2016 20:43:45 -0500 Subject: [PATCH 5/9] Lots of includes (for real this time) and a LogData() embryo --- Robot2016/src/Robot.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Robot2016/src/Robot.cpp b/Robot2016/src/Robot.cpp index 2766c38..c4aff98 100644 --- a/Robot2016/src/Robot.cpp +++ b/Robot2016/src/Robot.cpp @@ -1,5 +1,13 @@ #include "WPILib.h" #include "Shooter.h" +#include +#include +#include +#include +#include +#include +#include +#include #ifndef BUTTON_LAYOUT #define BUTTON_LAYOUT From 35cd776a482547469974d35bf8c67a31e35f7547 Mon Sep 17 00:00:00 2001 From: Aidan Ferguson Date: Wed, 10 Feb 2016 21:19:18 -0500 Subject: [PATCH 6/9] more of LogData(). still not done, but I'm tired. --- Robot2016/src/Robot.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Robot2016/src/Robot.cpp b/Robot2016/src/Robot.cpp index c4aff98..d6cf381 100644 --- a/Robot2016/src/Robot.cpp +++ b/Robot2016/src/Robot.cpp @@ -59,6 +59,15 @@ private: { static PowerDistributionPanel pdp; static DriverStation* ds = DriverStation::GetInstance(); + static DriverStation* ds = DriverStation::GetInstance(); + static std::vector motors; + + static std::ofstream logA, logB, logC; + timeval tm; + + SmartDashboard::PutBoolean("log A", logA.is_open()); + SmartDashboard::PutBoolean("log B", logB.is_open()); + SmartDashboard::PutBoolean("log C", logC.is_open()); } void RobotInit() From 4eb4ccb188f367dd1ae21e4e6b97b26f9e2410d9 Mon Sep 17 00:00:00 2001 From: john sandstedt Date: Sat, 20 Feb 2016 15:22:53 -0500 Subject: [PATCH 7/9] adam style csv logging code --- Robot2016/src/Robot.cpp | 88 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/Robot2016/src/Robot.cpp b/Robot2016/src/Robot.cpp index d6cf381..a72b64b 100644 --- a/Robot2016/src/Robot.cpp +++ b/Robot2016/src/Robot.cpp @@ -19,6 +19,10 @@ #endif // BUTTON_LAYOUT +#ifndef LOG +#define LOG(X) logA << X; logB << X; logC << X //for writing data to the csv file +#endif + class Robot: public IterativeRobot { Talon left_drive, right_drive; @@ -113,6 +117,7 @@ private: void AutonomousPeriodic() { + LogCSVData(); if(autoSelected == autoNameCustom){ //Custom Auto goes here } else { @@ -129,6 +134,7 @@ private: void TeleopPeriodic() { + LogCSVData(); std::cout << "Ramp position: "<< ramp.GetEncPosition() << std::endl; drive.ArcadeDrive(&driver_stick, true); @@ -179,6 +185,88 @@ private: void TestPeriodic() { lw->Run(); + LogCSVData(); + } + void LogCSVData() + { + static PowerDistributionPanel pdp; // preparing to read from the pdp + static DriverStation* ds = DriverStation::GetInstance(); + static std::vector motors; + + static std::ofstream logA, logB, logC; + timeval tm; + + SmartDashboard::PutBoolean("log A", logA.is_open()); + SmartDashboard::PutBoolean("log B", logB.is_open()); + SmartDashboard::PutBoolean("log C", logC.is_open()); + + if (!logA.is_open() && !logB.is_open() && !logC.is_open()) + { + std::fstream logNumFile; + int logNum; + logNumFile.open("/home/lvuser/logNum"); + logNumFile >> logNum; + logNum++; + logNumFile.seekp(0); + logNumFile << logNum; + // writing to /home/lvuser/logs/[unixtime].log + logA.open("/media/sda1/logs/log" + std::to_string(logNum) + ".csv"); + std::cerr << (logA.is_open() ? "Opened" : "Failed to open") << "log A." << std::endl; + logB.open("/media/sdb1/logs/log" + std::to_string(logNum) + ".csv"); + std::cerr << (logB.is_open() ? "Opened" : "Failed to open") << "log B." << std::endl; + logC.open("/home/lvuser/logs/log" + std::to_string(logNum) + ".csv"); + std::cerr << (logC.is_open() ? "Opened" : "Failed to open") << "log C." << std::endl; + + LOG("Time\tpdpInput voltage\tpdpTemperature\tpdpTotal Current\t"); + for (int ii = 0; ii < 16; ii++) + { + LOG("pdpChannel " << ii << " current\t"); + } + + LOG("tlaunch_spinny Bus Voltage\ttlaunch_spinny Output Current\ttlaunch_spinny Output Voltage\ttlaunch_spinny Temperature"); + motors.push_back(&ramp); + LOG("\tShooter1 Bus Voltage\tShooter1 Output Current\tShooter1 Output Voltage\tShooter1 Temperature"); + motors.push_back(&shooter1); + LOG("\tShooter2 Bus Voltage\tShooter2 Output Current\tShooter2 Output Voltage\tShooter2 Temperature"); + motors.push_back(&shooter2); + + LOG("\tJoystick X\tJoystick Y\tJoystick Twist"); + LOG("\tAlliance\tLocation\tMatch Time\tFMS Attached\tBrowned Out"); + LOG("\tTestStage"); + LOG(std::endl); + } + gettimeofday(&tm, NULL); + LOG(time(0) << '.' << std::setfill('0') << std::setw(3) << tm.tv_usec/1000); + // Some general information + LOG("\t" << pdp.GetVoltage()); + LOG("\t" << pdp.GetTemperature()); + LOG("\t" << pdp.GetTotalCurrent()); + // current on each channel + for (int ii = 0; ii < 16; ii++) + { + LOG("\t" << pdp.GetCurrent(ii)); + } + + //Talon Data + for(int ii = 0; ii < motors.size(); ii++) + { + LOG("\t" << motors[ii]->GetBusVoltage()); + LOG("\t" << motors[ii]->GetOutputVoltage()); + LOG("\t" << motors[ii]->GetOutputCurrent()); + LOG("\t" << motors[ii]->GetTemperature()); + } + //control data + LOG("\t" << driver_stick.GetX()); + LOG("\t" << driver_stick.GetY()); + LOG("\t" << driver_stick.GetTwist()); + + //DriverStation Data + LOG("\t" << ds->GetAlliance()); + LOG("\t" << ds->GetLocation()); + LOG("\t" << ds->GetMatchTime()); + LOG("\t" << ds->IsFMSAttached()); + LOG("\t" << ds->IsSysBrownedOut()); + LOG(std::endl); } }; From 420a5723a73b695b418c1fd567281ce5553a6c92 Mon Sep 17 00:00:00 2001 From: john sandstedt Date: Mon, 22 Feb 2016 19:04:27 -0500 Subject: [PATCH 8/9] logging code... fixed the error initializing the DriverStation Object potentially, and fixed a few of the syntax errors ' --- Robot2016/src/Robot.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Robot2016/src/Robot.cpp b/Robot2016/src/Robot.cpp index a72b64b..e847442 100644 --- a/Robot2016/src/Robot.cpp +++ b/Robot2016/src/Robot.cpp @@ -31,6 +31,7 @@ class Robot: public IterativeRobot RobotDrive drive; Shooter shooter; Joystick driver_stick, operator_stick; + DriverStation ds; float power; public: Robot(): @@ -45,6 +46,7 @@ public: driver_stick(0), // right stick (operator) operator_stick(1) // left stick (driver) { + ds.GetInstance(); } @@ -59,11 +61,10 @@ private: const std::string autoNameCustom = "My Auto"; std::string autoSelected; - void LogData() + /*void LogData() { static PowerDistributionPanel pdp; - static DriverStation* ds = DriverStation::GetInstance(); - static DriverStation* ds = DriverStation::GetInstance(); + static DriverStation ds = DriverStation::GetInstance(); static std::vector motors; static std::ofstream logA, logB, logC; @@ -72,7 +73,7 @@ private: SmartDashboard::PutBoolean("log A", logA.is_open()); SmartDashboard::PutBoolean("log B", logB.is_open()); SmartDashboard::PutBoolean("log C", logC.is_open()); - } + }*/ void RobotInit() { @@ -190,7 +191,6 @@ private: void LogCSVData() { static PowerDistributionPanel pdp; // preparing to read from the pdp - static DriverStation* ds = DriverStation::GetInstance(); static std::vector motors; static std::ofstream logA, logB, logC; @@ -261,11 +261,11 @@ private: LOG("\t" << driver_stick.GetTwist()); //DriverStation Data - LOG("\t" << ds->GetAlliance()); - LOG("\t" << ds->GetLocation()); - LOG("\t" << ds->GetMatchTime()); - LOG("\t" << ds->IsFMSAttached()); - LOG("\t" << ds->IsSysBrownedOut()); + LOG("\t" << ds.GetAlliance()); + LOG("\t" << ds.GetLocation()); + LOG("\t" << ds.GetMatchTime()); + LOG("\t" << ds.IsFMSAttached()); + LOG("\t" << ds.IsSysBrownedOut()); LOG(std::endl); } }; From efbe261750e368ac186bde1558ede187f08f5cbe Mon Sep 17 00:00:00 2001 From: john sandstedt Date: Mon, 22 Feb 2016 19:13:09 -0500 Subject: [PATCH 9/9] potato... also maybe fixed driverstation::GetInstance() again potentially --- Robot2016/src/Robot.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Robot2016/src/Robot.cpp b/Robot2016/src/Robot.cpp index e847442..5e9beaf 100644 --- a/Robot2016/src/Robot.cpp +++ b/Robot2016/src/Robot.cpp @@ -31,7 +31,7 @@ class Robot: public IterativeRobot RobotDrive drive; Shooter shooter; Joystick driver_stick, operator_stick; - DriverStation ds; + //DriverStation DriverStation::GetInstance(); float power; public: Robot(): @@ -46,7 +46,7 @@ public: driver_stick(0), // right stick (operator) operator_stick(1) // left stick (driver) { - ds.GetInstance(); + //DriverStation::GetInstance().GetInstance(); } @@ -64,7 +64,7 @@ private: /*void LogData() { static PowerDistributionPanel pdp; - static DriverStation ds = DriverStation::GetInstance(); + static DriverStation DriverStation::GetInstance() = DriverStation::GetInstance(); static std::vector motors; static std::ofstream logA, logB, logC; @@ -261,11 +261,11 @@ private: LOG("\t" << driver_stick.GetTwist()); //DriverStation Data - LOG("\t" << ds.GetAlliance()); - LOG("\t" << ds.GetLocation()); - LOG("\t" << ds.GetMatchTime()); - LOG("\t" << ds.IsFMSAttached()); - LOG("\t" << ds.IsSysBrownedOut()); + LOG("\t" << DriverStation::GetInstance().GetAlliance()); + LOG("\t" << DriverStation::GetInstance().GetLocation()); + LOG("\t" << DriverStation::GetInstance().GetMatchTime()); + LOG("\t" << DriverStation::GetInstance().IsFMSAttached()); + LOG("\t" << DriverStation::GetInstance().IsSysBrownedOut()); LOG(std::endl); } };