This reactor package library provides base reactors for interfacing with components of the Pololu 3pi+ 2040 robot, along with the C headers and utility routines used by the base reactors. This library is written in the C target of Lingua Franca.
This library requires installing the Raspberry Pi Pico SDK and picotool.
Please follow the steps in https://www.lf-lang.org/embedded-lab/Prerequisites.html.
Please follow the steps in https://www.lf-lang.org/embedded-lab/Non-Nix.html.
- Bump: Periodically reads the bump sensors and outputs their states.
- BumpAdjustable: Reads the left and right bump sensors with configurable calibration sample count and press/release thresholds, allowing bump detection behavior to be tuned for different operating conditions.
- BumpLog: Provides logging to bump sensor data. It passes the bump sensor fields through without modifying their values, allowing applications to record bump events and sensor state while the data continues through the reactor network.
- Display: Receives strings and displays them on the LCD display.
- Encoder: Reads the wheel encoders when triggered and outputs the measured angle in degrees.
- EncoderLog: Provides logging to wheel encoder and motion-related data, including encoder counts, encoder deltas, traveled distance, and command values. It preserves the original values while exposing them for logging and analysis of robot movement.
- Accelerometer, Gyro, and GyroAngle: Read the IMU values when triggered and output the acceleration, angular velocity, and the robot's angle relative to its initial orientation, respectively.
- IMULog: Provides logging for gyroscope heading and turn-target data. It receives the current gyroscope-derived heading angle and the target heading angle used by the robot's turning logic, and exposes them as standardized logging outputs without changing their values.
- Line: Reads the line sensors when triggered and outputs their values. By default, calibration is performed upon receiving the first trigger. NOTE: Using the line sensors together with the bump sensors is generally impractical because they interfere with each other.
- LineSensorLog: Provides logging to line sensor measurements and selected line-tracking state. It preserves the original values while exposing them for logging, making it easier to analyze line detection and the robot's line-following behavior.
- Motors: Drives the left and right motors according to the power levels provided as inputs.
- MotorsWithFeedback: Wraps Motors with a proportional-integral (PI) feedback controller. It uses encoder measurements to adjust motor power so that the measured wheel speeds track the desired speeds.
Clone the repo into your lf-packages directory in the root of your project or into the directory pointed to by your LF_PACKAGES environment variable:
git clone https://github.com/lf-lang/pololu-3pi-c.gitAlternatively, if you are in a git repo, create a submodule:
git submodule add https://github.com/lf-lang/pololu-3pi-c.gitThen import the library reactors. For example:
import Display from <pololu-3pi-c>
This package library is currently used by the lf-3pi-template repository as the main template library for the Embedded Systemd Labs.
The reactor libraries for logging are used by the cps-operational-sim repository for logging sensor and operational data in CPS simulations.