Merge "[orin] Remove CPU scaling settings from chrt script"
diff --git a/frc971/wpilib/generic_can_writer.h b/frc971/wpilib/generic_can_writer.h
index 7555c0a..f317b59 100644
--- a/frc971/wpilib/generic_can_writer.h
+++ b/frc971/wpilib/generic_can_writer.h
@@ -15,9 +15,9 @@
public:
GenericCANWriter(
::aos::EventLoop *event_loop,
- std::function<
- void(const T &output,
- std::map<std::string, std::shared_ptr<TalonFX>> talonfx_map)>
+ std::function<void(
+ const T &output,
+ std::map<std::string_view, std::shared_ptr<TalonFX>> talonfx_map)>
write_callback)
: LoopOutputHandler<T>(event_loop, "/superstructure"),
write_callback_(write_callback) {
@@ -66,7 +66,7 @@
std::function<void(
const T &output,
- std::map<std::string, std::shared_ptr<TalonFX>> talonfx_map)>
+ std::map<std::string_view, std::shared_ptr<TalonFX>> talonfx_map)>
write_callback_;
};
diff --git a/scouting/db/db.go b/scouting/db/db.go
index 578edb6..cf1c823 100644
--- a/scouting/db/db.go
+++ b/scouting/db/db.go
@@ -82,7 +82,7 @@
type NotesData struct {
ID uint `gorm:"primaryKey"`
- TeamNumber int32
+ TeamNumber string
Notes string
GoodDriving bool
BadDriving bool
@@ -94,7 +94,7 @@
}
type Ranking struct {
- TeamNumber int `gorm:"primaryKey"`
+ TeamNumber string `gorm:"primaryKey"`
Losses, Wins, Ties int32
Rank, Dq int32
}
@@ -108,9 +108,9 @@
ID uint `gorm:"primaryKey"`
MatchNumber int32
- Rank1 int32
- Rank2 int32
- Rank3 int32
+ Rank1 string
+ Rank2 string
+ Rank3 string
}
type ParsedDriverRankingData struct {
@@ -340,14 +340,14 @@
return shifts, result.Error
}
-func (database *Database) QueryActions(teamNumber_ int) ([]Action, error) {
+func (database *Database) QueryActions(teamNumber_ string) ([]Action, error) {
var actions []Action
result := database.
Where("team_number = ?", teamNumber_).Find(&actions)
return actions, result.Error
}
-func (database *Database) QueryNotes(TeamNumber int32) ([]string, error) {
+func (database *Database) QueryNotes(TeamNumber string) ([]string, error) {
var rawNotes []NotesData
result := database.Where("team_number = ?", TeamNumber).Find(&rawNotes)
if result.Error != nil {
@@ -361,7 +361,7 @@
return notes, nil
}
-func (database *Database) QueryRankings(TeamNumber int) ([]Ranking, error) {
+func (database *Database) QueryRankings(TeamNumber string) ([]Ranking, error) {
var rankins []Ranking
result := database.Where("team_number = ?", TeamNumber).Find(&rankins)
return rankins, result.Error
diff --git a/scouting/db/db_test.go b/scouting/db/db_test.go
index 94dce7e..d7001b8 100644
--- a/scouting/db/db_test.go
+++ b/scouting/db/db_test.go
@@ -114,12 +114,12 @@
correct := []Ranking{
Ranking{
- TeamNumber: 123,
+ TeamNumber: "123",
Losses: 1, Wins: 7, Ties: 0,
Rank: 2, Dq: 0,
},
Ranking{
- TeamNumber: 125,
+ TeamNumber: "125",
Losses: 2, Wins: 4, Ties: 0,
Rank: 2, Dq: 0,
},
@@ -691,22 +691,22 @@
testDatabase := []Ranking{
Ranking{
- TeamNumber: 123,
+ TeamNumber: "123",
Losses: 1, Wins: 7, Ties: 2,
Rank: 2, Dq: 0,
},
Ranking{
- TeamNumber: 124,
+ TeamNumber: "124",
Losses: 3, Wins: 4, Ties: 0,
Rank: 4, Dq: 2,
},
Ranking{
- TeamNumber: 125,
+ TeamNumber: "125",
Losses: 5, Wins: 2, Ties: 0,
Rank: 17, Dq: 0,
},
Ranking{
- TeamNumber: 126,
+ TeamNumber: "126",
Losses: 0, Wins: 7, Ties: 0,
Rank: 5, Dq: 0,
},
@@ -719,13 +719,13 @@
correct := []Ranking{
Ranking{
- TeamNumber: 126,
+ TeamNumber: "126",
Losses: 0, Wins: 7, Ties: 0,
Rank: 5, Dq: 0,
},
}
- got, err := fixture.db.QueryRankings(126)
+ got, err := fixture.db.QueryRankings("126")
check(t, err, "Failed QueryRankings()")
if !reflect.DeepEqual(correct, got) {
@@ -830,22 +830,22 @@
correct := []Ranking{
Ranking{
- TeamNumber: 123,
+ TeamNumber: "123",
Losses: 1, Wins: 7, Ties: 2,
Rank: 2, Dq: 0,
},
Ranking{
- TeamNumber: 124,
+ TeamNumber: "124",
Losses: 3, Wins: 4, Ties: 0,
Rank: 4, Dq: 2,
},
Ranking{
- TeamNumber: 125,
+ TeamNumber: "125",
Losses: 5, Wins: 2, Ties: 0,
Rank: 17, Dq: 0,
},
Ranking{
- TeamNumber: 126,
+ TeamNumber: "126",
Losses: 0, Wins: 7, Ties: 0,
Rank: 5, Dq: 0,
},
@@ -1021,27 +1021,27 @@
testDatabase := []Ranking{
Ranking{
- TeamNumber: 123,
+ TeamNumber: "123",
Losses: 1, Wins: 7, Ties: 2,
Rank: 2, Dq: 0,
},
Ranking{
- TeamNumber: 124,
+ TeamNumber: "124",
Losses: 3, Wins: 4, Ties: 0,
Rank: 4, Dq: 2,
},
Ranking{
- TeamNumber: 125,
+ TeamNumber: "125",
Losses: 5, Wins: 2, Ties: 0,
Rank: 17, Dq: 0,
},
Ranking{
- TeamNumber: 126,
+ TeamNumber: "126",
Losses: 0, Wins: 7, Ties: 0,
Rank: 5, Dq: 0,
},
Ranking{
- TeamNumber: 125,
+ TeamNumber: "125",
Losses: 2, Wins: 4, Ties: 1,
Rank: 5, Dq: 0,
},
@@ -1054,13 +1054,13 @@
correct := []Ranking{
Ranking{
- TeamNumber: 125,
+ TeamNumber: "125",
Losses: 2, Wins: 4, Ties: 1,
Rank: 5, Dq: 0,
},
}
- got, err := fixture.db.QueryRankings(125)
+ got, err := fixture.db.QueryRankings("125")
check(t, err, "Failed QueryRankings()")
checkDeepEqual(t, correct, got)
@@ -1072,14 +1072,14 @@
expected := []string{"Note 1", "Note 3"}
- err := fixture.db.AddNotes(NotesData{TeamNumber: 1234, Notes: "Note 1", GoodDriving: true, BadDriving: false, SolidPlacing: false, SketchyPlacing: true, GoodDefense: false, BadDefense: true, EasilyDefended: true})
+ err := fixture.db.AddNotes(NotesData{TeamNumber: "1234", Notes: "Note 1", GoodDriving: true, BadDriving: false, SolidPlacing: false, SketchyPlacing: true, GoodDefense: false, BadDefense: true, EasilyDefended: true})
check(t, err, "Failed to add Note")
- err = fixture.db.AddNotes(NotesData{TeamNumber: 1235, Notes: "Note 2", GoodDriving: false, BadDriving: true, SolidPlacing: false, SketchyPlacing: true, GoodDefense: false, BadDefense: false, EasilyDefended: false})
+ err = fixture.db.AddNotes(NotesData{TeamNumber: "1235", Notes: "Note 2", GoodDriving: false, BadDriving: true, SolidPlacing: false, SketchyPlacing: true, GoodDefense: false, BadDefense: false, EasilyDefended: false})
check(t, err, "Failed to add Note")
- err = fixture.db.AddNotes(NotesData{TeamNumber: 1234, Notes: "Note 3", GoodDriving: true, BadDriving: false, SolidPlacing: false, SketchyPlacing: true, GoodDefense: true, BadDefense: false, EasilyDefended: true})
+ err = fixture.db.AddNotes(NotesData{TeamNumber: "1234", Notes: "Note 3", GoodDriving: true, BadDriving: false, SolidPlacing: false, SketchyPlacing: true, GoodDefense: true, BadDefense: false, EasilyDefended: true})
check(t, err, "Failed to add Note")
- actual, err := fixture.db.QueryNotes(1234)
+ actual, err := fixture.db.QueryNotes("1234")
check(t, err, "Failed to get Notes")
if !reflect.DeepEqual(expected, actual) {
@@ -1092,20 +1092,20 @@
defer fixture.TearDown()
expected := []DriverRankingData{
- {ID: 1, MatchNumber: 12, Rank1: 1234, Rank2: 1235, Rank3: 1236},
- {ID: 2, MatchNumber: 12, Rank1: 1236, Rank2: 1235, Rank3: 1234},
+ {ID: 1, MatchNumber: 12, Rank1: "1234", Rank2: "1235", Rank3: "1236"},
+ {ID: 2, MatchNumber: 12, Rank1: "1236", Rank2: "1235", Rank3: "1234"},
}
err := fixture.db.AddDriverRanking(
- DriverRankingData{MatchNumber: 12, Rank1: 1234, Rank2: 1235, Rank3: 1236},
+ DriverRankingData{MatchNumber: 12, Rank1: "1234", Rank2: "1235", Rank3: "1236"},
)
check(t, err, "Failed to add Driver Ranking")
err = fixture.db.AddDriverRanking(
- DriverRankingData{MatchNumber: 12, Rank1: 1236, Rank2: 1235, Rank3: 1234},
+ DriverRankingData{MatchNumber: 12, Rank1: "1236", Rank2: "1235", Rank3: "1234"},
)
check(t, err, "Failed to add Driver Ranking")
err = fixture.db.AddDriverRanking(
- DriverRankingData{MatchNumber: 13, Rank1: 1235, Rank2: 1234, Rank3: 1236},
+ DriverRankingData{MatchNumber: 13, Rank1: "1235", Rank2: "1234", Rank3: "1236"},
)
check(t, err, "Failed to add Driver Ranking")
diff --git a/scouting/webserver/driver_ranking/driver_ranking.go b/scouting/webserver/driver_ranking/driver_ranking.go
index 82e34e1..82445bf 100644
--- a/scouting/webserver/driver_ranking/driver_ranking.go
+++ b/scouting/webserver/driver_ranking/driver_ranking.go
@@ -76,9 +76,9 @@
// Most of the data is unused so we just fill in empty
// strings.
"", "", "", "",
- strconv.Itoa(int(ranking.Rank1)),
- strconv.Itoa(int(ranking.Rank2)),
- strconv.Itoa(int(ranking.Rank3)),
+ ranking.Rank1,
+ ranking.Rank2,
+ ranking.Rank3,
})
}
diff --git a/scouting/webserver/driver_ranking/driver_ranking_test.go b/scouting/webserver/driver_ranking/driver_ranking_test.go
index 47a412e..98a60e8 100644
--- a/scouting/webserver/driver_ranking/driver_ranking_test.go
+++ b/scouting/webserver/driver_ranking/driver_ranking_test.go
@@ -28,8 +28,8 @@
func TestDriverRankingRun(t *testing.T) {
var database MockDatabase
database.rawRankings = []db.DriverRankingData{
- db.DriverRankingData{MatchNumber: 1, Rank1: 1234, Rank2: 1235, Rank3: 1236},
- db.DriverRankingData{MatchNumber: 2, Rank1: 971, Rank2: 972, Rank3: 973},
+ db.DriverRankingData{MatchNumber: 1, Rank1: "1234", Rank2: "1235", Rank3: "1236"},
+ db.DriverRankingData{MatchNumber: 2, Rank1: "971", Rank2: "972", Rank3: "973"},
}
GenerateFullDriverRanking(&database, "./fake_driver_rank_script")
diff --git a/scouting/webserver/match_list/match_list.go b/scouting/webserver/match_list/match_list.go
index c5af661..2ac5133 100644
--- a/scouting/webserver/match_list/match_list.go
+++ b/scouting/webserver/match_list/match_list.go
@@ -6,7 +6,6 @@
"github.com/frc971/971-Robot-Code/scouting/db"
"github.com/frc971/971-Robot-Code/scouting/scraping"
"log"
- "strconv"
"strings"
)
@@ -14,66 +13,32 @@
AddToMatch(db.TeamMatch) error
}
-func parseTeamKey(teamKey string) (int, error) {
+func parseTeamKey(teamKey string) string {
// TBA prefixes teams with "frc". Not sure why. Get rid of that.
teamKey = strings.TrimPrefix(teamKey, "frc")
- magnitude := 0
- if strings.HasSuffix(teamKey, "A") {
- magnitude = 0
- teamKey = strings.TrimSuffix(teamKey, "A")
- } else if strings.HasSuffix(teamKey, "B") {
- magnitude = 9
- teamKey = strings.TrimSuffix(teamKey, "B")
- } else if strings.HasSuffix(teamKey, "C") {
- magnitude = 8
- teamKey = strings.TrimSuffix(teamKey, "C")
- } else if strings.HasSuffix(teamKey, "D") {
- magnitude = 7
- teamKey = strings.TrimSuffix(teamKey, "D")
- } else if strings.HasSuffix(teamKey, "E") {
- magnitude = 6
- teamKey = strings.TrimSuffix(teamKey, "E")
- } else if strings.HasSuffix(teamKey, "F") {
- magnitude = 5
- teamKey = strings.TrimSuffix(teamKey, "F")
- }
-
- if magnitude != 0 {
- teamKey = strconv.Itoa(magnitude) + teamKey
- }
-
- result, err := strconv.Atoi(teamKey)
- return result, err
+ return teamKey
}
// Parses the alliance data from the specified match and returns the three red
// teams and the three blue teams.
-func parseTeamKeys(match *scraping.Match) ([3]int32, [3]int32, error) {
+func parseTeamKeys(match *scraping.Match) ([3]string, [3]string, error) {
redKeys := match.Alliances.Red.TeamKeys
blueKeys := match.Alliances.Blue.TeamKeys
if len(redKeys) != 3 || len(blueKeys) != 3 {
- return [3]int32{}, [3]int32{}, errors.New(fmt.Sprintf(
+ return [3]string{}, [3]string{}, errors.New(fmt.Sprintf(
"Found %d red teams and %d blue teams.", len(redKeys), len(blueKeys)))
}
- var red [3]int32
+ var red [3]string
for i, key := range redKeys {
- team, err := parseTeamKey(key)
- if err != nil {
- return [3]int32{}, [3]int32{}, errors.New(fmt.Sprintf(
- "Failed to parse red %d team '%s' as integer: %v", i+1, key, err))
- }
- red[i] = int32(team)
+ team := parseTeamKey(key)
+ red[i] = team
}
- var blue [3]int32
+ var blue [3]string
for i, key := range blueKeys {
- team, err := parseTeamKey(key)
- if err != nil {
- return [3]int32{}, [3]int32{}, errors.New(fmt.Sprintf(
- "Failed to parse blue %d team '%s' as integer: %v", i+1, key, err))
- }
- blue[i] = int32(team)
+ team := parseTeamKey(key)
+ blue[i] = team
}
return red, blue, nil
}
@@ -97,32 +62,32 @@
{
MatchNumber: int32(match.MatchNumber),
SetNumber: int32(match.SetNumber), CompLevel: match.CompLevel,
- Alliance: "R", AlliancePosition: 1, TeamNumber: strconv.Itoa(int(red[0])),
+ Alliance: "R", AlliancePosition: 1, TeamNumber: red[0],
},
{
MatchNumber: int32(match.MatchNumber),
SetNumber: int32(match.SetNumber), CompLevel: match.CompLevel,
- Alliance: "R", AlliancePosition: 2, TeamNumber: strconv.Itoa(int(red[1])),
+ Alliance: "R", AlliancePosition: 2, TeamNumber: red[1],
},
{
MatchNumber: int32(match.MatchNumber),
SetNumber: int32(match.SetNumber), CompLevel: match.CompLevel,
- Alliance: "R", AlliancePosition: 3, TeamNumber: strconv.Itoa(int(red[2])),
+ Alliance: "R", AlliancePosition: 3, TeamNumber: red[2],
},
{
MatchNumber: int32(match.MatchNumber),
SetNumber: int32(match.SetNumber), CompLevel: match.CompLevel,
- Alliance: "B", AlliancePosition: 1, TeamNumber: strconv.Itoa(int(blue[0])),
+ Alliance: "B", AlliancePosition: 1, TeamNumber: blue[0],
},
{
MatchNumber: int32(match.MatchNumber),
SetNumber: int32(match.SetNumber), CompLevel: match.CompLevel,
- Alliance: "B", AlliancePosition: 2, TeamNumber: strconv.Itoa(int(blue[1])),
+ Alliance: "B", AlliancePosition: 2, TeamNumber: blue[1],
},
{
MatchNumber: int32(match.MatchNumber),
SetNumber: int32(match.SetNumber), CompLevel: match.CompLevel,
- Alliance: "B", AlliancePosition: 3, TeamNumber: strconv.Itoa(int(blue[2])),
+ Alliance: "B", AlliancePosition: 3, TeamNumber: blue[2],
},
}
diff --git a/scouting/webserver/rankings/rankings.go b/scouting/webserver/rankings/rankings.go
index 0d20b54..9ffa503 100644
--- a/scouting/webserver/rankings/rankings.go
+++ b/scouting/webserver/rankings/rankings.go
@@ -4,7 +4,6 @@
"github.com/frc971/971-Robot-Code/scouting/db"
"github.com/frc971/971-Robot-Code/scouting/scraping"
"log"
- "strconv"
"strings"
)
@@ -12,10 +11,10 @@
AddOrUpdateRankings(db.Ranking) error
}
-func parseTeamKey(teamKey string) (int, error) {
+func parseTeamKey(teamKey string) string {
// TBA prefixes teams with "frc". Not sure why. Get rid of that.
teamKey = strings.TrimPrefix(teamKey, "frc")
- return strconv.Atoi(teamKey)
+ return teamKey
}
func GetRankings(database Database, year int32, eventCode string, blueAllianceConfig string) {
@@ -26,12 +25,7 @@
}
for _, rank := range rankings.Rankings {
- teamKey, err := parseTeamKey(rank.TeamKey)
-
- if err != nil {
- log.Println("Failed to parse team key: ", err)
- continue
- }
+ teamKey := parseTeamKey(rank.TeamKey)
rankingInfo := db.Ranking{
TeamNumber: teamKey,
diff --git a/scouting/webserver/rankings/rankings_test.go b/scouting/webserver/rankings/rankings_test.go
index 4ab3c34..748bcf8 100644
--- a/scouting/webserver/rankings/rankings_test.go
+++ b/scouting/webserver/rankings/rankings_test.go
@@ -58,15 +58,15 @@
}
beginningThreeExpected := []db.Ranking{
- {TeamNumber: 359, Losses: 1, Wins: 11, Ties: 0, Rank: 1, Dq: 0},
- {TeamNumber: 5254, Losses: 1, Wins: 11, Ties: 0, Rank: 2, Dq: 0},
- {TeamNumber: 3990, Losses: 1, Wins: 11, Ties: 0, Rank: 3, Dq: 0},
+ {TeamNumber: "359", Losses: 1, Wins: 11, Ties: 0, Rank: 1, Dq: 0},
+ {TeamNumber: "5254", Losses: 1, Wins: 11, Ties: 0, Rank: 2, Dq: 0},
+ {TeamNumber: "3990", Losses: 1, Wins: 11, Ties: 0, Rank: 3, Dq: 0},
}
endThreeExpected := []db.Ranking{
- {TeamNumber: 5943, Losses: 10, Wins: 2, Ties: 0, Rank: 34, Dq: 0},
- {TeamNumber: 4203, Losses: 10, Wins: 2, Ties: 0, Rank: 35, Dq: 0},
- {TeamNumber: 5149, Losses: 10, Wins: 2, Ties: 0, Rank: 36, Dq: 0},
+ {TeamNumber: "5943", Losses: 10, Wins: 2, Ties: 0, Rank: 34, Dq: 0},
+ {TeamNumber: "4203", Losses: 10, Wins: 2, Ties: 0, Rank: 35, Dq: 0},
+ {TeamNumber: "5149", Losses: 10, Wins: 2, Ties: 0, Rank: 36, Dq: 0},
}
if !reflect.DeepEqual(beginningThreeExpected, database.rankings[0:3]) {
diff --git a/scouting/webserver/requests/debug/cli/cli_test.py b/scouting/webserver/requests/debug/cli/cli_test.py
index b944564..d11b506 100644
--- a/scouting/webserver/requests/debug/cli/cli_test.py
+++ b/scouting/webserver/requests/debug/cli/cli_test.py
@@ -101,7 +101,7 @@
# First submit some data to be added to the database.
json_path = write_json_request({
- "team": 100,
+ "team": "100",
"notes": "A very inspiring and useful comment",
"good_driving": True,
"bad_driving": False,
@@ -124,7 +124,7 @@
self.assertIn(
textwrap.dedent("""\
{
- Team: (int32) 100,
+ Team: (string) (len=3) "100",
Notes: (string) (len=35) "A very inspiring and useful comment",
GoodDriving: (bool) true,
BadDriving: (bool) false,
@@ -140,10 +140,10 @@
# First submit some data to be added to the database.
json_path = write_json_request({
- "matchNumber": 100,
- "rank1": 101,
- "rank2": 202,
- "rank3": 303,
+ "match_number": 100,
+ "rank1": "101",
+ "rank2": "202",
+ "rank3": "303",
})
exit_code, _, stderr = run_debug_cli(
["-submitDriverRanking", json_path])
@@ -160,9 +160,9 @@
textwrap.dedent("""\
{
MatchNumber: (int32) 100,
- Rank1: (int32) 101,
- Rank2: (int32) 202,
- Rank3: (int32) 303
+ Rank1: (string) (len=3) "101",
+ Rank2: (string) (len=3) "202",
+ Rank3: (string) (len=3) "303"
}"""), stdout)
def test_request_all_matches(self):
diff --git a/scouting/webserver/requests/messages/request_all_driver_rankings_response.fbs b/scouting/webserver/requests/messages/request_all_driver_rankings_response.fbs
index dcc9712..8ce0ef2 100644
--- a/scouting/webserver/requests/messages/request_all_driver_rankings_response.fbs
+++ b/scouting/webserver/requests/messages/request_all_driver_rankings_response.fbs
@@ -1,10 +1,10 @@
namespace scouting.webserver.requests;
table Ranking {
- matchNumber:int (id: 0);
- rank1:int (id: 1);
- rank2:int (id: 2);
- rank3:int (id: 3);
+ match_number:int (id: 0);
+ rank1:string (id: 1);
+ rank2:string (id: 2);
+ rank3:string (id: 3);
}
table RequestAllDriverRankingsResponse {
diff --git a/scouting/webserver/requests/messages/request_all_notes_response.fbs b/scouting/webserver/requests/messages/request_all_notes_response.fbs
index 70504d3..1afdf25 100644
--- a/scouting/webserver/requests/messages/request_all_notes_response.fbs
+++ b/scouting/webserver/requests/messages/request_all_notes_response.fbs
@@ -1,7 +1,7 @@
namespace scouting.webserver.requests;
table Note {
- team:int (id: 0);
+ team:string (id: 0);
notes:string (id: 1);
good_driving:bool (id: 2);
bad_driving:bool (id: 3);
diff --git a/scouting/webserver/requests/messages/request_notes_for_team.fbs b/scouting/webserver/requests/messages/request_notes_for_team.fbs
index 9bda6d3..aa93a2b 100644
--- a/scouting/webserver/requests/messages/request_notes_for_team.fbs
+++ b/scouting/webserver/requests/messages/request_notes_for_team.fbs
@@ -1,7 +1,7 @@
namespace scouting.webserver.requests;
table RequestNotesForTeam {
- team:int (id: 0);
+ team:string (id: 0);
}
root_type RequestNotesForTeam;
diff --git a/scouting/webserver/requests/messages/submit_driver_ranking.fbs b/scouting/webserver/requests/messages/submit_driver_ranking.fbs
index ac1e218..052728c 100644
--- a/scouting/webserver/requests/messages/submit_driver_ranking.fbs
+++ b/scouting/webserver/requests/messages/submit_driver_ranking.fbs
@@ -1,10 +1,10 @@
namespace scouting.webserver.requests;
table SubmitDriverRanking {
- matchNumber:int (id: 0);
- rank1:int (id: 1);
- rank2:int (id: 2);
- rank3:int (id: 3);
+ match_number:int (id: 0);
+ rank1:string (id: 1);
+ rank2:string (id: 2);
+ rank3:string (id: 3);
}
root_type SubmitDriverRanking;
diff --git a/scouting/webserver/requests/messages/submit_notes.fbs b/scouting/webserver/requests/messages/submit_notes.fbs
index 845a601..332b612 100644
--- a/scouting/webserver/requests/messages/submit_notes.fbs
+++ b/scouting/webserver/requests/messages/submit_notes.fbs
@@ -1,7 +1,7 @@
namespace scouting.webserver.requests;
table SubmitNotes {
- team:int (id: 0);
+ team:string (id: 0);
notes:string (id: 1);
good_driving:bool (id: 2);
bad_driving:bool (id: 3);
diff --git a/scouting/webserver/requests/requests.go b/scouting/webserver/requests/requests.go
index 51612ff..af67386 100644
--- a/scouting/webserver/requests/requests.go
+++ b/scouting/webserver/requests/requests.go
@@ -84,7 +84,7 @@
ReturnStats2023() ([]db.Stats2023, error)
ReturnStats2023ForTeam(teamNumber string, matchNumber int32, setNumber int32, compLevel string, preScouting bool) ([]db.Stats2023, error)
QueryAllShifts(int) ([]db.Shift, error)
- QueryNotes(int32) ([]string, error)
+ QueryNotes(string) ([]string, error)
QueryPitImages(string) ([]db.RequestedPitImage, error)
AddNotes(db.NotesData) error
AddPitImage(db.PitImage) error
@@ -367,7 +367,7 @@
}
err = handler.db.AddNotes(db.NotesData{
- TeamNumber: request.Team(),
+ TeamNumber: string(request.Team()),
Notes: string(request.Notes()),
GoodDriving: bool(request.GoodDriving()),
BadDriving: bool(request.BadDriving()),
@@ -671,7 +671,7 @@
return
}
- notes, err := handler.db.QueryNotes(request.Team())
+ notes, err := handler.db.QueryNotes(string(request.Team()))
if err != nil {
respondWithError(w, http.StatusInternalServerError, fmt.Sprintf("Failed to query notes: %v", err))
return
@@ -790,9 +790,9 @@
err = handler.db.AddDriverRanking(db.DriverRankingData{
MatchNumber: request.MatchNumber(),
- Rank1: request.Rank1(),
- Rank2: request.Rank2(),
- Rank3: request.Rank3(),
+ Rank1: string(request.Rank1()),
+ Rank2: string(request.Rank2()),
+ Rank3: string(request.Rank3()),
})
if err != nil {
diff --git a/scouting/webserver/requests/requests_test.go b/scouting/webserver/requests/requests_test.go
index e50583b..0797bc1 100644
--- a/scouting/webserver/requests/requests_test.go
+++ b/scouting/webserver/requests/requests_test.go
@@ -449,7 +449,7 @@
builder := flatbuffers.NewBuilder(1024)
builder.Finish((&submit_notes.SubmitNotesT{
- Team: 971,
+ Team: "971",
Notes: "Notes",
GoodDriving: true,
BadDriving: false,
@@ -467,7 +467,7 @@
expected := []db.NotesData{
{
- TeamNumber: 971,
+ TeamNumber: "971",
Notes: "Notes",
GoodDriving: true,
BadDriving: false,
@@ -487,7 +487,7 @@
func TestRequestNotes(t *testing.T) {
database := MockDatabase{
notes: []db.NotesData{{
- TeamNumber: 971,
+ TeamNumber: "971A",
Notes: "Notes",
GoodDriving: true,
BadDriving: false,
@@ -505,7 +505,7 @@
builder := flatbuffers.NewBuilder(1024)
builder.Finish((&request_notes_for_team.RequestNotesForTeamT{
- Team: 971,
+ Team: "971A",
}).Pack(builder))
response, err := debug.RequestNotes("http://localhost:8080", builder.FinishedBytes())
if err != nil {
@@ -714,9 +714,9 @@
builder := flatbuffers.NewBuilder(1024)
builder.Finish((&submit_driver_ranking.SubmitDriverRankingT{
MatchNumber: 36,
- Rank1: 1234,
- Rank2: 1235,
- Rank3: 1236,
+ Rank1: "1234",
+ Rank2: "1235",
+ Rank3: "1236",
}).Pack(builder))
_, err := debug.SubmitDriverRanking("http://localhost:8080", builder.FinishedBytes())
@@ -725,7 +725,7 @@
}
expected := []db.DriverRankingData{
- {MatchNumber: 36, Rank1: 1234, Rank2: 1235, Rank3: 1236},
+ {MatchNumber: 36, Rank1: "1234", Rank2: "1235", Rank3: "1236"},
}
if !reflect.DeepEqual(database.driver_ranking, expected) {
@@ -739,15 +739,15 @@
driver_ranking: []db.DriverRankingData{
{
MatchNumber: 36,
- Rank1: 1234,
- Rank2: 1235,
- Rank3: 1236,
+ Rank1: "1234",
+ Rank2: "1235",
+ Rank3: "1236",
},
{
MatchNumber: 36,
- Rank1: 101,
- Rank2: 202,
- Rank3: 303,
+ Rank1: "101",
+ Rank2: "202",
+ Rank3: "303",
},
},
}
@@ -768,15 +768,15 @@
DriverRankingList: []*request_all_driver_rankings_response.RankingT{
{
MatchNumber: 36,
- Rank1: 1234,
- Rank2: 1235,
- Rank3: 1236,
+ Rank1: "1234",
+ Rank2: "1235",
+ Rank3: "1236",
},
{
MatchNumber: 36,
- Rank1: 101,
- Rank2: 202,
- Rank3: 303,
+ Rank1: "101",
+ Rank2: "202",
+ Rank3: "303",
},
},
}
@@ -795,7 +795,7 @@
db := MockDatabase{
notes: []db.NotesData{
{
- TeamNumber: 971,
+ TeamNumber: "971",
Notes: "Notes",
GoodDriving: true,
BadDriving: false,
@@ -806,7 +806,7 @@
EasilyDefended: false,
},
{
- TeamNumber: 972,
+ TeamNumber: "972",
Notes: "More Notes",
GoodDriving: false,
BadDriving: false,
@@ -834,7 +834,7 @@
expected := request_all_notes_response.RequestAllNotesResponseT{
NoteList: []*request_all_notes_response.NoteT{
{
- Team: 971,
+ Team: "971",
Notes: "Notes",
GoodDriving: true,
BadDriving: false,
@@ -845,7 +845,7 @@
EasilyDefended: false,
},
{
- Team: 972,
+ Team: "972",
Notes: "More Notes",
GoodDriving: false,
BadDriving: false,
@@ -1137,7 +1137,7 @@
return results, nil
}
-func (database *MockDatabase) QueryNotes(requestedTeam int32) ([]string, error) {
+func (database *MockDatabase) QueryNotes(requestedTeam string) ([]string, error) {
var results []string
for _, data := range database.notes {
if data.TeamNumber == requestedTeam {
diff --git a/scouting/www/app/app.ts b/scouting/www/app/app.ts
index 16e3197..011c94f 100644
--- a/scouting/www/app/app.ts
+++ b/scouting/www/app/app.ts
@@ -13,7 +13,7 @@
const unguardedTabs: Tab[] = ['MatchList'];
type TeamInMatch = {
- teamNumber: number;
+ teamNumber: string;
matchNumber: number;
setNumber: number;
compLevel: string;
@@ -26,7 +26,7 @@
})
export class App {
selectedTeamInMatch: TeamInMatch = {
- teamNumber: 1,
+ teamNumber: '1',
matchNumber: 1,
setNumber: 1,
compLevel: 'qm',
diff --git a/scouting/www/driver_ranking/driver_ranking.component.ts b/scouting/www/driver_ranking/driver_ranking.component.ts
index f61d901..09f62c2 100644
--- a/scouting/www/driver_ranking/driver_ranking.component.ts
+++ b/scouting/www/driver_ranking/driver_ranking.component.ts
@@ -18,7 +18,7 @@
section: Section = 'TeamSelection';
// Stores the team keys and rank (order of the array).
- team_ranking: number[] = [971, 972, 973];
+ team_ranking: string[] = ['971', '972', '973'];
match_number: number = 1;
@@ -58,13 +58,16 @@
async submitData() {
const builder = new Builder();
+ const teamRanking1 = builder.createString(this.team_ranking[0]);
+ const teamRanking2 = builder.createString(this.team_ranking[1]);
+ const teamRanking3 = builder.createString(this.team_ranking[2]);
builder.finish(
SubmitDriverRanking.createSubmitDriverRanking(
builder,
this.match_number,
- this.team_ranking[0],
- this.team_ranking[1],
- this.team_ranking[2]
+ teamRanking1,
+ teamRanking2,
+ teamRanking3
)
);
const buffer = builder.asUint8Array();
@@ -88,6 +91,6 @@
// Reset Data.
this.section = 'TeamSelection';
- this.team_ranking = [971, 972, 973];
+ this.team_ranking = ['971', '972', '973'];
}
}
diff --git a/scouting/www/driver_ranking/driver_ranking.ng.html b/scouting/www/driver_ranking/driver_ranking.ng.html
index 1fa1bc8..d361c9d 100644
--- a/scouting/www/driver_ranking/driver_ranking.ng.html
+++ b/scouting/www/driver_ranking/driver_ranking.ng.html
@@ -18,9 +18,7 @@
<input
*ngFor="let x of [1,2,3]; let i = index;"
[(ngModel)]="team_ranking[i]"
- type="number"
- min="1"
- max="9999"
+ type="text"
id="team_input_{{i}}"
/>
<button
diff --git a/scouting/www/entry/entry.component.ts b/scouting/www/entry/entry.component.ts
index 4b60ac1..5a93251 100644
--- a/scouting/www/entry/entry.component.ts
+++ b/scouting/www/entry/entry.component.ts
@@ -115,8 +115,7 @@
section: Section = 'Team Selection';
@Input() matchNumber: number = 1;
- // TODO(phil): Change the type of teamNumber to a string.
- @Input() teamNumber: number = 1;
+ @Input() teamNumber: string = '1';
@Input() setNumber: number = 1;
@Input() compLevel: CompLevel = 'qm';
@Input() skipTeamSelection = false;
@@ -173,7 +172,7 @@
if (this.teamNumber == null) {
return false;
}
- const teamNumber = this.teamNumber.toString();
+ const teamNumber = this.teamNumber;
for (const match of this.matchList) {
if (
@@ -392,7 +391,7 @@
actionOffsets.push(actionOffset);
}
}
- const teamNumberFb = builder.createString(this.teamNumber.toString());
+ const teamNumberFb = builder.createString(this.teamNumber);
const compLevelFb = builder.createString(this.compLevel);
const actionsVector = SubmitActions.createActionsListVector(
diff --git a/scouting/www/entry/entry.ng.html b/scouting/www/entry/entry.ng.html
index ada96ff..43575cd 100644
--- a/scouting/www/entry/entry.ng.html
+++ b/scouting/www/entry/entry.ng.html
@@ -26,10 +26,8 @@
<input
[(ngModel)]="teamNumber"
(ngModelChange)="updateTeamSelectionValidity()"
- type="number"
+ type="text"
id="team_number"
- min="1"
- max="9999"
/>
</div>
<div class="row">
diff --git a/scouting/www/notes/notes.component.ts b/scouting/www/notes/notes.component.ts
index 2786717..3848c22 100644
--- a/scouting/www/notes/notes.component.ts
+++ b/scouting/www/notes/notes.component.ts
@@ -48,7 +48,7 @@
}
interface Input {
- teamNumber: number;
+ teamNumber: string;
notesData: string;
keywordsData: Keywords;
}
@@ -79,7 +79,7 @@
section: Section = 'TeamSelection';
errorMessage = '';
- teamNumberSelection: number = 971;
+ teamNumberSelection: string = '971';
// Data inputted by user is stored in this array.
// Includes the team number, notes, and keyword selection.
@@ -145,10 +145,12 @@
const builder = new Builder();
const dataFb = builder.createString(this.newData[i].notesData);
+ const teamNumber = builder.createString(this.newData[i].teamNumber);
+
builder.finish(
SubmitNotes.createSubmitNotes(
builder,
- this.newData[i].teamNumber,
+ teamNumber,
dataFb,
this.newData[i].keywordsData.goodDriving,
this.newData[i].keywordsData.badDriving,
diff --git a/scouting/www/notes/notes.ng.html b/scouting/www/notes/notes.ng.html
index cb5e8ef..d7262b3 100644
--- a/scouting/www/notes/notes.ng.html
+++ b/scouting/www/notes/notes.ng.html
@@ -9,10 +9,8 @@
</label>
<input
[(ngModel)]="teamNumberSelection"
- type="number"
+ type="text"
id="team_number_notes"
- min="1"
- max="9999"
/>
<button class="btn btn-primary" (click)="setTeamNumber()">Select</button>
</div>
diff --git a/scouting/www/pit_scouting/pit_scouting.component.ts b/scouting/www/pit_scouting/pit_scouting.component.ts
index b74c119..fe14090 100644
--- a/scouting/www/pit_scouting/pit_scouting.component.ts
+++ b/scouting/www/pit_scouting/pit_scouting.component.ts
@@ -6,7 +6,7 @@
type Section = 'TeamSelection' | 'Data';
interface Input {
- teamNumber: number;
+ teamNumber: string;
pitImage: HTMLImageElement;
}
@@ -19,7 +19,7 @@
section: Section = 'Data';
errorMessage = '';
- teamNumber: number = 971;
+ teamNumber: string = '971';
pitImage: string = '';
async readFile(file): Promise<ArrayBuffer> {
@@ -41,7 +41,7 @@
async submitData() {
const builder = new Builder();
- const teamNumber = builder.createString(this.teamNumber.toString());
+ const teamNumber = builder.createString(this.teamNumber);
const pitImage = builder.createString(this.pitImage.toString());
const imageData = SubmitPitImage.createImageDataVector(
builder,
diff --git a/scouting/www/pit_scouting/pit_scouting.ng.html b/scouting/www/pit_scouting/pit_scouting.ng.html
index 98aa313..9e90d2d 100644
--- a/scouting/www/pit_scouting/pit_scouting.ng.html
+++ b/scouting/www/pit_scouting/pit_scouting.ng.html
@@ -4,13 +4,7 @@
<ng-container [ngSwitch]="section">
<div *ngSwitchCase="'Data'" id="pitImageSelection" class="container-fluid">
<label for="teamNumber">Team Number</label>
- <input
- [(ngModel)]="teamNumber"
- type="string"
- id="teamNumber"
- min="1"
- max="9999"
- />
+ <input [(ngModel)]="teamNumber" type="text" id="teamNumber" />
<form action="setPitImage()">
<label for="pitImage">Select pit image:</label>
<br />
diff --git a/scouting/www/view/view.component.ts b/scouting/www/view/view.component.ts
index c75f83b..26e816b 100644
--- a/scouting/www/view/view.component.ts
+++ b/scouting/www/view/view.component.ts
@@ -69,11 +69,19 @@
this.ascendingSort = !this.ascendingSort;
if (!this.ascendingSort) {
this.driverRankingList.sort((a, b) => b.matchNumber() - a.matchNumber());
- this.noteList.sort((a, b) => b.team() - a.team());
+ this.noteList.sort(function (a, b) {
+ return b[0]
+ .team()
+ .localeCompare(a[0].team(), undefined, {numeric: true});
+ });
this.statList.sort((a, b) => b.matchNumber() - a.matchNumber());
} else {
this.driverRankingList.sort((a, b) => a.matchNumber() - b.matchNumber());
- this.noteList.sort((a, b) => a.team() - b.team());
+ this.noteList.sort(function (a, b) {
+ return a[0]
+ .team()
+ .localeCompare(b[0].team(), undefined, {numeric: true});
+ });
this.statList.sort((a, b) => a.matchNumber() - b.matchNumber());
}
}
diff --git a/tools/python/BUILD b/tools/python/BUILD
index 8e410e5..40698ef 100644
--- a/tools/python/BUILD
+++ b/tools/python/BUILD
@@ -18,6 +18,19 @@
],
)
+# This binary is intended to run the `requirements.update` target in a Docker
+# container. This is primarily intended for reproducibility. See README.md.
+sh_binary(
+ name = "update_helper",
+ srcs = ["update_helper.sh"],
+ data = [
+ "update_helper_files/Dockerfile",
+ ],
+ deps = [
+ "@bazel_tools//tools/bash/runfiles",
+ ],
+)
+
py_runtime(
name = "python3_runtime",
files = [
diff --git a/tools/python/README.md b/tools/python/README.md
index cf878f7..625cb24 100644
--- a/tools/python/README.md
+++ b/tools/python/README.md
@@ -39,7 +39,7 @@
1. Add the new package you're interested in to `tools/python/requirements.txt`.
2. Run the lock file generation script.
- bazel run //tools/python:requirements.update
+ bazel run --run_under=//tools/python:update_helper //tools/python:requirements.update
How to make buildkite happy with new pip packages
diff --git a/tools/python/update_helper.sh b/tools/python/update_helper.sh
new file mode 100755
index 0000000..ba497ea
--- /dev/null
+++ b/tools/python/update_helper.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+# --- begin runfiles.bash initialization v2 ---
+# Copy-pasted from the Bazel Bash runfiles library v2.
+set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
+source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
+ source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
+ source "$0.runfiles/$f" 2>/dev/null || \
+ source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
+ source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
+ { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
+# --- end runfiles.bash initialization v2 ---
+
+DOCKERFILE="$(rlocation org_frc971/tools/python/update_helper_files/Dockerfile)"
+CONTEXT_DIR="$(dirname "${DOCKERFILE}")"
+CONTAINER_TAG="pip-lock:${USER}"
+
+# Build the container that has the bare minimum to run the various setup.py
+# scripts from our dependencies.
+docker build \
+ --file="${DOCKERFILE}" \
+ --tag="${CONTAINER_TAG}" \
+ "${CONTEXT_DIR}"
+
+# Run the actual update. The assumption here is that mounting the user's home
+# directory is sufficient to allow the tool to run inside the container without
+# any issues. I.e. the cache and the source tree are available in the
+# container.
+docker run \
+ --rm \
+ --tty \
+ --env BUILD_WORKSPACE_DIRECTORY="${BUILD_WORKSPACE_DIRECTORY}" \
+ --workdir "${PWD}" \
+ --volume "${HOME}:${HOME}" \
+ "${CONTAINER_TAG}" \
+ "$@"
diff --git a/tools/python/update_helper_files/Dockerfile b/tools/python/update_helper_files/Dockerfile
new file mode 100644
index 0000000..3a4d42c
--- /dev/null
+++ b/tools/python/update_helper_files/Dockerfile
@@ -0,0 +1,10 @@
+# This Dockerfile sets up a container with the minimum number of things to make
+# //tools/python:requirements.update target happy.
+
+FROM debian:12
+
+RUN apt update
+RUN DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y clang
+RUN DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y python3
+RUN DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y pkgconf
+RUN DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y libcairo2-dev
diff --git a/y2023/BUILD b/y2023/BUILD
index 2fb9e78..9bbed4f 100644
--- a/y2023/BUILD
+++ b/y2023/BUILD
@@ -285,6 +285,7 @@
"//aos/util:wrapping_counter",
"//frc971:can_configuration_fbs",
"//frc971/autonomous:auto_mode_fbs",
+ "//frc971/constants:constants_sender_lib",
"//frc971/control_loops:control_loop",
"//frc971/control_loops:control_loops_fbs",
"//frc971/control_loops/drivetrain:drivetrain_can_position_fbs",
@@ -306,6 +307,7 @@
"//third_party:phoenix",
"//third_party:phoenix6",
"//third_party:wpilib",
+ "//y2023/constants:constants_fbs",
"//y2023/control_loops/superstructure:led_indicator_lib",
"//y2023/control_loops/superstructure:superstructure_output_fbs",
"//y2023/control_loops/superstructure:superstructure_position_fbs",
diff --git a/y2023/constants.cc b/y2023/constants.cc
index 0154453..0b89ef0 100644
--- a/y2023/constants.cc
+++ b/y2023/constants.cc
@@ -23,7 +23,6 @@
Values r;
auto *const arm_proximal = &r.arm_proximal;
auto *const arm_distal = &r.arm_distal;
- auto *const wrist = &r.wrist;
auto *const roll_joint = &r.roll_joint;
r.wrist_flipped = true;
@@ -46,23 +45,6 @@
roll_joint->zeroing.moving_buffer_size = 20;
roll_joint->zeroing.allowable_encoder_error = 0.9;
- wrist->subsystem_params.zeroing_voltage = 3.0;
- wrist->subsystem_params.operating_voltage = 12.0;
- wrist->subsystem_params.zeroing_profile_params = {{}, 0.5, 3.0};
- wrist->subsystem_params.default_profile_params = {{}, 0.5, 5.0};
- wrist->subsystem_params.range = Values::kCompWristRange();
- wrist->subsystem_params.make_integral_loop =
- control_loops::superstructure::wrist::MakeIntegralWristLoop;
- wrist->subsystem_params.zeroing_constants.average_filter_size =
- Values::kZeroingSampleSize;
- wrist->subsystem_params.zeroing_constants.one_revolution_distance =
- M_PI * 2.0 * constants::Values::kCompWristEncoderRatio();
- wrist->subsystem_params.zeroing_constants.zeroing_threshold = 0.0005;
- wrist->subsystem_params.zeroing_constants.moving_buffer_size = 20;
- wrist->subsystem_params.zeroing_constants.allowable_encoder_error = 0.9;
- wrist->subsystem_params.zeroing_constants.middle_position =
- Values::kCompWristRange().middle();
-
switch (team) {
// A set of constants for tests.
case 1:
@@ -77,9 +59,6 @@
roll_joint->zeroing.measured_absolute_position = 0.0;
roll_joint->potentiometer_offset = 0.0;
- wrist->subsystem_params.zeroing_constants.measured_absolute_position =
- 0.0;
-
break;
case kCompTeamNumber:
@@ -109,9 +88,6 @@
0.097581301615046 + 3.3424421683095 - 3.97605190912604 +
0.709274294168941 - 0.0817908884966825 + 0.0420732537514303;
- wrist->subsystem_params.zeroing_constants.measured_absolute_position =
- 0.616272675539221;
-
break;
case kPracticeTeamNumber:
@@ -147,9 +123,6 @@
1.09682107821155 - 0.193945964842277 + 0.811834321668829 -
0.913134567575683;
- wrist->subsystem_params.zeroing_constants.measured_absolute_position =
- 2.94344206522199;
-
break;
case kCodingRobotTeamNumber:
@@ -162,9 +135,6 @@
roll_joint->zeroing.measured_absolute_position = 0.0;
roll_joint->potentiometer_offset = 0.0;
- wrist->subsystem_params.zeroing_constants.measured_absolute_position =
- 0.0;
-
break;
default:
diff --git a/y2023/constants.h b/y2023/constants.h
index d90bbc9..92428db 100644
--- a/y2023/constants.h
+++ b/y2023/constants.h
@@ -225,8 +225,6 @@
ArmJointConstants arm_distal;
ArmJointConstants roll_joint;
- AbsEncoderConstants wrist;
-
bool wrist_flipped;
};
diff --git a/y2023/constants/971.json b/y2023/constants/971.json
index fc21b74..bc26de8 100644
--- a/y2023/constants/971.json
+++ b/y2023/constants/971.json
@@ -25,6 +25,10 @@
"lateral_position": -0.23
}
]
+ },
+ "wrist_zero": {
+ {% include 'y2023/constants/wrist_common_zeroing.json' %},
+ "measured_absolute_position": 0.616272675539221
}
},
{% include 'y2023/constants/common.json' %}
diff --git a/y2023/constants/9971.json b/y2023/constants/9971.json
index d687c9e..4b10956 100644
--- a/y2023/constants/9971.json
+++ b/y2023/constants/9971.json
@@ -25,6 +25,10 @@
"lateral_position": -0.23
}
]
+ },
+ "wrist_zero": {
+ {% include 'y2023/constants/wrist_common_zeroing.json' %},
+ "measured_absolute_position": 2.94344206522199
}
},
{% include 'y2023/constants/common.json' %}
diff --git a/y2023/constants/BUILD b/y2023/constants/BUILD
index 512e400..bbcec56 100644
--- a/y2023/constants/BUILD
+++ b/y2023/constants/BUILD
@@ -1,4 +1,5 @@
load("//aos/flatbuffers:generate.bzl", "static_flatbuffer")
+load("@aspect_bazel_lib//lib:run_binary.bzl", "run_binary")
load("//tools/build_rules:template.bzl", "jinja2_template")
cc_library(
@@ -19,7 +20,12 @@
jinja2_template(
name = "test_constants.json",
src = "test_constants.jinja2.json",
- includes = glob(["test_data/*.json"]),
+ includes = glob([
+ "test_data/*.json",
+ ]) + [
+ ":wrist_common_zeroing.json",
+ "//y2023/control_loops/superstructure/wrist:wrist_json",
+ ],
parameters = {},
visibility = ["//visibility:public"],
)
@@ -33,6 +39,8 @@
"9971.json",
"common.json",
":scoring_map",
+ ":wrist_common_zeroing.json",
+ "//y2023/control_loops/superstructure/wrist:wrist_json",
"//y2023/vision/calib_files",
"//y2023/vision/maps",
],
@@ -54,8 +62,11 @@
srcs = ["constants.fbs"],
visibility = ["//visibility:public"],
deps = [
+ "//frc971/control_loops:profiled_subsystem_fbs",
+ "//frc971/control_loops:state_feedback_loop_fbs",
"//frc971/vision:calibration_fbs",
"//frc971/vision:target_map_fbs",
+ "//frc971/zeroing:constants_fbs",
"//y2023/localizer:scoring_map_fbs",
],
)
@@ -80,3 +91,19 @@
"//frc971/constants:constants_sender_lib",
],
)
+
+cc_binary(
+ name = "json_codegen",
+ srcs = ["json_codegen.cc"],
+ deps = [
+ "//aos/util:file",
+ "//y2023:constants",
+ ],
+)
+
+run_binary(
+ name = "wrist_json_codegen",
+ outs = ["wrist_common_zeroing.json"],
+ args = ["$(location :wrist_common_zeroing.json)"],
+ tool = ":json_codegen",
+)
diff --git a/y2023/constants/common.json b/y2023/constants/common.json
index d63c518..a120e52 100644
--- a/y2023/constants/common.json
+++ b/y2023/constants/common.json
@@ -3,4 +3,24 @@
"ignore_targets": {
"red": [4],
"blue": [5]
+ },
+ "wrist": {
+ "zeroing_voltage": 3.0,
+ "operating_voltage": 12.0,
+ "zeroing_profile_params": {
+ "max_velocity": 0.5,
+ "max_acceleration": 3.0
+ },
+ "default_profile_params":{
+ "max_velocity": 0.5,
+ "max_acceleration": 5.0
+ },
+ {# The range is currently duplicated from the constants.h; try to fix this. #}
+ "range": {
+ "lower_hard": -0.10,
+ "upper_hard": 4.90,
+ "lower": 0.0,
+ "upper": 4.0
+ },
+ "loop": {% include 'y2023/control_loops/superstructure/wrist/integral_wrist_plant.json' %}
}
diff --git a/y2023/constants/constants.fbs b/y2023/constants/constants.fbs
index 61c3365..8910051 100644
--- a/y2023/constants/constants.fbs
+++ b/y2023/constants/constants.fbs
@@ -1,5 +1,7 @@
include "frc971/vision/calibration.fbs";
include "frc971/vision/target_map.fbs";
+include "frc971/control_loops/profiled_subsystem.fbs";
+include "frc971/zeroing/constants.fbs";
include "y2023/localizer/scoring_map.fbs";
namespace y2023;
@@ -27,6 +29,7 @@
// Table of time-of-flight reading positions. Until we bother using one
// of our interpolation classes, should just contain two values.
tof:TimeOfFlight (id: 0);
+ wrist_zero:frc971.zeroing.AbsoluteEncoderZeroingConstants (id: 1);
}
// Set of april tag targets, by april tag ID, to ignore when on a
@@ -42,6 +45,7 @@
scoring_map:localizer.ScoringMap (id: 2);
robot:RobotConstants (id: 3);
ignore_targets:IgnoreTargets (id: 4);
+ wrist:frc971.control_loops.StaticZeroingSingleDOFProfiledSubsystemCommonParams (id: 5);
}
root_type Constants;
diff --git a/y2023/constants/json_codegen.cc b/y2023/constants/json_codegen.cc
new file mode 100644
index 0000000..fc08df1
--- /dev/null
+++ b/y2023/constants/json_codegen.cc
@@ -0,0 +1,25 @@
+#include "aos/util/file.h"
+#include "y2023/constants.h"
+
+using namespace y2023::constants;
+
+// This file generates some JSON constants information that is currently
+// dependent on values that are located in C++ headers and would be
+// obnoxious/inappropriate to pull out.
+int main(int argc, char *argv[]) {
+ CHECK_EQ(argc, 2) << "Must supply file name to output to.";
+ std::string output_file = argv[1];
+
+ std::stringstream output;
+
+ output << "\"average_filter_size\": " << Values::kZeroingSampleSize << ",\n";
+ output << "\"one_revolution_distance\": "
+ << M_PI * 2.0 * Values::kCompWristEncoderRatio() << ",\n";
+ output << "\"zeroing_threshold\": 0.0005,\n";
+ output << "\"moving_buffer_size\": 20,\n";
+ output << "\"allowable_encoder_error\": 0.9,\n";
+ output << "\"middle_position\": " << Values::kCompWristRange().middle()
+ << "\n";
+ aos::util::WriteStringToFileOrDie(output_file, output.str());
+ return 0;
+}
diff --git a/y2023/constants/test_data/test_team.json b/y2023/constants/test_data/test_team.json
index 0a226f0..bb9c1e4 100644
--- a/y2023/constants/test_data/test_team.json
+++ b/y2023/constants/test_data/test_team.json
@@ -27,8 +27,32 @@
"lateral_position": -0.2
}
]
+ },
+ "wrist_zero": {
+ {% include 'y2023/constants/wrist_common_zeroing.json' %},
+ "measured_absolute_position": 0.0
}
},
+ "wrist": {
+ "zeroing_voltage": 3.0,
+ "operating_voltage": 12.0,
+ "zeroing_profile_params": {
+ "max_velocity": 0.5,
+ "max_acceleration": 3.0
+ },
+ "default_profile_params":{
+ "max_velocity": 0.5,
+ "max_acceleration": 5.0
+ },
+ {# The range is currently duplicated from the constants.h; try to fix this. #}
+ "range": {
+ "lower_hard": -0.10,
+ "upper_hard": 4.90,
+ "lower": 0.0,
+ "upper": 4.0
+ },
+ "loop": {% include 'y2023/control_loops/superstructure/wrist/integral_wrist_plant.json' %}
+ },
"ignore_targets": {
"red": [4],
"blue": [5]
diff --git a/y2023/control_loops/python/wrist.py b/y2023/control_loops/python/wrist.py
index fe2fcf6..3ad404c 100644
--- a/y2023/control_loops/python/wrist.py
+++ b/y2023/control_loops/python/wrist.py
@@ -41,13 +41,13 @@
return
# Write the generated constants out to a file.
- if len(argv) != 5:
+ if len(argv) != 7:
glog.fatal(
'Expected .h file name and .cc file name for the wrist and integral wrist.'
)
else:
namespaces = ['y2023', 'control_loops', 'superstructure', 'wrist']
- angular_system.WriteAngularSystem(kWrist, argv[1:3], argv[3:5],
+ angular_system.WriteAngularSystem(kWrist, argv[1:4], argv[4:7],
namespaces)
diff --git a/y2023/control_loops/superstructure/superstructure.cc b/y2023/control_loops/superstructure/superstructure.cc
index e11092a..0ee1061 100644
--- a/y2023/control_loops/superstructure/superstructure.cc
+++ b/y2023/control_loops/superstructure/superstructure.cc
@@ -34,7 +34,8 @@
event_loop->MakeFetcher<aos::JoystickState>("/aos")),
arm_(values_, arm_trajectories.message()),
end_effector_(),
- wrist_(values->wrist.subsystem_params) {
+ wrist_(constants_fetcher_.constants().wrist(),
+ constants_fetcher_.constants().robot()->wrist_zero()) {
event_loop->SetRuntimeRealtimePriority(30);
}
diff --git a/y2023/control_loops/superstructure/superstructure_lib_test.cc b/y2023/control_loops/superstructure/superstructure_lib_test.cc
index d4fa653..5973eee 100644
--- a/y2023/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2023/control_loops/superstructure/superstructure_lib_test.cc
@@ -175,15 +175,23 @@
chrono::nanoseconds dt)
: event_loop_(event_loop),
dt_(dt),
+ constants_fetcher_(event_loop),
arm_(values->arm_proximal.zeroing, values->arm_distal.zeroing,
values->roll_joint.zeroing, dt_),
wrist_(new CappedTestPlant(wrist::MakeWristPlant()),
- PositionSensorSimulator(
- values->wrist.subsystem_params.zeroing_constants
- .one_revolution_distance),
- values->wrist, constants::Values::kCompWristRange(),
- values->wrist.subsystem_params.zeroing_constants
- .measured_absolute_position,
+ PositionSensorSimulator(constants_fetcher_.constants()
+ .robot()
+ ->wrist_zero()
+ ->one_revolution_distance()),
+ {.subsystem_params =
+ {constants_fetcher_.constants().wrist(),
+ constants_fetcher_.constants().robot()->wrist_zero()}},
+ frc971::constants::Range::FromFlatbuffer(
+ constants_fetcher_.constants().wrist()->range()),
+ constants_fetcher_.constants()
+ .robot()
+ ->wrist_zero()
+ ->measured_absolute_position(),
dt_),
superstructure_position_sender_(
event_loop_->MakeSender<Position>("/superstructure")),
@@ -257,6 +265,7 @@
::aos::EventLoop *event_loop_;
const chrono::nanoseconds dt_;
::aos::PhasedLoopHandler *phased_loop_handle_ = nullptr;
+ frc971::constants::ConstantsFetcher<Constants> constants_fetcher_;
ArmSimulation arm_;
AbsoluteEncoderSimulator wrist_;
diff --git a/y2023/control_loops/superstructure/wrist/BUILD b/y2023/control_loops/superstructure/wrist/BUILD
index 694d95f..212c203 100644
--- a/y2023/control_loops/superstructure/wrist/BUILD
+++ b/y2023/control_loops/superstructure/wrist/BUILD
@@ -5,8 +5,10 @@
outs = [
"wrist_plant.h",
"wrist_plant.cc",
+ "wrist_plant.json",
"integral_wrist_plant.h",
"integral_wrist_plant.cc",
+ "integral_wrist_plant.json",
],
cmd = "$(location //y2023/control_loops/python:wrist) $(OUTS)",
target_compatible_with = ["@platforms//os:linux"],
@@ -32,3 +34,9 @@
"//frc971/control_loops:state_feedback_loop",
],
)
+
+filegroup(
+ name = "wrist_json",
+ srcs = ["integral_wrist_plant.json"],
+ visibility = ["//visibility:public"],
+)
diff --git a/y2023/wpilib_interface.cc b/y2023/wpilib_interface.cc
index 8438281..d03bda3 100644
--- a/y2023/wpilib_interface.cc
+++ b/y2023/wpilib_interface.cc
@@ -39,6 +39,7 @@
#include "aos/util/wrapping_counter.h"
#include "frc971/autonomous/auto_mode_generated.h"
#include "frc971/can_configuration_generated.h"
+#include "frc971/constants/constants_sender_lib.h"
#include "frc971/control_loops/drivetrain/drivetrain_can_position_generated.h"
#include "frc971/control_loops/drivetrain/drivetrain_position_generated.h"
#include "frc971/input/robot_state_generated.h"
@@ -56,6 +57,7 @@
#include "frc971/wpilib/sensor_reader.h"
#include "frc971/wpilib/wpilib_robot_base.h"
#include "y2023/constants.h"
+#include "y2023/constants/constants_generated.h"
#include "y2023/control_loops/superstructure/led_indicator.h"
#include "y2023/control_loops/superstructure/superstructure_output_generated.h"
#include "y2023/control_loops/superstructure/superstructure_position_static.h"
@@ -403,6 +405,7 @@
CANSensorReader *can_sensor_reader)
: ::frc971::wpilib::SensorReader(event_loop),
values_(std::move(values)),
+ constants_fetcher_(event_loop),
auto_mode_sender_(
event_loop->MakeSender<::frc971::autonomous::AutonomousMode>(
"/autonomous")),
@@ -460,8 +463,10 @@
false, values_->roll_joint.potentiometer_offset);
CopyPosition(wrist_encoder_, builder->add_wrist(),
Values::kWristEncoderCountsPerRevolution(),
- values_->wrist.subsystem_params.zeroing_constants
- .one_revolution_distance /
+ constants_fetcher_.constants()
+ .robot()
+ ->wrist_zero()
+ ->one_revolution_distance() /
(M_PI * 2.0),
values_->wrist_flipped);
@@ -632,6 +637,7 @@
private:
std::shared_ptr<const Values> values_;
+ frc971::constants::ConstantsFetcher<Constants> constants_fetcher_;
aos::Sender<frc971::autonomous::AutonomousMode> auto_mode_sender_;
aos::Sender<superstructure::PositionStatic> superstructure_position_sender_;
@@ -919,6 +925,8 @@
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
aos::configuration::ReadConfig("aos_config.json");
+ frc971::constants::WaitForConstants<y2023::Constants>(&config.message());
+
// Thread 1.
::aos::ShmEventLoop joystick_sender_event_loop(&config.message());
::frc971::wpilib::JoystickSender joystick_sender(
diff --git a/y2024/BUILD b/y2024/BUILD
index 7e5761c..be8abe0 100644
--- a/y2024/BUILD
+++ b/y2024/BUILD
@@ -77,7 +77,7 @@
"//frc971/orin:argus_camera",
],
target_compatible_with = ["//tools/platforms/hardware:raspberry_pi"],
- target_type = "orin",
+ target_type = "pi",
)
aos_config(
diff --git a/y2024/autonomous/auto_splines.h b/y2024/autonomous/auto_splines.h
index efdfb33..309222f 100644
--- a/y2024/autonomous/auto_splines.h
+++ b/y2024/autonomous/auto_splines.h
@@ -13,8 +13,7 @@
*/
-namespace y2024 {
-namespace autonomous {
+namespace y2024::autonomous {
class AutonomousSplines {
public:
@@ -39,7 +38,6 @@
aos::FlatbufferDetachedBuffer<frc971::MultiSpline> test_spline_;
};
-} // namespace autonomous
-} // namespace y2024
+} // namespace y2024::autonomous
#endif // Y2024_AUTONOMOUS_AUTO_SPLINES_H_
diff --git a/y2024/autonomous/autonomous_actor.h b/y2024/autonomous/autonomous_actor.h
index 6603080..c3d7d79 100644
--- a/y2024/autonomous/autonomous_actor.h
+++ b/y2024/autonomous/autonomous_actor.h
@@ -11,8 +11,7 @@
#include "y2024/control_loops/superstructure/superstructure_goal_generated.h"
#include "y2024/control_loops/superstructure/superstructure_status_generated.h"
-namespace y2024 {
-namespace autonomous {
+namespace y2024::autonomous {
class AutonomousActor : public ::frc971::autonomous::BaseAutonomousActor {
public:
@@ -60,7 +59,6 @@
const ::std::vector<::Eigen::Matrix<double, 3, 1>> points_;
};
-} // namespace autonomous
-} // namespace y2024
+} // namespace y2024::autonomous
#endif // Y2024_AUTONOMOUS_AUTONOMOUS_ACTOR_H_
diff --git a/y2024/constants/common.json b/y2024/constants/common.json
index f9c79c6..279ec04 100644
--- a/y2024/constants/common.json
+++ b/y2024/constants/common.json
@@ -1 +1,10 @@
- "target_map": {% include 'y2024/vision/maps/target_map.json' %}
+"shooter_interpolation_table": [
+ {
+ "distance_from_goal": 0.0,
+ "shot_params": {
+ "shot_velocity": 0.0,
+ "shot_angle": 0.0
+ }
+ }
+],
+"target_map": {% include 'y2024/vision/maps/target_map.json' %}
diff --git a/y2024/constants/constants.fbs b/y2024/constants/constants.fbs
index ad34617..490bc99 100644
--- a/y2024/constants/constants.fbs
+++ b/y2024/constants/constants.fbs
@@ -2,6 +2,15 @@
namespace y2024;
+table ShotParams {
+ shot_velocity: double (id: 0);
+ shot_angle: double (id: 1);
+}
+
+table InterpolationTablePoint {
+ distance_from_goal: double (id: 0);
+ shot_params: ShotParams (id: 1);
+}
table RobotConstants {
@@ -10,6 +19,7 @@
table Constants {
target_map:frc971.vision.TargetMap (id: 0);
robot:RobotConstants (id: 1);
+ shooter_interpolation_table: [InterpolationTablePoint] (id: 2);
}
root_type Constants;
diff --git a/y2024/constants/constants_validator_test.cc b/y2024/constants/constants_validator_test.cc
index 238bfc3..cd478a8 100644
--- a/y2024/constants/constants_validator_test.cc
+++ b/y2024/constants/constants_validator_test.cc
@@ -4,9 +4,7 @@
#include "aos/json_to_flatbuffer.h"
#include "y2024/constants/constants_list_generated.h"
-namespace y2024 {
-namespace constants {
-namespace testing {
+namespace y2024::constants::testing {
class ConstantsValidatorTest : public ::testing::Test {};
TEST_F(ConstantsValidatorTest, CheckConstants) {
@@ -16,6 +14,4 @@
.constants());
}
-} // namespace testing
-} // namespace constants
-} // namespace y2024
+} // namespace y2024::constants::testing
diff --git a/y2024/control_loops/drivetrain/drivetrain_base.h b/y2024/control_loops/drivetrain/drivetrain_base.h
index 807981a..e7eb581 100644
--- a/y2024/control_loops/drivetrain/drivetrain_base.h
+++ b/y2024/control_loops/drivetrain/drivetrain_base.h
@@ -3,15 +3,11 @@
#include "frc971/control_loops/drivetrain/drivetrain_config.h"
-namespace y2024 {
-namespace control_loops {
-namespace drivetrain {
+namespace y2024::control_loops::drivetrain {
const ::frc971::control_loops::drivetrain::DrivetrainConfig<double> &
GetDrivetrainConfig();
-} // namespace drivetrain
-} // namespace control_loops
-} // namespace y2024
+} // namespace y2024::control_loops::drivetrain
#endif // Y2024_CONTROL_LOOPS_DRIVETRAIN_DRIVETRAIN_BASE_H_
diff --git a/y2024/control_loops/superstructure/superstructure.h b/y2024/control_loops/superstructure/superstructure.h
index 1d7cdf5..b3ab37e 100644
--- a/y2024/control_loops/superstructure/superstructure.h
+++ b/y2024/control_loops/superstructure/superstructure.h
@@ -16,9 +16,7 @@
#include "y2024/control_loops/superstructure/superstructure_position_generated.h"
#include "y2024/control_loops/superstructure/superstructure_status_generated.h"
-namespace y2024 {
-namespace control_loops {
-namespace superstructure {
+namespace y2024::control_loops::superstructure {
class Superstructure
: public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> {
@@ -47,8 +45,6 @@
DISALLOW_COPY_AND_ASSIGN(Superstructure);
};
-} // namespace superstructure
-} // namespace control_loops
-} // namespace y2024
+} // namespace y2024::control_loops::superstructure
#endif // Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
diff --git a/y2024/control_loops/superstructure/superstructure_goal.fbs b/y2024/control_loops/superstructure/superstructure_goal.fbs
index 25fc8ca..c00c70e 100644
--- a/y2024/control_loops/superstructure/superstructure_goal.fbs
+++ b/y2024/control_loops/superstructure/superstructure_goal.fbs
@@ -12,12 +12,24 @@
// Represents goal for pivot on intake
enum IntakePivotGoal : ubyte {
EXTENDED = 0,
- RETRACTED = 1,
+ RETRACTED = 1,
+}
+
+table CatapultGoal {
+ // The target shot position and velocity. If these are provided before fire
+ // is called, the optimizer can pre-compute the trajectory.
+ shot_position: double (id: 0);
+ shot_velocity: double (id: 1);
+
+ // Return position of the catapult
+ return_position: double (id: 2);
}
table Goal {
intake_roller_goal:IntakeRollerGoal (id: 0);
intake_pivot_goal:IntakePivotGoal (id: 1);
+
+ catapult_goal:CatapultGoal (id: 2);
}
root_type Goal;
diff --git a/y2024/control_loops/superstructure/superstructure_output.fbs b/y2024/control_loops/superstructure/superstructure_output.fbs
index d54e608..cd5971e 100644
--- a/y2024/control_loops/superstructure/superstructure_output.fbs
+++ b/y2024/control_loops/superstructure/superstructure_output.fbs
@@ -6,6 +6,15 @@
// Voltage of intake pivot
intake_pivot_voltage:double (id: 1);
+
+ // Voltage of the turret
+ turret_voltage: double (id: 2);
+
+ // Voltage of the altitude
+ altitude_voltage: double (id: 3);
+
+ // Voltage of the catapult
+ catapult_voltage: double (id: 4);
}
root_type Output;
diff --git a/y2024/control_loops/superstructure/superstructure_position.fbs b/y2024/control_loops/superstructure/superstructure_position.fbs
index 0bb5ae8..e4f6474 100644
--- a/y2024/control_loops/superstructure/superstructure_position.fbs
+++ b/y2024/control_loops/superstructure/superstructure_position.fbs
@@ -6,6 +6,15 @@
table Position {
// Values of the encoder and potentiometer at the intake pivot
intake_pivot:frc971.PotAndAbsolutePosition (id: 0);
+
+ // Values of the encoder and potentiometer at the turret
+ turret:frc971.PotAndAbsolutePosition (id: 1);
+
+ // Values of the encoder and potentiometer at the altitude
+ altitude:frc971.PotAndAbsolutePosition (id: 2);
+
+ // Values of the encoder and potentiometer at the catapult
+ catapult:frc971.PotAndAbsolutePosition (id: 3);
}
root_type Position;
diff --git a/y2024/control_loops/superstructure/superstructure_status.fbs b/y2024/control_loops/superstructure/superstructure_status.fbs
index 98134bd..82756dd 100644
--- a/y2024/control_loops/superstructure/superstructure_status.fbs
+++ b/y2024/control_loops/superstructure/superstructure_status.fbs
@@ -10,6 +10,17 @@
INTAKING = 2,
}
+table ShooterStatus {
+ // Estimated angle and angular velocitiy of the turret.
+ turret_state:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 0);
+
+ // Estimated angle and angular velocitiy of the catapult.
+ catapult_state:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 1);
+
+ // Estimated angle and angular velocitiy of the altitude.
+ altitude_state:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus (id: 2);
+}
+
table Status {
// All subsystems know their location.
zeroed:bool (id: 0);