Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Commit

Permalink
Made autonomous not lock up our drivetrain by changing some abs() to …
Browse files Browse the repository at this point in the history
…fabs()
  • Loading branch information
frc4646Developer authored and bobbysq committed Oct 30, 2016
1 parent 4564eca commit 049df89
Show file tree
Hide file tree
Showing 15 changed files with 201 additions and 58 deletions.
212 changes: 168 additions & 44 deletions .cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>frc4646-2016-competition-code</name>
<name>Sherman</name>
<comment></comment>
<projects>
</projects>
Expand Down
15 changes: 13 additions & 2 deletions .settings/language.settings.xml
Expand Up @@ -5,18 +5,29 @@
<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="902718506072416551" 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="-1702718735741470413" 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>
</extension>
</configuration>
<configuration id="cdt.managedbuild.config.gnu.cross.exe.debug.1104744751.2017904325" name="Simulate">
<configuration id="cdt.managedbuild.config.gnu.cross.exe.debug.1104744751.2017904325" name="linux_simulate">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<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-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/>
</extension>
</configuration>
<configuration id="cdt.managedbuild.config.gnu.mingw.exe.debug.912379410.387599128" name="Windows Simulate">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<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="-155214497164935" 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>
</extension>
</configuration>
</project>
1 change: 0 additions & 1 deletion src/CommandGroups/FiringAuto.cpp
Expand Up @@ -39,7 +39,6 @@ FiringAuto::FiringAuto()
AddSequential(new RobotGoalAngle(),2);
AddSequential(new RobotGoalDistance(),2);
AddSequential(new RobotGoalAngle(),1);
// AddSequential(new SpinUp(.8), 2);
AddSequential(new Launch(.9));

}
6 changes: 3 additions & 3 deletions src/CommandGroups/JustCrossDefense.cpp
Expand Up @@ -22,7 +22,7 @@ JustCrossDefense::JustCrossDefense()
// a CommandGroup containing them would require both the chassis and the
// arm.
AddSequential(new ResetGyro());
AddSequential(new DriveForTime(.8,0),2);
AddSequential(new TurnForAngle(.4, 0), 2);
AddSequential(new DriveForTime(.4, 0), .5);
AddSequential(new DriveForTime(.9,0),2.5);
// AddSequential(new TurnForAngle(.4, 0), 2);
// AddSequential(new DriveForTime(.4, 0), .5);
}
3 changes: 2 additions & 1 deletion src/Commands/AutoRollerIn.cpp
Expand Up @@ -2,7 +2,8 @@
#include "Subsystems/IntakeRoller.h"
#include "Subsystems/IntakeArms.h"

AutoRollerIn::AutoRollerIn()
AutoRollerIn::AutoRollerIn():
CommandBase("AutoRollerIn")
{
// Use Requires() here to declare subsystem dependencies
// eg. Requires(chassis);
Expand Down
1 change: 1 addition & 0 deletions src/Commands/DriveForTime.cpp
Expand Up @@ -2,6 +2,7 @@
#include "Subsystems/DropDrive.h"

DriveForTime::DriveForTime(double power, double curve):
CommandBase("DriveForTime"),
drivePower(power),
driveCurve(curve)
{
Expand Down
1 change: 1 addition & 0 deletions src/Commands/DriveUntilClose.cpp
Expand Up @@ -3,6 +3,7 @@
#include "Subsystems/UltrasonicSensor.h"

DriveUntilClose::DriveUntilClose(double power, double distance):
CommandBase("DriveUntilClose"),
robotPower(power),
sensorDistance(distance),
confidence(0)
Expand Down
1 change: 1 addition & 0 deletions src/Commands/FoldIntakeOut.cpp
@@ -1,6 +1,7 @@
#include "FoldIntakeOut.h"
#include "Subsystems/IntakeArms.h"
FoldIntakeOut::FoldIntakeOut()
:CommandBase("FoldIntakeOut")
{
// Use Requires() here to declare subsystem dependencies
// eg. Requires(chassis);
Expand Down
1 change: 1 addition & 0 deletions src/Commands/ResetGyro.cpp
Expand Up @@ -2,6 +2,7 @@
#include "Subsystems/DropDrive.h"

ResetGyro::ResetGyro()
:CommandBase("ResetGyro")
{
// Use Requires() here to declare subsystem dependencies
// eg. Requires(chassis);
Expand Down
1 change: 1 addition & 0 deletions src/Commands/RobotGoalAngle.cpp
Expand Up @@ -4,6 +4,7 @@
#include <algorithm>

RobotGoalAngle::RobotGoalAngle():
CommandBase("RobotGoalAngle"),
turning(0),
robotTurn(0),
confidence(0),
Expand Down
1 change: 1 addition & 0 deletions src/Commands/RobotGoalDistance.cpp
Expand Up @@ -3,6 +3,7 @@
#include "Subsystems/VisionCalculation.h"

RobotGoalDistance::RobotGoalDistance():
CommandBase("RobotGoalDistance"),
po(),
ps(visioncalculation),
pc(1.75,0.003,-0.3,&ps,&po)
Expand Down
10 changes: 6 additions & 4 deletions src/Commands/TurnForAngle.cpp
Expand Up @@ -3,6 +3,7 @@
#include <math.h>

TurnForAngle::TurnForAngle(double robotPower, double robotAngle):
CommandBase("TurnForAngle"),
power(robotPower),
angle(robotAngle)
{
Expand All @@ -14,13 +15,13 @@ angle(robotAngle)
// Called just before this Command runs the first time
void TurnForAngle::Initialize()
{
initDif = abs(dropdrive->GetHeading() - angle);
initDif = fabs(dropdrive->GetHeading() - angle);
}

// Called repeatedly when this Command is scheduled to run
void TurnForAngle::Execute()
{
drive = power * abs((dropdrive->GetHeading() - angle))/initDif;
drive = power * fabs((dropdrive->GetHeading() - angle))/initDif;
if (drive < .2)
{
drive = .2;
Expand All @@ -39,7 +40,8 @@ void TurnForAngle::Execute()
bool TurnForAngle::IsFinished()
{
error = dropdrive->GetHeading() - angle;
return abs(error) < 5;
SmartDashboard::PutNumber("TurnForAngleError", error);
return fabs(error) < 5;
}

// Called once after isFinished returns true
Expand All @@ -52,5 +54,5 @@ void TurnForAngle::End()
// subsystems is scheduled to run
void TurnForAngle::Interrupted()
{

End();
}
4 changes: 2 additions & 2 deletions src/Subsystems/IntakeArms.cpp
Expand Up @@ -40,7 +40,7 @@ void IntakeArms::SetSpeed(double power)

void IntakeArms::Raise() {

arms.Set(-.55);
arms.Set(-.4);
// if(LimitUp->Get())
// {
// LeftEncoder.Reset();
Expand All @@ -66,7 +66,7 @@ void IntakeArms::ForceRaise() {
}

void IntakeArms::Lower() {
arms.Set(.65);
arms.Set(.45);
// if(!MotorsUnbalanced()){
// arms.Set((MAX_ENCODER_COUNT-RightEncoder.Get())/MAX_ENCODER_COUNT);
// }
Expand Down
Binary file modified sysProps.xml
Binary file not shown.

0 comments on commit 049df89

Please sign in to comment.