Skip to content

Commit

Permalink
Add default robot specs to binary
Browse files Browse the repository at this point in the history
  • Loading branch information
g3force committed Feb 4, 2023
1 parent 08c1da2 commit 2a8f5a3
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions internal/simctl/handler_robot_specs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
"os"
)

type TeamRobotSpecs struct {
Expand Down Expand Up @@ -45,9 +45,35 @@ type RobotSpecHandler struct {
appliedTeams map[referee.Team]string
}

var defaultRobotSpecs = TeamRobotSpecs{
Teams: map[string]RobotSpec{
"Unknown": {
Radius: 0.09,
Height: 0.143,
Mass: 2.7,
MaxLinearKickSpeed: 6,
MaxChipKickSpeed: 6,
CenterToDribbler: 0.078,
Limits: Limits{
AccSpeedupAbsoluteMax: 2,
AccSpeedupAngularMax: 20,
AccBrakeAbsoluteMax: 2,
AccBrakeAngularMax: 20,
VelAbsoluteMax: 2,
VelAngularMax: 5,
},
CustomErforce: CustomRobotSpecErForce{
ShootRadius: 0.0715,
DribblerWidth: 0.065,
},
},
},
}

func NewRobotSpecHandler(c *SimulationController, configFile string) (r *RobotSpecHandler) {
r = new(RobotSpecHandler)
r.c = c
r.teamRobotSpecs = defaultRobotSpecs
r.loadRobotSpecs(configFile)
return r
}
Expand All @@ -57,7 +83,7 @@ func (r *RobotSpecHandler) Reset() {
}

func (r *RobotSpecHandler) loadRobotSpecs(configFile string) {
data, err := ioutil.ReadFile(configFile)
data, err := os.ReadFile(configFile)
if err != nil {
log.Println("Could not read robot spec file: ", err)
} else if err := yaml.Unmarshal(data, &r.teamRobotSpecs); err != nil {
Expand Down

0 comments on commit 2a8f5a3

Please sign in to comment.