Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit 8134536

Browse files
committed
Motion magic command yay
1 parent 832cb78 commit 8134536

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package com.nerdherd.lib.motor.commands;
9+
10+
import com.nerdherd.lib.motor.single.AbstractSingleMotorTalonSRX;
11+
12+
import edu.wpi.first.wpilibj.command.Command;
13+
14+
public class SetMotorMotionMagic extends Command {
15+
16+
private AbstractSingleMotorTalonSRX m_motor;
17+
private double m_pos;
18+
19+
public SetMotorMotionMagic(AbstractSingleMotorTalonSRX motor, double pos) {
20+
m_motor = motor;
21+
m_pos = pos;
22+
requires(m_motor);
23+
}
24+
25+
// Called just before this Command runs the first time
26+
@Override
27+
protected void initialize() {
28+
}
29+
30+
// Called repeatedly when this Command is scheduled to run
31+
@Override
32+
protected void execute() {
33+
m_motor.setPositionMotionMagic(m_pos);
34+
}
35+
36+
// Make this return true when this Command no longer needs to run execute()
37+
@Override
38+
protected boolean isFinished() {
39+
return false;
40+
}
41+
42+
// Called once after isFinished returns true
43+
@Override
44+
protected void end() {
45+
}
46+
47+
// Called when another command which requires one or more of the same
48+
// subsystems is scheduled to run
49+
@Override
50+
protected void interrupted() {
51+
}
52+
}

0 commit comments

Comments
 (0)