-
Notifications
You must be signed in to change notification settings - Fork 2
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
206 changed files
with
27,699 additions
and
2 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
Empty file.
Empty file.
Empty file.
Empty file.
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* \file api.h | ||
* | ||
* PROS API header provides high-level user functionality | ||
* | ||
* Contains declarations for use by typical VEX programmers using PROS. | ||
* | ||
* This file should not be modified by users, since it gets replaced whenever | ||
* a kernel upgrade occurs. | ||
* | ||
* Copyright (c) 2017-2018, Purdue University ACM SIGBots. | ||
* All rights reserved. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef _PROS_API_H_ | ||
#define _PROS_API_H_ | ||
|
||
#ifdef __cplusplus | ||
#include <cerrno> | ||
#include <cmath> | ||
#include <cstdbool> | ||
#include <cstddef> | ||
#include <cstdint> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <iostream> | ||
#else /* (not) __cplusplus */ | ||
#include <errno.h> | ||
#include <math.h> | ||
#include <stdbool.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#endif /* __cplusplus */ | ||
|
||
#define PROS_VERSION_MAJOR 3 | ||
#define PROS_VERSION_MINOR 1 | ||
#define PROS_VERSION_PATCH 6 | ||
#define PROS_VERSION_STRING "3.1.6" | ||
|
||
#define PROS_ERR (INT32_MAX) | ||
#define PROS_ERR_F (INFINITY) | ||
|
||
#include "pros/adi.h" | ||
#include "pros/colors.h" | ||
#include "pros/llemu.h" | ||
#include "pros/misc.h" | ||
#include "pros/motors.h" | ||
#include "pros/rtos.h" | ||
#include "pros/vision.h" | ||
|
||
#ifdef __cplusplus | ||
#include "pros/adi.hpp" | ||
#include "pros/llemu.hpp" | ||
#include "pros/misc.hpp" | ||
#include "pros/motors.hpp" | ||
#include "pros/rtos.hpp" | ||
#include "pros/vision.hpp" | ||
#endif | ||
|
||
#endif // _PROS_API_H_ |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#pragma once | ||
#include "autolib/auto/pathGeneratorMath.hpp" | ||
#include "autolib/util/messages.hpp" | ||
#include "okapi/api/units/QLength.hpp" | ||
#include "okapi/api/util/mathUtil.hpp" | ||
#include <vector> | ||
#include <cmath> | ||
|
||
#define DEBUG | ||
|
||
namespace autolib{ | ||
|
||
class PathGenerator{ | ||
public: | ||
|
||
/** | ||
* This is the constructor for the Path Generator class. To initialize, a list of autolib::Points, and a okapi::QLength | ||
* value. Each value in the initializer_list is a autolib::Point. For more information on those check out the | ||
* autolib/util/messages.hpp file. The next field is the minimum distance between each point generated on the path. | ||
* The smaller this value is, the more points will be generated. However, for each point generated it will take | ||
* microseconds longer to calculate a path. We suggest a distance roughly equal to 1_mm or 1 millimeter. To use okapi's | ||
* QLength you send a number such as 1 or 2.3 but after send a _distance ie: 3.471_in. To get a list of these distances, | ||
* visit: https://pros.cs.purdue.edu/v5/okapi/api/units/index.html | ||
* | ||
* @param std::initializer_list<Point> &iwaypoints | ||
* example: { autolib::Point{ 1_ft, 2_ft }, autolib::Point{ -5_ft, 3_ft } } | ||
* @param okapi::QLength &iminDistanceBetweenPoints | ||
* example: 1_mm | ||
* | ||
*/ | ||
PathGenerator( const std::initializer_list<Point> &iwaypoints, | ||
const okapi::QLength &iminDistanceBetweenPoints); | ||
|
||
~PathGenerator(){} | ||
|
||
/** | ||
* This enumeration is to tell the generatePath method what kind of path it is generating. The HermiteSplinePath is meant | ||
* for smoothing the points on the path, while StraightInterpolation is just filling inbetween the dots. Both methods work, | ||
* but HermiteSpline is more complicated with a better return while StraightInterpolation is simpler and manageable. | ||
* | ||
* Note: If you don't know what a HermiteSpline and have no intention to learn what it is then use StraightInterpolation, | ||
* if you want to learn what it is check out the wiki. | ||
*/ | ||
enum PathType{ HermiteSpline, StraightInterpolation, None }; | ||
|
||
/** | ||
* This method will fill in the points between the waypoints that you generate based off of the PathType that you send. | ||
* Currently only HermiteSpline is working. | ||
* | ||
* @param const PathType &pathType | ||
* example autolib::PathType::HermiteSpline | ||
*/ | ||
void generatePath( const PathType &pathType ); | ||
|
||
/** | ||
* This will show you the path that is generated. Use the pros terminal to see the points. | ||
*/ | ||
void showPath(); | ||
|
||
/** | ||
* Use this to initialize the Pure Pursuit class. | ||
* | ||
* @return InternalPath path | ||
* example: PurePursuit purePursuit( pathGenerator.getPath(), 1_ft ); | ||
*/ | ||
InternalPath getPath(); | ||
|
||
/** | ||
* This is a method used for debugging purposes. Use the pros terminal to see the output. | ||
*/ | ||
void debugHermiteSpline(); | ||
|
||
protected: | ||
InternalPath waypoints; | ||
InternalPath path; | ||
double minDistanceBetweenPoints; | ||
}; | ||
}//autolib |
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#pragma once | ||
#include "autolib/util/messages.hpp" | ||
#include "okapi/api/units/QLength.hpp" | ||
#include "okapi/api/util/mathUtil.hpp" | ||
#include <vector> | ||
#include <cmath> | ||
|
||
#define DEBUG | ||
|
||
namespace autolib{ | ||
|
||
class HermiteSplineMath{ | ||
public: | ||
/** | ||
* | ||
* @param {double} iminLength : | ||
* @param {InternalPoint} P1 : | ||
* @param {InternalPoint} M1 : | ||
* @param {InternalPoint} P2 : | ||
* @param {InternalPoint} M2 : | ||
* @return {InternalPoint} : | ||
*/ | ||
static InternalPoint findNextPoint( const double &iminLength, const InternalPoint &P1, const InternalPoint &M1, const InternalPoint &P2, const InternalPoint &M2 ); | ||
/** | ||
* | ||
* @param {double} ih00 : | ||
* @return {double} : | ||
*/ | ||
static double h00( const double &ih00 ); | ||
/** | ||
* | ||
* @param {double} ih10 : | ||
* @return {double} : | ||
*/ | ||
static double h10( const double &ih10 ); | ||
/** | ||
* | ||
* @param {double} ih01 : | ||
* @return {double} : | ||
*/ | ||
static double h01( const double &ih01 ); | ||
/** | ||
* | ||
* @param {double} ih11 : | ||
* @return {double} : | ||
*/ | ||
static double h11( const double &ih11 ); | ||
/** | ||
* | ||
* @param {double} iminLength : | ||
* @param {InternalPoint} P1 : | ||
* @param {InternalPoint} M1 : | ||
* @param {InternalPoint} P2 : | ||
* @param {InternalPoint} M2 : | ||
*/ | ||
static void debug( double iminLength, const InternalPoint &P1, const InternalPoint &M1, const InternalPoint &P2, const InternalPoint &M2 ); | ||
}; | ||
|
||
class StraightInterpolationMath{ | ||
public: | ||
/** | ||
* | ||
* @param {InternalPoint} lastGeneratedPoint : | ||
* @param {double} ixDistanceBetweenPoints : | ||
* @param {InternalPoint} P1 : | ||
* @param {InternalPoint} P2 : | ||
* @return {InternalPoint} : | ||
*/ | ||
static InternalPoint findNextPoint( const InternalPoint &lastGeneratedPoint, const double &ixDistanceBetweenPoints, const InternalPoint &P1, const InternalPoint &P2); | ||
/** | ||
* | ||
* @param {double} ixDistanceBetweenPoints : | ||
* @param {InternalPoint} P1 : | ||
* @param {InternalPoint} P2 : | ||
* @return {double} : | ||
*/ | ||
static double findRise(const double &ixDistanceBetweenPoints, const InternalPoint &P1, const InternalPoint &P2); | ||
|
||
}; | ||
|
||
}//autolib |
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#pragma once | ||
#include "autolib/util/messages.hpp" | ||
#include "autolib/auto/pathGenerator.hpp" | ||
#include "autolib/auto/purePursuitMath.hpp" | ||
#include "okapi/api/units/QLength.hpp" | ||
#include "okapi/api/units/RQuantity.hpp" | ||
#include <memory> | ||
#include <vector> | ||
#include <cmath> | ||
//* | ||
|
||
#define DEBUG | ||
|
||
namespace autolib{ | ||
|
||
class PurePursuit { | ||
public: | ||
|
||
|
||
/** | ||
* PurePursuit | ||
* This is the constructor for PurePursuit. The first param is an InternalPath which should be generated by | ||
* PathGenerator's getPath() method. The second param is the lookaheadDistance of the Pure Pursuit algorithm. | ||
* | ||
* @param {InternalPath} ipath : | ||
* example: pathGenerator.getPath() | ||
* @param {okapi::QLength} ilookaheadDistance : | ||
* example: 1_ft | ||
*/ | ||
PurePursuit( const InternalPath &ipath, const okapi::QLength &ilookaheadDistance ); | ||
|
||
/** | ||
* This should be run in a loop during your autonomous. The input is the x, y, and theta in global coordinates | ||
* of where your robot is currently located. This can be calculated using okapi's odometry feature. To access | ||
* that feature go the the feature/odometry branch on github until the official release of it. | ||
* | ||
* @param {okapi::QLength} ix : | ||
* example: exampleVariable * foot | ||
* @param {okapi::QLength} iy : | ||
* example: exampleVariable * inch | ||
* @param {okapi::QAngle} itheta : | ||
* example: exampleVariable * degree | ||
* @return {Curvature} : | ||
* example: ask me | ||
*/ | ||
Curvature getGoalCurvature( const okapi::QLength &ix , const okapi::QLength &iy, const okapi::QAngle &itheta ); | ||
|
||
protected: | ||
const bool debug = true; | ||
InternalPath path; | ||
InternalPath possiblePoints; | ||
InternalPoint currentPoint{0,0}; | ||
InternalPoint nearestPoint{0,0}; | ||
InternalPoint lastNearestPoint{0,0}; | ||
InternalPoint goalPoint{0,0}; | ||
InternalPoint localGoalPoint{0,0}; | ||
double lookaheadDistance; | ||
double theta; | ||
bool checkLastPointBool = true; | ||
|
||
/** | ||
* | ||
* @param {okapi::QLength} ix : | ||
* @param {okapi::QLength} iy : | ||
* @return {InternalPoint} : | ||
*/ | ||
InternalPoint getNearestPoint( const okapi::QLength &ix , const okapi::QLength &iy ); | ||
}; | ||
|
||
}//autolib | ||
//*/ |
Oops, something went wrong.