Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/autoinit #56

Merged
merged 20 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c83e02b
Added launcher code, crashes on code launch
BMorozov Feb 9, 2024
266b74b
Adding function to raise / lower shooter, minor bugfixes in launcher.py
magnite5 Feb 12, 2024
42c60ae
Adding Autonomous Motion Initializtion
magnite5 Feb 13, 2024
6e2bf74
Resolving comments on pull request #39
magnite5 Feb 13, 2024
b2409d9
Resolving pull request comments on Develop
magnite5 Feb 16, 2024
93cc551
Fixing gyro initialisation
magnite5 Feb 16, 2024
f62d7dc
Cleaning up sendable chooser initialisation
ColonelGuitar82 Feb 16, 2024
25904b6
Added updated fild iamge and json
magnite5 Feb 19, 2024
3414675
removed isSimulation constant and moved field2D code to robot.py
magnite5 Feb 19, 2024
fbe24a8
Publish odometry pose information for dashboard display
Portnord Feb 19, 2024
168801f
Minor refactoring, added gyro angle to shuffleboard
Portnord Feb 19, 2024
030dbc2
Consider frame when initialising and only initialise once enetering a…
Portnord Feb 20, 2024
ff0ab2c
added odometerGyroOffset to correct for the odometer offset after gyr…
NathanGrenier Mar 1, 2024
918b3b6
Merge remote-tracking branch 'origin/develop' into feature/autoinit
NathanGrenier Mar 1, 2024
6f46be4
troubleshooting
NathanGrenier Mar 1, 2024
b488894
Fixing blue team offset
NathanGrenier Mar 1, 2024
6954f42
Merge branch 'feature/autoinit' of https://github.com/sonic-howl/frc2…
NathanGrenier Mar 1, 2024
1298768
Troubleshooting
magnite5 Mar 2, 2024
14ca7d3
Merge branch 'develop' into feature/autoinit
Portnord Apr 13, 2024
3383277
Update robotpy version
Portnord Apr 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions boards/swerveboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@
"vgap": 16.0,
"titleType": 0,
"tiles": {
"0,0": {
"size": [
16,
8
],
"content": {
"_type": "Field",
"_source0": "network_table:///SmartDashboard/Field",
"_title": "Field",
"_glyph": 148,
"_showGlyph": false,
"Game/Game": "k2024Crescendo",
"Visuals/Robot Icon Size": 50.0,
"Visuals/Show Outside Circles": false
}
},
"16,0": {
"size": [
1,
Expand Down Expand Up @@ -583,9 +567,9 @@
}
],
"windowGeometry": {
"x": -8.0,
"y": -8.0,
"width": 2576.0,
"height": 1568.0
"x": -7.199999809265137,
"y": -7.199999809265137,
"width": 1550.4000244140625,
"height": 926.4000244140625
}
}
5 changes: 3 additions & 2 deletions src/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def __init__(self):
self.firetimer = 75

def stop(self):
# self.motor1.set(0.0)
# self.motor2.set(0.0)
self.motor1.set(0.0)
self.motor2.set(0.0)

self.feed.set(0.0)
self.elevator.set(0.0)
self.firetimer = 75 # In robot cycles
Expand Down
4 changes: 2 additions & 2 deletions src/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[tool.robotpy]

# Version of robotpy this project depends on
robotpy_version = "2024.3.1.0"
robotpy_version = "2024.3.2.1"

# Which extra RobotPy components should be installed
# -> equivalent to `pip install robotpy[extra1, ...]
Expand Down Expand Up @@ -93,4 +93,4 @@ indent-style = "space"
# Respect magic trailing commas.
skip-magic-trailing-comma = false
# Automatically detect the appropriate line ending.
line-ending = "auto"
line-ending = "auto"
2 changes: 2 additions & 0 deletions src/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def init_NT(self):
"""
self.network_table = ntcore.NetworkTableInstance.getDefault()
self.pose_table = self.network_table.getTable(PoseInfo.name)

self.odometry_x_pub = self.pose_table.getFloatTopic(PoseInfo.odometry_x).publish()
self.odometry_y_pub = self.pose_table.getFloatTopic(PoseInfo.odometry_y).publish()
self.odometry_r_pub = self.pose_table.getFloatTopic(PoseInfo.odometry_r).publish()
Expand All @@ -72,6 +73,7 @@ def getInputs(self):
def setOutputs(self):
# Robot Pose
odometry_pose = self.drivebase.getPose()

self.odometry_x_pub.set(odometry_pose.X())
self.odometry_y_pub.set(odometry_pose.Y())
self.odometry_r_pub.set(odometry_pose.rotation().degrees())
Expand Down
25 changes: 16 additions & 9 deletions src/swerve/swervesubsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def __init__(self) -> None:

self.gyroCalibrated = False

self.odometerGyroOffset = Rotation2d()

def getAngle(self) -> float:
return -self.gyro.getYaw()

Expand All @@ -103,6 +105,8 @@ def reset_motor_positions(self):
self.back_right.resetEncoders()

def resetOdometer(self, pose: Pose2d = Pose2d()):
self.odometerGyroOffset = pose.rotation() - self.getRotation2d()

self.odometer.resetPosition(
self.getRotation2d(),
[
Expand All @@ -116,14 +120,16 @@ def resetOdometer(self, pose: Pose2d = Pose2d()):
# potentially call gyro.setAngleAdjustment to align gyro with odometry (not necessary if we only use odometry)

def periodic(self) -> None:
self.odometer.update(
self.getRotation2d(),
(
self.front_left.getPosition(),
self.front_right.getPosition(),
self.back_left.getPosition(),
self.back_right.getPosition(),
),
(
self.odometer.update(
self.getRotation2d(),
(
self.front_left.getPosition(),
self.front_right.getPosition(),
self.back_left.getPosition(),
self.back_right.getPosition(),
),
)
)

if self.isCalibrated():
Expand Down Expand Up @@ -156,7 +162,8 @@ def setvelocity(self, drive: float, strafe: float, rotate: float):
x,
y,
z,
self.getRotation2d(),
self.getRotation2d()
+ self.odometerGyroOffset, # Adding the odometry gyro offset at init to correct for the 180 degree difference
)
else:
chassisSpeeds = ChassisSpeeds(
Expand Down
Loading