Skip to content

Commit

Permalink
sim working
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushSagar16 committed Sep 22, 2023
1 parent b05498c commit ced3d54
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
7 changes: 7 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,12 @@
}
}
}
},
"NetworkTables": {
"transitory": {
"SmartDashboard": {
"open": true
}
}
}
}
25 changes: 22 additions & 3 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
package frc.robot;

import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.Superstructure.Position;
import frc.robot.auto.AutoSelector;
Expand Down Expand Up @@ -46,7 +51,7 @@ public void robotInit() {
drive_.setDefaultCommand(new DriveTeleop(drive_, robot_state_, driver_controller_));

setupTeleopControls();
superstructure_.setPosition(Position.STOW);
// superstructure_.setPosition(Position.STOW);
}

@Override
Expand All @@ -56,10 +61,17 @@ public void robotPeriodic() {
telemetry_.periodic();
}

public Command test() {
return new SequentialCommandGroup(
new InstantCommand(()-> superstructure_.setPosition(Position.STOW)),
new WaitCommand(5.0),
superstructure_.setPosition(Position.CUBE_L1)
);
}

@Override
public void autonomousInit() {
// superstructure_.setPosition(Position.CUBE_L1);
auto_selector_.run(robot_state_, superstructure_, arm_);
System.out.println("AUTO ENABLED");
}

Expand All @@ -68,10 +80,17 @@ public void autonomousPeriodic() {}

@Override
public void teleopInit() {
test().schedule();
}

@Override
public void teleopPeriodic() {}
public void teleopPeriodic() {

System.out.println(superstructure_.getState());
// System.out.println(arm_.getAngle());
SmartDashboard.putNumber("Arm Angle", arm_.getAngle());

}

@Override
public void disabledInit() {}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/Superstructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public Superstructure(Arm arm) {


public Command setPosition(Position pos) {
System.out.println("x");
return new SequentialCommandGroup(
new InstantCommand(() -> System.out.println("inside setposition")),
new InstantCommand(() -> this.state = pos.posname),
new ArmToPosition(arm_, pos.angle).withTimeout(3)
);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Telemetry.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ public Telemetry(RobotState robot_state, Arm arm) {
public void periodic() {
for (Runnable fn : periodic_registry_)
fn.run();
System.out.println(periodic_registry_);
// System.out.println(periodic_registry_);
}
}
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/subsystems/Arm.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import edu.wpi.first.wpilibj.RobotBase;
import edu.wpi.first.wpilibj.simulation.SimDeviceSim;
import edu.wpi.first.wpilibj.simulation.SingleJointedArmSim;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class Arm extends SubsystemBase {
Expand Down Expand Up @@ -96,6 +97,8 @@ public void periodic() {
// Set simulated inputs
if (RobotBase.isSimulation())
arm_motor_sim_.getDouble("Applied Output").set(io_.demand * 12);
SmartDashboard.putNumber("ARM angle", getAngle());
SmartDashboard.putNumber("ARM Demand", io_.demand);
break;
case ANGLE:
double feedback = fb_.calculate(io_.angle);
Expand Down

0 comments on commit ced3d54

Please sign in to comment.