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

Add Xbox controller support to Thunderscope #3064

Merged
Merged
Show file tree
Hide file tree
Changes from 168 commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
1bf3177
resetting
Bvasilchikov Apr 1, 2023
803a815
Added redis service to thunderloop and some cleanup
Bvasilchikov Jan 15, 2022
bda285e
added deps to build file
Bvasilchikov Jan 15, 2022
f0c9f29
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software …
Bvasilchikov Mar 24, 2022
cd45491
Merge remote-tracking branch 'origin/master'
Bvasilchikov Apr 1, 2023
7a0127b
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software
Bvasilchikov Apr 8, 2023
0f53eb1
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software
Bvasilchikov Apr 28, 2023
fb344a6
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software
Bvasilchikov Jun 3, 2023
3dfba83
initial changes compiling
itsarune Jun 3, 2023
d4a6ce7
perform RESET write to clear RESET indicator properly
itsarune Jun 3, 2023
3e1ccbb
formatting
itsarune Jun 6, 2023
a54183a
cleanup logic
itsarune Jun 6, 2023
1caa573
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jun 6, 2023
629b482
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software
Bvasilchikov Jun 9, 2023
5e3b7de
Merge branch 'master' of github.com:UBC-Thunderbots/Software into thu…
itsarune Jun 10, 2023
63d7fd2
Merge branch 'thunderloop-safety-updates-v1' of github.com:itsarune/S…
itsarune Jun 10, 2023
b6d612c
better time printout
itsarune Jun 11, 2023
3a7829b
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jun 11, 2023
9c3f21b
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software
Bvasilchikov Jun 11, 2023
7cfd77d
Merge branch 'thunderloop-safety-updates-v2' of github.com:itsarune/S…
Bvasilchikov Jun 11, 2023
00fe0d6
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software
Bvasilchikov Jun 17, 2023
ddf6c8c
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software
Bvasilchikov Jun 22, 2023
5421fe1
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software
Bvasilchikov Jun 27, 2023
8911356
Merge remote-tracking branch 'upstream/master'
Bvasilchikov Nov 25, 2023
b5c1400
merging is difficult
Bvasilchikov Nov 26, 2023
87580c9
added handlers for signals, moved some comm logic out of controller, …
Bvasilchikov Nov 30, 2023
7c9d0c7
formatting
Bvasilchikov Nov 30, 2023
83862f1
wip
Bvasilchikov Jan 13, 2024
c8c12fb
wip
Bvasilchikov Jan 20, 2024
c546f9c
wip saturday notes
Bvasilchikov Jan 20, 2024
8a81a68
wip
Bvasilchikov Feb 3, 2024
91b5d01
moving lgoic out of rob comm
Bvasilchikov Feb 3, 2024
5939e75
wip
Bvasilchikov Feb 3, 2024
1061940
wip
Bvasilchikov Feb 10, 2024
e1f40e9
finally working the way i want
Bvasilchikov Feb 11, 2024
6084e9f
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software …
Bvasilchikov Feb 26, 2024
565ab5e
wip
Bvasilchikov Mar 2, 2024
16511b4
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software …
Bvasilchikov Mar 15, 2024
7cf3d3c
wip
Bvasilchikov Mar 16, 2024
798f2e4
wip
Bvasilchikov Mar 17, 2024
2a1fad6
wip
Bvasilchikov Mar 17, 2024
f6138e4
formatting
Bvasilchikov Mar 17, 2024
75b6228
cleanup
Bvasilchikov Mar 17, 2024
e984e36
formatting
Bvasilchikov Mar 17, 2024
63b93eb
changed to id
Bvasilchikov Mar 17, 2024
b3e8a41
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Mar 17, 2024
35be0c5
clean up and added todo's
Bvasilchikov Mar 18, 2024
940dc48
Merge remote-tracking branch 'origin/xbox_controller_support3' into x…
Bvasilchikov Mar 18, 2024
9427ff1
clean up and added todo's addressing pr comments
Bvasilchikov Mar 23, 2024
d97e92b
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Mar 23, 2024
c966fa1
formatting
Bvasilchikov Mar 23, 2024
210910e
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software …
Bvasilchikov Mar 23, 2024
bb2ce57
Merge remote-tracking branch 'origin/xbox_controller_support3' into x…
Bvasilchikov Mar 23, 2024
1494757
formatting
Bvasilchikov Mar 23, 2024
f8a24db
addressing comments
Bvasilchikov Mar 23, 2024
d446ec8
formatting
Bvasilchikov Mar 23, 2024
c661261
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software …
Bvasilchikov Mar 23, 2024
4d56abc
updated import order
Bvasilchikov Mar 27, 2024
1b99fc4
updated requirements' pyqtgraph dep
Bvasilchikov Mar 27, 2024
867c6bc
added constants from other branch, handheld_demo_4, for ref
Bvasilchikov Mar 27, 2024
c4627dc
undo requirements, too much bumped
Bvasilchikov Mar 27, 2024
82222ed
pr comments: removed todos
Bvasilchikov Mar 27, 2024
64b8250
added constants
Bvasilchikov Mar 27, 2024
15df761
returned back the lost signal
Bvasilchikov Mar 27, 2024
ac95b3b
added todo
Bvasilchikov Mar 27, 2024
635f45d
added refresh button and status
Bvasilchikov Mar 27, 2024
87d40d6
formatting
Bvasilchikov Mar 27, 2024
e9f7ca0
added todo
Bvasilchikov Mar 27, 2024
857256a
bob's the rebuilder
Bvasilchikov Mar 27, 2024
ebb53c1
formatting, ofcourse and alas
Bvasilchikov Mar 27, 2024
2d883d2
added reminder
Bvasilchikov Mar 27, 2024
e772a0d
back to info level!
Bvasilchikov Mar 27, 2024
a57fb71
we do a lil cleanup
Bvasilchikov Mar 27, 2024
0b8f5db
formatting
Bvasilchikov Mar 27, 2024
28d314a
debugging
Bvasilchikov Mar 27, 2024
54ceb4d
removed unused constants
Bvasilchikov Mar 28, 2024
ee6899c
not even needed
Bvasilchikov Mar 28, 2024
904f245
cleanup
Bvasilchikov Mar 28, 2024
1f66789
bump evdev to latest
Bvasilchikov Mar 28, 2024
7304a93
Merge remote-tracking branch 'refs/remotes/upstream/master' into xbox…
Bvasilchikov Mar 28, 2024
6874cae
formatting
Bvasilchikov Mar 28, 2024
b5fc9db
refactoring and working locally
Bvasilchikov Mar 28, 2024
d91cdb7
formatting
Bvasilchikov Mar 28, 2024
a0f6947
formatting
Bvasilchikov Mar 28, 2024
b59f64e
fix ci
Bvasilchikov Mar 28, 2024
5f9a727
Merge remote-tracking branch 'upstream/master' into xbox_controller_s…
Bvasilchikov Apr 1, 2024
9485892
import correct logger ("wait it's always been there?" "always has been")
Bvasilchikov Apr 1, 2024
a3d9314
remove unused import
Bvasilchikov Apr 1, 2024
6e9f7cf
reorganize init and clean up comments
Bvasilchikov Apr 1, 2024
e04ac17
rename enum and cleanup
Bvasilchikov Apr 1, 2024
6b81fcf
simplify
Bvasilchikov Apr 1, 2024
7d30a55
rename method and remove boolean field, some cleanup
Bvasilchikov Apr 1, 2024
5fff8db
simplify and cleanup
Bvasilchikov Apr 1, 2024
4f2bd9b
disable widget controls based on control mode
Bvasilchikov Apr 1, 2024
380ed30
Added input event type enum and a dictionary for supported controller…
Bvasilchikov Apr 1, 2024
78651f2
standardized event processing to use event code, simplified for reada…
Bvasilchikov Apr 1, 2024
65d4977
formatting
Bvasilchikov Apr 1, 2024
ea818d0
bazel sync error temp fix
Bvasilchikov Apr 1, 2024
4702158
renaming some stuff and more cleanup
Bvasilchikov Apr 1, 2024
2b786d4
formatting
Bvasilchikov Apr 1, 2024
f0d21b0
lil cleanup
Bvasilchikov Apr 1, 2024
b2fbb0a
Merge remote-tracking branch 'upstream/master' into xbox_controller_s…
Bvasilchikov Apr 4, 2024
5f729df
changed controller config structure, returned back to using thread so…
Bvasilchikov Apr 5, 2024
55e5f32
formatting
Bvasilchikov Apr 5, 2024
53533ef
Merge remote-tracking branch 'upstream/master' into xbox_controller_s…
Bvasilchikov Apr 5, 2024
136b911
removed abs info and clean up, added event type check
Bvasilchikov Apr 5, 2024
e07e1ad
formatting
Bvasilchikov Apr 5, 2024
d317a33
Merge remote-tracking branch 'refs/remotes/upstream/master' into xbox…
Bvasilchikov Apr 12, 2024
003d3d3
update signal name
Bvasilchikov Apr 16, 2024
6f8f367
update logic for consistency and naming
Bvasilchikov Apr 16, 2024
3bb67dd
moved button
Bvasilchikov Apr 16, 2024
7c22169
split into two functions
Bvasilchikov Apr 16, 2024
e78be52
field testing constants
Bvasilchikov Apr 16, 2024
d8a997d
update logic based on pr comments
Bvasilchikov Apr 16, 2024
874a5a9
simplify
Bvasilchikov Apr 16, 2024
13d3e3d
added public method to update sliders values
Bvasilchikov Apr 16, 2024
5498292
field testing wip
Bvasilchikov Apr 16, 2024
ae461c6
update ubuntu 22 reqs
Bvasilchikov Apr 16, 2024
e505684
sliders now update to match controller value on handheld mode
Bvasilchikov Apr 16, 2024
d357fc9
formatting
Bvasilchikov Apr 16, 2024
29ad025
updated to use builtin dict instead of rebuilding a wheel
Bvasilchikov Apr 17, 2024
bf83557
type error
Bvasilchikov Apr 17, 2024
ddc84d0
formatting
Bvasilchikov Apr 17, 2024
2f89a5b
update deadzone perc
Bvasilchikov Apr 17, 2024
fb18730
we do a lil cleanup
Bvasilchikov Apr 17, 2024
51e992e
renamed function to use snake_case
Bvasilchikov Apr 18, 2024
73cad9e
add logger to robot comms, rename attr
Bvasilchikov Apr 18, 2024
908a52d
wrapped with enum constructor
Bvasilchikov Apr 18, 2024
7b9f474
add todo
Bvasilchikov Apr 18, 2024
29819ec
comment groupbox for now, collapses whole ui for some reason
Bvasilchikov Apr 18, 2024
06c63e4
split method into a bunch of smaller ones,
Bvasilchikov Apr 18, 2024
96ecf2a
refactored logic - added more signals to propagate ui changes, added …
Bvasilchikov Apr 18, 2024
4253625
changed threading logic, added separate chipper distance attr and par…
Bvasilchikov Apr 18, 2024
c9970e9
updated
Bvasilchikov Apr 18, 2024
d16a339
formatting
Bvasilchikov Apr 18, 2024
0ae3a10
remove unused enum, reorder imports
Bvasilchikov Apr 18, 2024
5e8b874
docs, added todos for refactoring out exp kick speed into method, var…
Bvasilchikov May 6, 2024
c0d0b92
turns out python type hinting isnt really that hintful :/
Bvasilchikov May 9, 2024
d8a99e6
moved proto sending logic down a level
Bvasilchikov May 9, 2024
15bc0c2
Merge remote-tracking branch 'upstream/master' into xbox_controller_s…
Bvasilchikov May 9, 2024
a88353b
Merge remote-tracking branch 'refs/remotes/upstream/master' into xbox…
Bvasilchikov May 20, 2024
8a7ef78
layouting and ui changes on diagnostics tab - all controls now wrappe…
Bvasilchikov May 20, 2024
bafd463
formatting
Bvasilchikov May 20, 2024
5edb780
small cleanup
Bvasilchikov May 20, 2024
6c8391b
formatting
Bvasilchikov May 20, 2024
e686a59
pr comments
Bvasilchikov May 20, 2024
304d468
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software …
williamckha Sep 2, 2024
20d9aac
Revert accidental change to pyqt version
williamckha Sep 2, 2024
4696dba
Fix bugs
williamckha Sep 7, 2024
58049f5
made it work but untested kind of
williamckha Sep 21, 2024
7deff55
Fix thread safety problems, refactoring
williamckha Sep 23, 2024
7672ffa
Fix bugs
williamckha Sep 23, 2024
b8f28c7
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software …
williamckha Sep 23, 2024
00f6a30
Nits
williamckha Sep 23, 2024
2c23948
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Sep 23, 2024
5c282b1
More nits
williamckha Sep 23, 2024
64b5653
Merge branch 'xbox_controller_support3' of https://github.com/bvasilc…
williamckha Sep 23, 2024
c9e4770
Fix bugs with chicker widget buttons enabling/disabling at wrong times
williamckha Sep 24, 2024
749db91
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Sep 24, 2024
99b7c0a
Nits
williamckha Sep 24, 2024
a157a2c
Merge branch 'xbox_controller_support3' of https://github.com/bvasilc…
williamckha Sep 24, 2024
c30ba4a
Formatting
williamckha Sep 24, 2024
ecdd19e
Add docstrings
williamckha Sep 25, 2024
c0be885
Add docs
williamckha Sep 28, 2024
8f2b080
Major refactor
williamckha Oct 9, 2024
2cf5afc
Update doc
williamckha Oct 9, 2024
0e1c0f1
Update doc
williamckha Oct 9, 2024
31b3ba1
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software …
williamckha Oct 10, 2024
875865a
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software …
williamckha Oct 31, 2024
b4d1b46
Press left trigger to drive slowly
williamckha Nov 2, 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
5 changes: 3 additions & 2 deletions environment_setup/ubuntu20_requirements.txt
Bvasilchikov marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
protobuf==3.20.2
pyqtgraph==0.13.7
pyqtdarktheme==2.1.0
pyqt6==6.5.0
PyQt6-Qt6==6.5.0
pyqt6==6.6.1
PyQt6-Qt6==6.6.1
thefuzz==0.19.0
iterfzf==0.5.0.20.0
python-Levenshtein==0.12.2
psutil==5.9.0
PyOpenGL==3.1.6
numpy==1.24.4
ruff==0.5.5
evdev==1.7.0
5 changes: 3 additions & 2 deletions environment_setup/ubuntu22_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
protobuf==3.20.2
pyqtgraph==0.13.7
pyqtdarktheme==2.1.0
pyqt6==6.5.0
PyQt6-Qt6==6.5.0
pyqt6==6.6.1
PyQt6-Qt6==6.6.1
thefuzz==0.19.0
iterfzf==0.5.0.20.0
python-Levenshtein==0.12.2
psutil==5.9.0
PyOpenGL==3.1.6
numpy==1.24.4
ruff==0.5.5
evdev==1.7.0
16 changes: 9 additions & 7 deletions src/proto/message_translation/power_frame_msg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ TbotsProto_PowerStatus inline createNanoPbPowerStatus(
/**
* Converts a google protobuf power control msg to its nanopb representation
*
* @param google_control protobuf message to convert
* @param power_control protobuf message to convert
* @return a nanopb power control msg matching provided protobuf
*/

TbotsProto_PowerPulseControl inline createNanoPbPowerPulseControl(
const TbotsProto::PowerControl& google_control, double kick_coeff, int kick_constant,
const TbotsProto::PowerControl& power_control, double kick_coeff, int kick_constant,
int chip_pulse_width)
{
TbotsProto_PowerPulseControl nanopb_control =
Expand All @@ -133,15 +133,17 @@ TbotsProto_PowerPulseControl inline createNanoPbPowerPulseControl(
kick_constant = std::min(kick_constant, MAX_KICK_CONSTANT);
kick_coeff = std::min(kick_coeff, MAX_KICK_COEFFICIENT);

switch (google_control.chicker().chicker_command_case())
switch (power_control.chicker().chicker_command_case())
{
case TbotsProto::PowerControl::ChickerControl::kKickSpeedMPerS:
nanopb_control.chicker.which_chicker_command =
TbotsProto_PowerPulseControl_ChickerControl_kick_pulse_width_tag;
// TODO (#3193): refactor kick pulse width calculation out into seperate
// function
nanopb_control.chicker.chicker_command.kick_pulse_width =
static_cast<uint32_t>(
kick_constant *
std::exp(kick_coeff * google_control.chicker().kick_speed_m_per_s()));
std::exp(kick_coeff * power_control.chicker().kick_speed_m_per_s()));
break;
case TbotsProto::PowerControl::ChickerControl::kChipDistanceMeters:
nanopb_control.chicker.which_chicker_command =
Expand All @@ -151,7 +153,7 @@ TbotsProto_PowerPulseControl inline createNanoPbPowerPulseControl(
case TbotsProto::PowerControl::ChickerControl::kAutoChipOrKick:
nanopb_control.chicker.which_chicker_command =
TbotsProto_PowerPulseControl_ChickerControl_auto_chip_or_kick_tag;
switch (google_control.chicker().auto_chip_or_kick().auto_chip_or_kick_case())
switch (power_control.chicker().auto_chip_or_kick().auto_chip_or_kick_case())
{
case TbotsProto::AutoChipOrKick::kAutokickSpeedMPerS:
nanopb_control.chicker.chicker_command.auto_chip_or_kick
Expand All @@ -160,7 +162,7 @@ TbotsProto_PowerPulseControl inline createNanoPbPowerPulseControl(
nanopb_control.chicker.chicker_command.auto_chip_or_kick
.auto_chip_or_kick.autokick_pulse_width = static_cast<uint32_t>(
kick_constant *
std::exp(kick_coeff * google_control.chicker()
std::exp(kick_coeff * power_control.chicker()
.auto_chip_or_kick()
.autokick_speed_m_per_s()));
break;
Expand All @@ -179,7 +181,7 @@ TbotsProto_PowerPulseControl inline createNanoPbPowerPulseControl(
default:
break;
}
switch (google_control.geneva_slot())
switch (power_control.geneva_slot())
{
case TbotsProto::Geneva::LEFT:
nanopb_control.geneva_slot = TbotsProto_Geneva_Slot_LEFT;
Expand Down
24 changes: 12 additions & 12 deletions src/proto/message_translation/power_frame_msg_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
#include <gtest/gtest.h>
#include <proto/power_frame_msg.nanopb.h>

TEST(PowerFrameMsgTest, google_to_nanopb)
TEST(PowerFrameMsgTest, proto_to_nanopb)
{
auto google_control = TbotsProto::PowerControl();
google_control.mutable_chicker()->set_chip_distance_meters(3);
auto nanopb_control = createNanoPbPowerPulseControl(google_control, 0, 0, 100);
auto power_control = TbotsProto::PowerControl();
power_control.mutable_chicker()->set_chip_distance_meters(3);
auto nanopb_control = createNanoPbPowerPulseControl(power_control, 0, 0, 100);
EXPECT_EQ(nanopb_control.chicker.which_chicker_command,
TbotsProto_PowerPulseControl_ChickerControl_chip_pulse_width_tag);
EXPECT_EQ(nanopb_control.chicker.chicker_command.chip_pulse_width, 100);

google_control.mutable_chicker()->set_kick_speed_m_per_s(5);
nanopb_control = createNanoPbPowerPulseControl(google_control, 0.3, 300, 0);
power_control.mutable_chicker()->set_kick_speed_m_per_s(5);
nanopb_control = createNanoPbPowerPulseControl(power_control, 0.3, 300, 0);
EXPECT_EQ(nanopb_control.chicker.which_chicker_command,
TbotsProto_PowerPulseControl_ChickerControl_kick_pulse_width_tag);
EXPECT_EQ(nanopb_control.chicker.chicker_command.kick_pulse_width,
static_cast<int>(300 * std::exp(0.3 * 5)));

google_control.mutable_chicker()
power_control.mutable_chicker()
->mutable_auto_chip_or_kick()
->set_autokick_speed_m_per_s(4);
nanopb_control = createNanoPbPowerPulseControl(google_control, 0.1, 3, 0);
nanopb_control = createNanoPbPowerPulseControl(power_control, 0.1, 3, 0);
EXPECT_EQ(nanopb_control.chicker.which_chicker_command,
TbotsProto_PowerPulseControl_ChickerControl_auto_chip_or_kick_tag);
EXPECT_EQ(
Expand All @@ -32,10 +32,10 @@ TEST(PowerFrameMsgTest, google_to_nanopb)
.autokick_pulse_width,
static_cast<int>(3 * std::exp(4 * 0.1)));

google_control.mutable_chicker()
power_control.mutable_chicker()
->mutable_auto_chip_or_kick()
->set_autokick_speed_m_per_s(6);
nanopb_control = createNanoPbPowerPulseControl(google_control, 10000, 10000, 0);
nanopb_control = createNanoPbPowerPulseControl(power_control, 10000, 10000, 0);
EXPECT_EQ(nanopb_control.chicker.which_chicker_command,
TbotsProto_PowerPulseControl_ChickerControl_auto_chip_or_kick_tag);
EXPECT_EQ(
Expand All @@ -45,10 +45,10 @@ TEST(PowerFrameMsgTest, google_to_nanopb)
.autokick_pulse_width,
static_cast<int>(MAX_KICK_CONSTANT * std::exp(6 * MAX_KICK_COEFFICIENT)));

google_control.mutable_chicker()
power_control.mutable_chicker()
->mutable_auto_chip_or_kick()
->set_autochip_distance_meters(2);
nanopb_control = createNanoPbPowerPulseControl(google_control, 0, 0, 200);
nanopb_control = createNanoPbPowerPulseControl(power_control, 0, 0, 200);
EXPECT_EQ(nanopb_control.chicker.which_chicker_command,
TbotsProto_PowerPulseControl_ChickerControl_auto_chip_or_kick_tag);
EXPECT_EQ(
Expand Down
7 changes: 4 additions & 3 deletions src/shared/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ static const unsigned int MAX_ROBOT_IDS_PER_SIDE = 8;
// The total number of possible robot ids between two teams
static const unsigned int MAX_ROBOT_IDS = MAX_ROBOT_IDS_PER_SIDE * 2;

// How many robots are allowed in each division
static const unsigned int DIV_A_NUM_ROBOTS = 11;
static const unsigned int DIV_B_NUM_ROBOTS = 6;

// The maximum time in seconds given to Full System to cleanly exit the process.
static const double MAX_TIME_TO_EXIT_FULL_SYSTEM_SEC = 0.5;

Expand All @@ -173,9 +177,6 @@ static const double MAX_CAPACITOR_VOLTAGE = 250.0 + 50.0; // +50v headroom

static const unsigned int ROBOT_CHIP_ANGLE_DEGREES = 45;
static const double CHICKER_TIMEOUT = 3 * MILLISECONDS_PER_SECOND;
// How many robots are allowed in each division
static const unsigned DIV_A_NUM_ROBOTS = 11;
static const unsigned DIV_B_NUM_ROBOTS = 6;

// Kick Spd to Pulse Width Safety Constraint Constants

Expand Down
4 changes: 2 additions & 2 deletions src/software/field_tests/field_test_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from software.thunderscope.proto_unix_io import ProtoUnixIO
from software.thunderscope.binary_context_managers.full_system import FullSystem
from software.thunderscope.binary_context_managers.game_controller import Gamecontroller
from software.logger.logger import createLogger
from software.logger.logger import create_logger


from software.thunderscope.thunderscope_config import configure_field_test_view
Expand All @@ -22,7 +22,7 @@
from software.thunderscope.estop_helpers import get_estop_config
from software.py_constants import *

logger = createLogger(__name__)
logger = create_logger(__name__)

WORLD_BUFFER_TIMEOUT = 5.0
PROCESS_BUFFER_DELAY_S = 0.01
Expand Down
4 changes: 2 additions & 2 deletions src/software/field_tests/movement_robot_field_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from software.field_tests.field_test_fixture import *

from software.simulated_tests.simulated_test_fixture import *
from software.logger.logger import createLogger
from software.logger.logger import create_logger
import math

logger = createLogger(__name__)
logger = create_logger(__name__)


# TODO 2908: Support running this test in both simulator or field mode
Expand Down
4 changes: 2 additions & 2 deletions src/software/field_tests/pivot_kick_field_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from software.field_tests.field_test_fixture import *

from software.simulated_tests.simulated_test_fixture import *
from software.logger.logger import createLogger
from software.logger.logger import create_logger

logger = createLogger(__name__)
logger = create_logger(__name__)


def test_pivot_kick(field_test_runner):
Expand Down
10 changes: 5 additions & 5 deletions src/software/logger/logger.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import logging
from logging import Logger, basicConfig, getLogger, INFO

logging.basicConfig(
level=logging.INFO,
basicConfig(
level=INFO,
format="%(asctime)s - [%(levelname)s] - [%(threadName)s] - %(name)s - (%(filename)s).%(funcName)s(%(lineno)d) - %(message)s",
)


def createLogger(name):
def create_logger(name) -> Logger:
"""Create a logger given the name of the logger

:return: A Logger
"""
return logging.getLogger(name)
return getLogger(name)
4 changes: 2 additions & 2 deletions src/software/networking/unix/threaded_unix_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import queue
import socketserver
from threading import Thread
from software.logger.logger import createLogger
from software.logger.logger import create_logger
from software import py_constants

logger = createLogger(__name__)
logger = create_logger(__name__)


class ThreadedUnixListener:
Expand Down
4 changes: 2 additions & 2 deletions src/software/simulated_tests/simulated_test_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from software.thunderscope.binary_context_managers.game_controller import Gamecontroller
from software.thunderscope.thunderscope_config import configure_simulated_test_view

from software.logger.logger import createLogger
from software.logger.logger import create_logger

logger = createLogger(__name__)
logger = create_logger(__name__)

LAUNCH_DELAY_S = 0.1
WORLD_BUFFER_TIMEOUT = 0.5
Expand Down
4 changes: 2 additions & 2 deletions src/software/simulated_tests/tbots_test_runner.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from proto.import_all_protos import *
from software.logger.logger import createLogger
from software.logger.logger import create_logger
from software.thunderscope.thread_safe_buffer import ThreadSafeBuffer
from proto.ssl_gc_common_pb2 import Team


logger = createLogger(__name__)
logger = create_logger(__name__)


class TbotsTestRunner:
Expand Down
3 changes: 2 additions & 1 deletion src/software/thunderscope/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ py_library(
"//software/thunderscope/play:refereeinfo_widget",
"//software/thunderscope/replay:proto_player",
"//software/thunderscope/robot_diagnostics:chicker",
"//software/thunderscope/robot_diagnostics:diagnostics_input_widget",
"//software/thunderscope/robot_diagnostics:diagnostics_widget",
"//software/thunderscope/robot_diagnostics:drive_and_dribbler_widget",
"//software/thunderscope/robot_diagnostics:estop_view",
"//software/thunderscope/robot_diagnostics:robot_error_log",
Expand Down Expand Up @@ -161,6 +161,7 @@ py_library(
"//software:py_constants.so",
],
deps = [
"//software/logger:py_logger",
"//software/thunderscope:constants",
],
)
Expand Down
50 changes: 32 additions & 18 deletions src/software/thunderscope/common/common_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def setValue(self, value: float) -> None:

:param value: the float value to set
"""
super(ColorProgressBar, self).setValue(value * self.decimals)
super(ColorProgressBar, self).setValue(int(value * self.decimals))

# clamp percent to make sure it's between 0% and 100%
percent = self.getPercentage()
Expand Down Expand Up @@ -380,30 +380,46 @@ def set_table_data(
table.setHorizontalHeaderLabels(horizontal_headers)


def change_button_state(button, enable):
"""Change button color and clickable state.
def disconnect_signal(signal: QtCore.Signal):
"""Helper function to disconnect all connections for a Qt signal.
Suppresses TypeErrors thrown by Signal.disconnect() if there are no connections.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh weird that this is the only way we have to disconnect the signal

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qt sucks

"""
try:
signal.disconnect()
except TypeError:
pass


def enable_button(button):
"""Enables the given button and sets the button UI to reflect that
visually to the user.

:param button: button to change the state of
"""
button.setStyleSheet("")
button.setEnabled(True)


def disable_button(button):
"""Disables the given button and sets the button UI to reflect that
visually to the user.

:param button: button to change the state of
:param enable: bool: if True: enable this button, if False: disable
"""
if enable:
button.setStyleSheet("background-color: White")
button.setCheckable(True)
else:
button.setStyleSheet("background-color: Grey")
button.setCheckable(False)
button.setStyleSheet("background-color: grey")
button.setEnabled(False)


def disable_slider(slider):
"""Disables a slider by getting the current value and setting the slider to that
value upon every value change
value every time the slider is moved

This results in slider value not changing even when slider is moved

:param slider: slider widget to be disabled
"""
old_val = slider.value()
slider.valueChanged.connect(lambda: slider.setValue(old_val))
slider.sliderMoved.connect(lambda new_val: slider.setValue(old_val))
slider.setStyleSheet(
"QSlider::sub-page:horizontal"
"{"
Expand All @@ -417,15 +433,13 @@ def disable_slider(slider):
)


def enable_slider(slider, label, get_value):
"""Enables a slider by connecting a function to update label upon value change
def enable_slider(slider):
"""Enables a slider that was disabled with disable_slider

:param slider: slider widget to be enabled
:param label: label widget corresponding to the slider
:param get_value: function to translate slider value into label text
"""
slider.valueChanged.connect(lambda: label.setText(get_value(slider.value())))
slider.setStyleSheet("QSlider::groove:horizontal" "{" "border-width: 0px" "}")
disconnect_signal(slider.sliderMoved)
slider.setStyleSheet("")


def disable_radio_button(button_group):
Expand Down
Loading
Loading