Skip to content

Commit

Permalink
Version 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
realquantumcookie committed Dec 14, 2019
1 parent 6f7d9d3 commit 65f042c
Show file tree
Hide file tree
Showing 34 changed files with 1,811 additions and 36 deletions.
12 changes: 1 addition & 11 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/commons-math3-3.6.1.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/Darbots-FTC-Trajectory-Commons.jar">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
Expand Down
8 changes: 5 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
2 changes: 2 additions & 0 deletions .settings/org.eclipse.ltk.core.refactoring.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
Binary file removed libs/Darbots-FTC-Trajectory-Commons.jar
Binary file not shown.
Binary file removed libs/commons-math3-3.6.1.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.darbots.darbotsftclib.libcore.calculations.algebraic_calculation;

public interface OrderedValueProvider {
boolean orderIncremental();
double valueAt(double independentVar);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.darbots.darbotsftclib.libcore.calculations.algebraic_calculation;

public class OrderedValueSolver {
public static final double INFINATELY_SMALL = 0.00000001;
public static final double RESULT_NOSOLUTION = -1000000000000000.0;
public static double solve(OrderedValueProvider valueProvider, double errorMargin, double independentVarMin, double independentVarMax, double desiredValue){
if((valueProvider.orderIncremental() && independentVarMax > independentVarMin) || ((!valueProvider.orderIncremental()) && independentVarMax < independentVarMin)){
return __solve(valueProvider,errorMargin,independentVarMin,independentVarMax,desiredValue);
}else{
return __solve(valueProvider,errorMargin,independentVarMax,independentVarMin,desiredValue);
}
}
protected static double __solve(OrderedValueProvider valueProvider, double errorMargin, double independentVarMin, double independentVarMax, double desiredValue){
double deltaMaxMin = independentVarMax - independentVarMin;
if(Math.abs(deltaMaxMin) <= INFINATELY_SMALL){
return RESULT_NOSOLUTION;
}
double middleVar = (independentVarMax + independentVarMin) / 2.0;
double middleVal = valueProvider.valueAt(middleVar);
if(Math.abs(middleVal - desiredValue) <= errorMargin){
return middleVar;
}else if(desiredValue < middleVal){
//middleVar as new independentVarMax
return __solve(valueProvider,errorMargin,independentVarMin,middleVar,desiredValue);
}else{ //desiredValue > middleVal
//middleVar as new independentVarMin
return __solve(valueProvider,errorMargin,middleVar,independentVarMax,desiredValue);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.darbots.darbotsftclib.libcore.calculations.dimentional_calculation;

public class DarbotsDerivative {
public static final double DERIVATIVE_VERTICLE_TANGENT_YPOSITIVE = 100000000;
public static final double DERIVATIVE_VERTICLE_TANGENT_YNEGATIVE = -100000000;
public static final double DERIVATIVE_VERTICLE_TANGENT_YZERO = -500000000;
public double deltaX = 0;
public double deltaY = 0;
public DarbotsDerivative(double deltaX, double deltaY){
this.deltaX = deltaX;
this.deltaY = deltaY;
}
public DarbotsDerivative(DarbotsDerivative oldDerivative){
this.deltaX = oldDerivative.deltaX;
this.deltaY = oldDerivative.deltaY;
}
public double computeDyOverDx(){
double deltaX, deltaY = 0;
if(this.deltaX < 0){
deltaX = -this.deltaX;
deltaY = -this.deltaY;
}else{
deltaX = this.deltaX;
deltaY = this.deltaY;
}
if(deltaX == 0){
if(deltaY > 0){
return DERIVATIVE_VERTICLE_TANGENT_YPOSITIVE;
}else if(deltaY == 0){
return DERIVATIVE_VERTICLE_TANGENT_YZERO;
}else{ //deltaY < 0
return DERIVATIVE_VERTICLE_TANGENT_YNEGATIVE;
}
}else{
return deltaY / deltaX;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.darbots.darbotsftclib.libcore.calculations.dimentional_calculation;

public class RobotPoint2D {
public double X;
public double Y;
public RobotPoint2D(double X, double Y) {
this.X = X;
this.Y = Y;
}
public RobotPoint2D(RobotPoint2D oldPoint) {
this.X = oldPoint.X;
this.Y = oldPoint.Y;
}
public RobotPoint2D(RobotVector2D indicator) {
this.X = indicator.X;
this.Y = indicator.Y;
}
public double distanceTo(RobotPoint2D secondPoint){
return Math.sqrt(Math.pow(secondPoint.X - this.X,2) + Math.pow(secondPoint.Y - this.Y,2));
}
public void setValues(RobotPoint2D value){
this.X = value.X;
this.Y = value.Y;
}
@Override
public String toString() {
return "(" + this.X + ", " + this.Y + ")";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
MIT License
Copyright (c) 2018 DarBots Collaborators
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package org.darbots.darbotsftclib.libcore.calculations.dimentional_calculation;


public class RobotPose2D extends RobotVector2D {
public RobotPose2D(double X, double Y, double ZRotation) {
super(X, Y, XYPlaneCalculations.normalizeDeg(ZRotation));
}

public RobotPose2D(RobotPoint2D Point, double ZRotation) {
super(Point, XYPlaneCalculations.normalizeDeg(ZRotation));
}

public RobotPose2D(RobotVector2D Pos2D) {
super(Pos2D.X,Pos2D.Y,XYPlaneCalculations.normalizeDeg(Pos2D.m_RotationZ));
}

public void setValues(double X, double Y, double RotationZ){
this.X = X;
this.Y = Y;
this.m_RotationZ = XYPlaneCalculations.normalizeDeg(RotationZ);
}
public void setValues(RobotVector2D pose2D){
this.X = pose2D.X;
this.Y = pose2D.Y;
this.m_RotationZ = XYPlaneCalculations.normalizeDeg(pose2D.m_RotationZ);
}
public void offsetValues(double X, double Y, double RotationZ){
this.X += X;
this.Y += Y;
this.m_RotationZ = XYPlaneCalculations.normalizeDeg(this.m_RotationZ + RotationZ);
}
public void setRotationZ(double RotationZ){
this.m_RotationZ = XYPlaneCalculations.normalizeDeg(RotationZ);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
MIT License
Copyright (c) 2018 DarBots Collaborators
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package org.darbots.darbotsftclib.libcore.calculations.dimentional_calculation;


public class RobotPose3D {
public double X;
public double Y;
public double Z;
protected double m_RotationX;
protected double m_RotationZ;
protected double m_RotationY;
public RobotPose3D(double X, double Y, double Z, double RotationX, double RotationY, double RotationZ){
this.X = X;
this.Y = Y;
this.Z = Z;
this.m_RotationX = XYPlaneCalculations.normalizeDeg(RotationX);
this.m_RotationY = XYPlaneCalculations.normalizeDeg(RotationY);
this.m_RotationZ = XYPlaneCalculations.normalizeDeg(RotationZ);
}
public RobotPose3D(RobotPose2D Pos2D, double Z, double RotationX, double RotationY){
this.X = Pos2D.X;
this.Y = Pos2D.Y;
this.Z = Z;
this.m_RotationX = XYPlaneCalculations.normalizeDeg(RotationX);
this.m_RotationZ = Pos2D.getRotationZ();
this.m_RotationY = XYPlaneCalculations.normalizeDeg(RotationY);
}
public RobotPose3D(RobotPose3D Pos3D){
this.X = Pos3D.X;
this.Y = Pos3D.Y;
this.Z = Pos3D.Z;
this.m_RotationX = Pos3D.m_RotationX;
this.m_RotationY = Pos3D.m_RotationY;
this.m_RotationZ = Pos3D.m_RotationZ;
}
public double getDistanceToOrigin(){
return (Math.sqrt(Math.pow(this.X,2) + Math.pow(this.Y,2) + Math.pow(this.Z,2)));
}
public RobotPose2D get2DPosition(){
return new RobotPose2D(this.X,this.Y,this.getRotationZ());
}
public double getRotationX(){
return this.m_RotationX;
}
public void setRotationX(double RotationX){
this.m_RotationX = XYPlaneCalculations.normalizeDeg(RotationX);
}
public double getRotationY(){
return this.m_RotationY;
}
public void setRotationY(double RotationY){
this.m_RotationY = XYPlaneCalculations.normalizeDeg(RotationY);
}
public double getRotationZ(){
return this.m_RotationZ;
}
public void setRotationZ(double RotationZ){
this.m_RotationZ = XYPlaneCalculations.normalizeDeg(RotationZ);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
MIT License
Copyright (c) 2018 DarBots Collaborators
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package org.darbots.darbotsftclib.libcore.calculations.dimentional_calculation;


public class RobotVector2D {
public double X;
public double Y;
protected double m_RotationZ;
public RobotVector2D(double X, double Y, double ZRotation){
this.X = X;
this.Y = Y;
this.m_RotationZ = ZRotation;
}
public RobotVector2D(RobotPoint2D Point, double ZRotation) {
this.X = Point.X;
this.Y = Point.Y;
this.m_RotationZ = ZRotation;
}
public RobotVector2D(RobotVector2D Pos2D){
this.X = Pos2D.X;
this.Y = Pos2D.Y;
this.m_RotationZ = Pos2D.m_RotationZ;
}
public void setValues(double X, double Y, double RotationZ){
this.X = X;
this.Y = Y;
this.m_RotationZ = RotationZ;
}
public void setValues(RobotVector2D pose2D){
this.X = pose2D.X;
this.Y = pose2D.Y;
this.m_RotationZ = pose2D.m_RotationZ;
}
public void offsetValues(double X, double Y, double RotationZ){
this.X += X;
this.Y += Y;
this.m_RotationZ += RotationZ;
}
public void offsetValues(RobotVector2D pose2D){
this.offsetValues(pose2D.X,pose2D.Y,pose2D.getRotationZ());
}
public double getDistanceToOrigin(){
return (Math.sqrt(Math.pow(this.X,2) + Math.pow(this.Y,2)));
}
public double getRotationZ(){
return this.m_RotationZ;
}
public void setRotationZ(double RotationZ){
this.m_RotationZ = RotationZ;
}
public RobotPoint2D toPoint2D() {
return new RobotPoint2D(this);
}
}
Loading

0 comments on commit 65f042c

Please sign in to comment.