Skip to content

Commit

Permalink
Added movement helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nitroxplunge committed Jan 16, 2018
1 parent 1177f40 commit 7c2820f
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 32 deletions.
1 change: 1 addition & 0 deletions Robot2018/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.metadata/
Binary file removed Robot2018/Debug/FRCUserProgram
Binary file not shown.
Binary file removed Robot2018/Debug/src/Robot.o
Binary file not shown.
12 changes: 12 additions & 0 deletions Robot2018/RemoteSystemsTempFiles/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RemoteSystemsTempFiles</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
<nature>org.eclipse.rse.ui.remoteSystemsTempNature</nature>
</natures>
</projectDescription>
5 changes: 3 additions & 2 deletions Robot2018/.cproject → eclipse/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<option id="cdt.managedbuild.option.gnu.cross.prefix.541714056" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix" value="arm-frc-linux-gnueabi-" valueType="string"/>
<option id="cdt.managedbuild.option.gnu.cross.path.1246856819" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path" value="/usr/local/bin" valueType="string"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.864368257" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/Robot2018}/Debug" cleanBuildTarget="clean" id="org.eclipse.cdt.build.core.internal.builder.1308552451" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="org.eclipse.cdt.build.core.internal.builder"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/eclipse}/Debug" cleanBuildTarget="clean" id="org.eclipse.cdt.build.core.internal.builder.1308552451" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="org.eclipse.cdt.build.core.internal.builder"/>
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1261239456" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.680635682" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option id="gnu.c.compiler.option.debugging.level.143320011" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
Expand All @@ -39,7 +39,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${WPILIB}/user/cpp/include&quot;"/>
</option>
<option id="gnu.cpp.compiler.option.dialect.flags.1518551306" superClass="gnu.cpp.compiler.option.dialect.flags" value="-std=c++1y" valueType="string"/>
<option id="gnu.cpp.compiler.option.dialect.flags.1518551306" superClass="gnu.cpp.compiler.option.dialect.flags" useByScannerDiscovery="true" value="-std=c++1y" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1033680971" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.362679811" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
Expand Down Expand Up @@ -286,4 +286,5 @@
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>
1 change: 1 addition & 0 deletions eclipse/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Debug/
2 changes: 1 addition & 1 deletion Robot2018/.project → eclipse/.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Robot2018</name>
<name>eclipse</name>
<comment></comment>
<projects>
</projects>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-632134864929199017" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="537872359404229287" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-97595266661" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="60160153867" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -27,7 +27,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1397026044559007" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1171011726947217" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
File renamed without changes.
File renamed without changes.
64 changes: 38 additions & 26 deletions Robot2018/src/Robot.cpp → eclipse/src/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@
#include <Joystick.h>
#include <RobotDrive.h>
#include <Servo.h>
#include <Timer.h>
#include <WPILib.h>

class Robot : public frc::IterativeRobot {
public:
RobotDrive *drive;
Joystick *stick;
SmartDashboard *dashboard;

Servo *armServo0;
Servo *armServo1;
Servo *armServo2;
Servo *armServo3;
RobotDrive *drive;
Timer *timer;
/*
* This autonomous (along with the chooser code above) shows how to
* select
Expand All @@ -43,7 +39,8 @@ class Robot : public frc::IterativeRobot {
* well.
*/
void AutonomousInit() override {
drive = new RobotDrive(1, 2, 3, 4);
drive = new RobotDrive(0, 1, 2, 3);
drive->SetSafetyEnabled(false);

m_autoSelected = m_chooser.GetSelected();
// m_autoSelected = SmartDashboard::GetString(
Expand All @@ -53,34 +50,35 @@ class Robot : public frc::IterativeRobot {
if (m_autoSelected == kAutoNameCustom) {
// Custom Auto goes here
} else {
// Default Auto goes here
MoveForTime(3.0, 1, 0, 0.25);
Wait(2);
MoveForTime(3.0, -1, 0, 0.25);
}
}

void AutonomousPeriodic() {
if (m_autoSelected == kAutoNameCustom) {
// Custom Auto goes here
} else {
drive->Drive(1.0, 0.0);
// Default Auto goes here
}
}

void TeleopInit() {
stick = new Joystick(5);
drive = new RobotDrive(1, 2, 3, 4);
stick = new Joystick(0);
drive->SetSafetyEnabled(false);
}

void TeleopPeriodic() {
while (IsOperatorControl() && IsEnabled()) {
drive->Drive(0.25, 0.0);
//drive->ArcadeDrive(stick);
//dashboard->PutNumber("test", 5.0);
drive->ArcadeDrive(stick);
Wait(0.01);
}
}

void TestPeriodic() {
drive->Drive(0.25, 0.0);
drive->Drive(0.1, 0.0);
Wait(0.01);
}

private:
Expand All @@ -90,18 +88,32 @@ class Robot : public frc::IterativeRobot {
const std::string kAutoNameCustom = "My Auto";
std::string m_autoSelected;

void lowArmPosition() {
armServo0->SetAngle(0.0);
armServo1->SetAngle(180.0);
armServo2->SetAngle(0.0);
armServo3->SetAngle(330);
// (float) distance - Distance forward or backwards, in feet
// (float) rotation - Rotation right or left, in degrees
// (float) speed - The speed in which to move (0.0 to 1.0)
void MoveDistance(float distance, float rotation, float speed) {
// TO FINISH
}

void highArmPosition() {
armServo0->SetAngle(90.0);
armServo1->SetAngle(90.0);
armServo2->SetAngle(90.0);
armServo3->SetAngle(0);
// (float) time - Time to move
// (integer) move - Weather to move forwards (1), backwards (-1) or stay still (0)
// (integer) rotate - Weather to rotate right (1), left (-1) or stay still (0)
// (float) speed - The speed in which to move (0.0 to 1.0)
void MoveForTime(float time, int move, int rotate, float speed) {
timer = new Timer();
float moveSpeed = 0.0;
float rotateSpeed = 0.0;

if (move == 1) { moveSpeed = speed; }
else if (move == -1) { moveSpeed = -speed; }

if (rotate == 1) { rotateSpeed = speed; }
else if (rotate == -1) { rotateSpeed = -speed; }

while(timer->Get() < time) {
drive->Drive(moveSpeed, rotateSpeed);
Wait(0.01);
}
}
};

Expand Down

0 comments on commit 7c2820f

Please sign in to comment.