← Back to Main Portfolio

task_user.py

Purpose

This file implements the serial user-interface task. It inherits command-handling behavior from UserCmds and provides the live runtime interface used for tuning gains, calibrating sensors, printing diagnostic values, starting or stopping line-follow mode, and controlling estimator streaming.

Main Role

This task is the main human-facing interface to the robot. It makes the robot much easier to test and tune because many settings can be changed at runtime rather than by repeatedly editing code.

Key Responsibilities

Important Attributes / Shares / Variables

NameDescription
_serUSB serial interface object used for user interaction.
_leftMotorGo, _rightMotorGoShares used to control motor enable from the UI.
_Kp, _KiGain Shares edited through the UI.
_vBaseLine-follow base speed Share.
_lfEnableShare used to toggle line-follow mode.
_estStreamEnableShare used to enable observer streaming.
_sensLine sensor object used for calibration and printout commands.
_imuIMU object used for calibration and IMU printout commands.
_courseEnableShare used to start or stop the full course task.
_buf, _mode, _num_strInternal state used while collecting typed user input.

Task States

StateDescription
S0_INITPrints the help menu and prompt at startup.
S1_CMDWaits for user commands.
S2_GETCollects multi-character numeric input.
S3_COLWaits until log queues are ready to dump data.
S4_DISDisplays buffered data over the serial interface.

Why This File Matters

This file made the full development process dramatically easier by turning many tuning and diagnostic tasks into serial commands rather than manual source edits. It is one of the most practical files in the project.

Open raw task_user.py file