Repository navigation
Releases
BearPlatform 0.4.0
New: the simulator
The robot's code runs on a laptop, on a simulated robot: before the robot is built, between practices, or to try a
change before it goes to the robot.
./gradlew :TeamCode:simulate
opens a Driver Station in the browser at http://localhost:8080/bear/driverstation. Pick an opmode, then INIT, START and
STOP. Next to the buttons are the Driver Station's lines and the field view.
- The opmodes run their own code, unchanged, and every device the code asks for is there. A mecanum drive moves by its
wheels' powers, the walls stop it, and the Pinpoint reports where it is. Encoders count, flywheels spin up and coast,
and servos turn at a servo's speed. - An autonomous stops after 30 s, and its
preselectTeleOpis picked next. The robot stays on the field, so TeleOp
starts where autonomous ended. - Gamepads plugged into the laptop are gamepads 1 and 2. The keyboard is gamepad 1 too: WASD moves, Q and E turn, and
the arrow keys are the dpad. - The graphs and settings pages are there too, as on the robot.
--opmode="Auto"runs one opmode and ends, with the Driver Station's lines and the log in the output.sim.*settings make it move like your robot, and the Tune opmode's characterizations measure the main ones. The
defaults are Beta's, a 12 kg mecanum robot on 435 rpm motors.
More in the manual: Simulator.
New: balls and the season's field in the simulator
A season's field, and how the robot handles balls, go in the module's src/sim/kotlin. Only the simulator runs that
code; it stays out of the robot's app.
- A
SimulatedSeasonsets the field up: balls, obstacles and walls, stacks of balls, containers that catch them, and
what the Driver Station page says about the field, like the score. - A
RobotSimulationdescribes the robot's intakes, turntables, shooters and distance sensors from its parts. - Balls roll, fly and bounce, and the robot pushes them. Each shot says where it went. Reset field puts everything
back as at the start of a match.
More: Balls.
New: the field view
The graphs page draws the field as the audience sees it, with its tiles, on the robot and in the simulator:
- the robot where its localizer says it is, as big as the new
robotSize.lengthandrobotSize.widthsettings say
(18 inches by default), and the track it drove; - where the path follower drives to (
PathFollower.destinations), the last pose as a dashed outline; - points the code marks with
mark("goal", point), or a pose, which shows the way it faces too; - the season's zones and field elements, which its
Fieldlists asFieldShapes. The robot sends them once, not with
every update.
More: The field view,
Layout.
Changed
- The Gradle plugin sets
unitTests.returnDefaultValueson the app module, so Android's own methods return 0, false
or null in unit tests instead of throwing. It also addssrc/sim/kotlinto the unit tests' sources. - Config doesn't report
sim.*settings as unused.
Updating from 0.3.0
Nothing breaks. Change the version to 0.4.0 in both places: nl.beargineers.platform:ftc in TeamCode/build.gradle,
and the plugin nl.beargineers.platform in the top-level build.gradle. The plugin brings the simulate task.
The Quickstart's README says how to try it: its Auto drives its square on
the field view.
BearPlatform 0.3.0
New: choices in INIT
Drivers pick the alliance, where the robot starts, or the routine on the Driver Station before START. Each choice is a
property of the opmode:
private val alliance by choice(Alliance.RED, Alliance.BLUE)
private val wait by choice(0.seconds, 3.seconds, 5.seconds)INIT shows the choices above every other line. Gamepad 1's dpad picks, so A, B, X and Y stay free for the opmode's own
buttons. The robot remembers each pick by its name: the next run starts with it, and TeleOp gets the alliance picked in
autonomous. A choice with remember = false starts at its first option every run.
The Quickstart's Auto picks the alliance, and on blue drives its square
mirrored.
More in the manual: Choices in INIT.
New: tuning, from the Driver Station or a laptop
One opmode lists every tuning the robot's parts offer:
@TeleOp(name = "Tune")
class Tune : TuningOpMode(::MyRobot)drive: check wheelsspins each wheel in turn.follower: characterize forward,strafeandturnmeasure the power that starts the robot moving, its speeds,
its acceleration and how far it takes to stop. They suggest the friction powers.follower: test movesdrives forward, right, a quarter turn and a diagonal, each and back, and reports how the
follower did.<flywheel>: find gainsfinds the gains for the hub's speed control.
Gamepad 1 picks and runs a tuning, and X applies what it suggests. The graphs page offers the same, with an Apply
button. Applied settings last until the next install. ./gradlew :TeamCode:pullConfig writes the robot's config into
config.properties and lists what changed, so it can be committed. Your own parts can offer tunings with
tuning("name") { ... }.
More: Tuning.
New: flywheels, and motors that hold a speed
motor.targetVelocity = 3800.rpmhands the speed to the hub's own speed control, in real units. Its gains are the
hubVelocityGainssetting, likep=300, i=0, d=0, f=31.Flywheelholds one or more motors at a speed, andisReadysays when it's ready to shoot. Insideshooting { }it
reads the speed every loop, for bursts of shots. It reports a motor that measures far less than the others.SpeedTablemaps distances to speeds from config:1m: 3200rpm, 2m: 3600rpm.
More: Holding a speed,
Flywheels.
New: servo axes and absolute encoders
AbsoluteEncoderreads an angle from an analog port, like an Axon's fourth wire. It counts turns through gears and
ignores glitches where the angle wraps around.ServoAxisturns something to angles through gears. With anAbsoluteEncoderit knows when a move has arrived, and
stops when the servo jams.PositionServotakes default pulse widths:pwmMin = 500.0, pwmMax = 2500.0for an Axon.
More: Servo axes,
Analog sensors.
Changed: a shorter Driver Station before START, with bold and colors
- Before START, the choices come first. Then each warning gets one line, marked ⚠ in amber, with the details in the
log. The Loop and Battery lines appear from START. - The Driver Station shows lines as HTML. The chosen line of a menu is bold, and an alliance shows in red or blue
wherever it appears. Your own lines can use them too:
show(Styled.plain("Flywheel: ") + Styled.colored("ready", "#4CAF50")).
Smaller
robot.partsOf<T>()lists the robot's parts of a type.- Settings the robot writes, like applied tuning results, keep their numbers as typed:
333deg/s, not
333.00000000000006deg/s.
Updating from 0.2.0
Nothing breaks. Change the version to 0.3.0 in both places: nl.beargineers.platform:ftc in TeamCode/build.gradle,
and the plugin nl.beargineers.platform in the top-level build.gradle.
One thing to check: the Driver Station is now in HTML mode. The platform escapes lines shown with show(), but text
written to FIRST's telemetry directly is read as HTML, so a < in it can disappear. telemetry.html = false in
config keeps the Driver Station in plain text.
To tune, add the Tune opmode above. The Quickstart has it.
BearPlatform 0.2.0
New: Gradle tasks that talk to the robot, on Windows too
The Gradle plugin nl.beargineers.platform adds tasks to the robot's module (TeamCode). In Android Studio they are
in the Gradle tool window, under TeamCode › Tasks › robot:
sendConfigsendsres/raw/config.propertiesto the robot, where it applies right away;--file=...sends
another file.robotCommand --name="forward 60 cm"starts a command the running opmode offers; without a name, it lists them.downloadMatchLogsdownloads FIRST's match logs intoTeamCode/matchLogs, and deletes them from the robot.
They replace the shell scripts in scripts/, which are gone. Over USB, set bear.robot=usb in gradle.properties:
the tasks forward the robot's port with the Android SDK's adb themselves.
More in the manual: Gradle tasks.
Updating from 0.1.0
Nothing breaks. Change the version of nl.beargineers.platform:ftc in TeamCode/build.gradle to 0.2.0, and add the
plugin, at the same version, to the top-level build.gradle:
plugins {
id 'nl.beargineers.platform' version '0.2.0' apply false
}and to TeamCode/build.gradle, after the other apply plugin lines:
apply plugin: 'nl.beargineers.platform'The Quickstart has both.