Skip to content

Commit

Permalink
Merge pull request #11 from Arctos6135/dev/2.1.1-dev
Browse files Browse the repository at this point in the history
Version 2.1.1!
  • Loading branch information
tylertian123 committed Jan 23, 2019
2 parents 8fc9dd9 + edb203f commit b44ea25
Show file tree
Hide file tree
Showing 22 changed files with 804 additions and 578 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: java

jdk:
- oraclejdk8
- openjdk8
- oraclejdk11
- openjdk11

Expand Down Expand Up @@ -30,12 +28,12 @@ after_success:
curl --request 'POST'
--header 'Content-Type: text/plain; charset=utf-8'
--data "✅ The latest commit pushed to **RobotPathfinder** (commit *$SHORT_COMMIT* on branch *$TRAVIS_BRANCH*) has **passed** CI checks on **$TRAVIS_JDK_VERSION**!"
https://arctos6135.ryver.com/application/webhook/DCrjbShXT4HvRtp
https://arctos6135.ryver.com/application/webhook/2EnmZwoD1TCAySR
after_failure:
- export SHORT_COMMIT=${TRAVIS_COMMIT:0:7}
- >
curl --request 'POST'
--header 'Content-Type: text/plain; charset=utf-8'
--data "❌ The latest commit pushed to **RobotPathfinder** (commit *$SHORT_COMMIT* on branch *$TRAVIS_BRANCH*) has **failed** CI checks on **$TRAVIS_JDK_VERSION**!"
https://arctos6135.ryver.com/application/webhook/DCrjbShXT4HvRtp
curl --request 'POST'
--header 'Content-Type: text/plain; charset=utf-8'
--data "❌ The latest commit pushed to **RobotPathfinder** (commit *$SHORT_COMMIT* on branch *$TRAVIS_BRANCH*) has **failed** CI checks on **$TRAVIS_JDK_VERSION**!"
https://arctos6135.ryver.com/application/webhook/2EnmZwoD1TCAySR
48 changes: 25 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RobotPathfinder
[![Build Status](https://travis-ci.com/Arctos6135/RobotPathfinder.svg?branch=dev%2Fmisc%2Ftravis)](https://travis-ci.com/Arctos6135/RobotPathfinder)
[![Build Status](https://travis-ci.com/Arctos6135/RobotPathfinder.svg?branch=master)](https://travis-ci.com/Arctos6135/RobotPathfinder)

Robot motion profiler/path planner for tank drive robots. Used and developed by <a href="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/Arctos6135">FRC Team 6135 (Arctos)</a>!<br>
Inspired by and partially based on <a href="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/JacisNonsense/Pathfinder">Pathfinder by Jaci Brunning</a>. <em>This project is in no way intended to be a copy or replacement for Pathfinder! Though a lot of it is based on Pathfinder, the two generators have their own pros and cons.</em><br>
Expand All @@ -13,10 +13,8 @@ Some of the highlights include:
* Follower class that can be set to follow position, velocity, acceleration and direction
* And much more...!

***All version 1 releases are deprecated; they contain serious design oversights that make them very inaccurate. Please use a version 2 release instead.***

## Purpose
Given an array of waypoints, each with coordinates and a heading, RobotPathfinder generates a smooth path that follows all the waypoints. Then, using that path, it generates left and right wheel trajectories for a robot to follow in order to achieve the desired path.
Given an array of waypoints, each with coordinates, a heading, and optionally a velocity, RobotPathfinder generates a smooth path that follows all the waypoints. Then, using that path, it generates left and right wheel trajectories for a robot to follow in order to achieve the desired path.

Example path:
![Path graph](http:https://tylertian123.github.io/images/RobotPathfinder/path1.png)<br>
Expand All @@ -26,43 +24,47 @@ These graphs are generated using <b>JMathPlot</b>. You can find its repository <
The program that generated this trajectory can be found under the `examples` directory as `TrajectoryGenerationDemo.java`.

## Usage
In every release, there will be 4 binaries:
* `RobotPathfinder-VERSION.jar` - The basic jar that contains the library, but without some dependencies. This is the jar recommended for use on a robot. It does not contain the dependencies required for graphing.
* `RobotPathfinder-VERSION-all.jar` - The fat jar that contains the library as well as all its dependencies.
* `Trajectory-Visualizer-VERSION.jar` - The executable jar that contains the GUI Trajectory Visualization Tool (and all its dependencies).
* `RobotPathfinder-Doc-VERSION.zip` - The zip that contains the JavaDocs for all classes and methods.
Every release contains 4 binaries:
* `RobotPathfinder-(VERSION).jar` - The basic jar that contains the library, but without some dependencies. This is the jar recommended for use on a robot. It does not contain the dependencies required for graphing.
* `RobotPathfinder-(VERSION)-all.jar` - The fat jar that contains the library as well as all its dependencies.
* `Trajectory-Visualizer-(VERSION).jar` - The executable jar that contains the GUI Trajectory Visualization Tool (and all its dependencies).
* `RobotPathfinder-Doc-(VERSION).zip` - The zip that contains the JavaDocs for all classes and methods.

Alternatively, you can build the binaries yourself by navigating to the root directory, and running `./gradlew allArchives`. (*If you're on a Windows machine, make sure you're using PowerShell not cmd!*) The jars and JavaDoc zip can then be found under the `output` directory.
Alternatively, you can build the binaries yourself by navigating to the root directory, and running `./gradlew allArchives --rerun-tasks`. (*If you're on a Windows machine, make sure you're using PowerShell not cmd!*) The jars and JavaDoc zip can then be found under the `output` directory.

**If you're using it in the First Robotics Competition:**\
**FRC Usage:**\
In addition to adding the library jar to your build path, you must also put a copy/simlink of the jar in the WPILib Java libraries directory, or else your robot program will not compile! (This is `C:\Users\USERNAME\wpilib\user\java\lib` on Windows and `/home/USERNAME/wpilib/user/java/lib` on UNIX-based systems.)

Setup instructions for Eclipse:
* Put the jar in a folder somewhere in the project, e.g. `lib`
* Expand the project in Eclipse, right-click Referenced Libraries, Build Path -> Configure Build Path
* In the dialog that pops up, click Add Jars, navigate to and select the library jar, and confirm

Setup instructions for GradleRIO:
* Put the jar in a folder somewhere in the project, e.g. `lib`
* In `build.gradle`, under `dependencies`, add this line: `compile files('path/to/jar')`
* Your new `dependencies` should look something like this:
```groovy
dependencies {
compile files('lib/RobotPathfinder-2.1.0.jar')
compile wpilib()
compile ctre()
compile navx()
compile openrio.powerup.matchData()
compile wpi.deps.wpilib()
compile wpi.deps.vendor.java()
compile files('lib/RobotPathfinder-2.1.1.jar')
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
testCompile 'junit:junit:4.12'
}
```

Setup instructions for Eclipse:
* Put the jar in a folder somewhere in the project, e.g. `lib`
* Expand the project in Eclipse, right-click Referenced Libraries, Build Path -> Configure Build Path
* In the dialog that pops up, click Add Jars, navigate to and select the library jar, and confirm
* Put a copy of the jar or a simlink to it in the WPILib Java libraries directory (`C:\Users\USERNAME\wpilib\user\java\lib` on Windows and `/home/USERNAME/wpilib/user/java/lib` on UNIX-based systems).

## Documentation
All classes and methods are documented with JavaDocs, in `RobotPathfinder-Doc-VERSION.zip`.\
All classes and methods are documented with JavaDocs, in `RobotPathfinder-Doc-(VERSION).zip`.\
Examples can be found under the `examples` directory.<br><br>

## GUI Trajectory Visualization Tool
A GUI Trajectory Visualization Tool in the form of an executable jar is included with every release.
![Trajectory Visualization Tool](http:https://tylertian123.github.io/images/RobotPathfinder/tvtool1.png)<br>
![Trajectory Visualization Tool](https:https://user-images.githubusercontent.com/32781310/51583456-a5fd0780-1e9e-11e9-833a-e62376f82ec5.png)<br>

This tool generates path and trajectory graphs from waypoints and robot specification parameters; it can be used to preview paths and trajectories and check if a path is possible without having to write code for it.

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
jcenter()
}

version = '2.1.0'
project.version = '2.1.1'

// Add sources to the jar
jar {
Expand Down Expand Up @@ -60,7 +60,7 @@ task fatJar(type: Jar, group: 'Build', description: 'Assembles a jar of the libr

archiveName 'RobotPathfinder-' + project.version + '-all.jar'

//Collect all
// Collect all
classifier = 'all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }

Expand Down
6 changes: 3 additions & 3 deletions examples/FollowerDemo_FRC.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* and the unit for time must be <em>seconds</em>.
* @author Tyler Tian
*/
//Note: This example does not include the use of the directional-proportional term.
// Note: This example does not include the use of the directional-proportional term.
public class FollowerDemo_FRC extends Command {

//Acceleration feedforward term, velocity feedforward term, proportional gain, derivative gain
//Must tune later by trial and error
// Acceleration feedforward term, velocity feedforward term, proportional gain, derivative gain
// Must tune later by trial and error
public static double kA = 0.00215, kV = 0.01, kP = 0.02225, kD = 0.001;

static final Follower.TimestampSource TIMER = () -> {
Expand Down
28 changes: 14 additions & 14 deletions examples/TrajectoryGenerationDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@
public class TrajectoryGenerationDemo {

public static void main(String[] args) {
//Did you know that this trajectory generation code can be generated by the trajectory visualization tool?
//Give it a try!
// Did you know that this trajectory generation code can be generated by the trajectory visualization tool?
// Give it a try!

//To create a trajectory, first we need the robot specifications object
//The hypothetical robot has max speed of 8 ft/sec, max acceleration of 6 ft/sec and a base plate 2 feet wide
// To create a trajectory, first we need the robot specifications object
// The hypothetical robot has max speed of 8 ft/sec, max acceleration of 6 ft/sec and a base plate 2 feet wide
RobotSpecs robotSpecs = new RobotSpecs(8.0, 6.0, 2.0);
//Now create the trajectory parameters object
// Now create the trajectory parameters object
TrajectoryParams params = new TrajectoryParams();
//Specify the waypoints
//Note that all angles are in radians!
// Specify the waypoints
// Note that all angles are in radians!
params.waypoints = new Waypoint[] {
//Try changing these and see what happens!
// Try changing these and see what happens!
new Waypoint(0.0, 0.0, Math.PI / 2),
new Waypoint(-10.0, 14.0, Math.PI / 2),
new Waypoint(0.0, 25.0, 0.0),
};
//The "alpha" value is the turn smoothness constant. For more information, see its documentation.
//Try tweaking this value and see what happens!
// The "alpha" value is the turn smoothness constant. For more information, see its documentation.
// Try tweaking this value and see what happens!
params.alpha = 20.0;
//Since we want a tank drive trajectory, set this to true
// Since we want a tank drive trajectory, set this to true
params.isTank = true;
//Finally, generate the trajectory
// Finally, generate the trajectory
TankDriveTrajectory trajectory = new TankDriveTrajectory(new BasicTrajectory(robotSpecs, params));
//Now that we have the trajectory, graph it using the Grapher utility class, and show it
// Now that we have the trajectory, graph it using the Grapher utility class, and show it
JFrame pathGraph = Grapher.graphPath(trajectory.getPath(), 0.01);
JFrame trajectoryGraph = Grapher.graphTrajectory(trajectory, 0.01);
//Since swing is not thread safe, the windows have to be shown on the EDT
// Since swing is not thread safe, the windows have to be shown on the EDT
SwingUtilities.invokeLater(() -> {
pathGraph.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
trajectoryGraph.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/robot/pathfinder/core/Waypoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**
* Represents a "waypoint" in a path or trajectory. A waypoint consists of an X value, Y value, and heading
* (direction the robot is facing). All angles are in <em>radians</em>. Used to construct paths and trajectories.
* (direction the robot is travelling in). All angles are in <em>radians</em>. Used to construct paths and trajectories.
* This class is immutable.
* <p>
* Note that it does not matter what specific unit is used for distance; however, the unit must match with
* the units in the {@link RobotSpecs} object used to construct the trajectory. For example, if the unit
Expand All @@ -15,7 +16,8 @@
*
*/
public class Waypoint {
double x, y, heading;

final double x, y, heading;

/**
* Constructs a new waypoint with the specified X and Y value and heading.
Expand Down
69 changes: 69 additions & 0 deletions src/main/java/robot/pathfinder/core/WaypointEx.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package robot.pathfinder.core;

import robot.pathfinder.math.Vec2D;

/**
* Represents a "waypoint" in a path or trajectory. A waypoint consists of an X value, Y value, and heading
* (direction the robot is travelling in). All angles are in <em>radians</em>. Used to construct paths and trajectories.
* This class is immutable.
* <p>
* The {@code WaypointEx} adds additional velocity information in addition to the {@link robot.pathfinder.core.Waypoint Waypoint}'s
* position and heading. Since it inherits from a regular {@link robot.pathfinder.core.Waypoint Waypoint},
* you can use it in the place of one to accomplish things such as creating a trajectory that is a continuation of some other
* trajectory, or make the robot slow down in certain places along the path.
* </p>
* <p>
* Note that it does not matter what specific unit is used for distance; however, the unit must match with
* the units in the {@link RobotSpecs} object used to construct the trajectory. For example, if the unit
* for max velocity in the {@link RobotSpecs} object was m/s, the unit used for distance must be m.
* On the other hand, the angles must all be in <strong>radians</strong>.
* </p>
* @author Tyler Tian
*
*/
public class WaypointEx extends Waypoint {

final double velocity;

/**
* Constructs a new waypoint with the specified X and Y value, heading and velocity.
* <p>
* Note that it does not matter what specific unit is used for distance and velocity; however, the unit must
* match with the units in the {@link RobotSpecs} object used to construct the trajectory. For example, if the
* unit for max velocity in the {@link RobotSpecs} object was m/s, the unit used for distance must be m.
* </p>
* @param x The X value of this waypoint
* @param y The Y value of this waypoint
* @param heading The heading at this waypoint, in <strong>radians</strong>
* @param velocity The velocity of this waypoint
*/
public WaypointEx(double x, double y, double heading, double velocity) {
super(x, y, heading);
this.velocity = velocity;
}

/**
* Constructs a new waypoint with the specified location, heading and velocity.
* <p>
* Note that it does not matter what specific unit is used for distance and velocity; however, the unit must
* match with the units in the {@link RobotSpecs} object used to construct the trajectory. For example, if the
* unit for max velocity in the {@link RobotSpecs} object was m/s, the unit used for distance must be m.
* </p>
* @param location The location of the waypoint, represented as a 2D vector
* @param heading The heading at this waypoint, in <strong>radians</strong>
* @param velocity The velocity of this waypoint
*/
public WaypointEx(Vec2D location, double heading, double velocity) {
super(location, heading);
this.velocity = velocity;
}

/**
* Retrieves the velocity of this waypoint.
*
* @return The velocity of this waypoint
*/
public double getVelocity() {
return velocity;
}
}
Loading

0 comments on commit b44ea25

Please sign in to comment.