Skip to main content

Utilities for building frc robots

Project description

Mars Utilities

Utilties for building better robot code

View the docs online at Read the Docs

ControlManager

ControlManager provides a wrapper that makes making alternate control modes (alternate drivers, different controlers) incredibly simple. It is designed primarially for MagicRobot components, however, it should work with any type.

See example/ for an example robot.

Usage

First, all of the controls must be implemented as classes that subclass marsutils.ControlInterface. The primary control code defined in the teleopPeriodic method. Then, you must define the _DISPLAY_NAME field which will be displayed on the dashboard autochooser. You can set _SORT to prioritize certain interfaces, the higher the number, the higher on the chooser list.

Because it is a magic bot component, you can access injected components.

But you must make an empty execute function to be a valid magicbot function.

After you have the control components there are two ways to create the manager.

MagicBot magic

If you are using the MagicRobot framework you can use the @with_ctrl_manager decorator to automagically set everything up. Just annotate your robot class with @with_ctrl_manager and you are done. It will magically detect any ControlInterfaces, construct the ControlManager and automatically call the periodic functions.

Using the decorator also means you don't need to define an execute function.

Manually

Otherwize, you must must set up manager by initializing ControlManager with all of your components after createObjects has been called. This is not technically possible with the MagicBot framework yet.

self.control_manager = marsutils.ControlManager(self.xbox_ctrl, self.joystick_ctrl)

After you have created the control manager, you must call its periodic functions. This means adding self.control_manager.teleopPeriodic() to your teleopPeriodic function and so on for each function you use.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marsutils-0.5.0.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file marsutils-0.5.0.tar.gz.

File metadata

  • Download URL: marsutils-0.5.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for marsutils-0.5.0.tar.gz
Algorithm Hash digest
SHA256 2fc1085fb6f828b4e4128511fcb1a586b0f2b0f2281d370a35d5794a314c3489
MD5 760f5d71f0f193e3c9c0c06d5b4fbace
BLAKE2b-256 417fc7e4d7f6d3a4f94e39ee4e0da7e49fad0abb63cd4f79cef63126c03cdd3c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page