MCPcopy Create free account
hub / github.com/LemLib/LemLib / initialize

Function initialize

src/main.cpp:87–112  ·  view source on GitHub ↗

* Runs initialization code. This occurs as soon as the program is started. * * All other competition modes are blocked by initialize; it is recommended * to keep execution time for this mode under a few seconds. */

Source from the content-addressed store, hash-verified

85 * to keep execution time for this mode under a few seconds.
86 */
87void initialize() {
88 pros::lcd::initialize(); // initialize brain screen
89 chassis.calibrate(); // calibrate sensors
90
91 // the default rate is 50. however, if you need to change the rate, you
92 // can do the following.
93 // lemlib::bufferedStdout().setRate(...);
94 // If you use bluetooth or a wired connection, you will want to have a rate of 10ms
95
96 // for more information on how the formatting for the loggers
97 // works, refer to the fmtlib docs
98
99 // thread to for brain screen and position logging
100 pros::Task screenTask([&]() {
101 while (true) {
102 // print robot location to the brain screen
103 pros::lcd::print(0, "X: %f", chassis.getPose().x); // x
104 pros::lcd::print(1, "Y: %f", chassis.getPose().y); // y
105 pros::lcd::print(2, "Theta: %f", chassis.getPose().theta); // heading
106 // log position telemetry
107 lemlib::telemetrySink()->info("Chassis pose: {}", chassis.getPose());
108 // delay to save resources
109 pros::delay(50);
110 }
111 });
112}
113
114/**
115 * Runs while the robot is disabled

Callers

nothing calls this directly

Calls 5

telemetrySinkFunction · 0.85
calibrateMethod · 0.80
infoMethod · 0.80
printFunction · 0.50
getPoseMethod · 0.45

Tested by

no test coverage detected