Lynx Modules

Representing the control hub in your code

Resources

The Lynx Module is used as an object for each hub on your robot. Each hub on your robot has a Lynx Module created for it. Before doing anything else software related to your robot, it is a good idea to quickly write code that takes care of your control hub. Luckily, this process is easy.

Bulk Reading

One of the main uses for the Lynx Module is for bulk reading of sensor outputs. It can bulk read all of your sensor outputs at once, and therefore make your loop run a lot faster.

Implementation

Off Mode

circle-exclamation
// Paste this where you initialize your hardware

void initHardware(){
   // Always setup your lynx modules before your hardware.
   List<LynxModule> allHubs = hardwareMap.getAll(LynxModule.class);

   for (LynxModule hub : allHubs) {
      hub.setBulkCachingMode(LynxModule.BulkCachingMode.OFF);
   }
   
   initMotors(); 
   initServos(); 
}

Auto Mode

This is the simplest mode to use that utilizes bulk reads; a new bulk read is done when a hardware read is repeated.

circle-exclamation

This implementation from Game Manual 0 gives a good implementation for using the Auto Mode of the Lynx Module

Manual Mode

GM0:

In manual mode the cache for bulk reads is only reset once manually reset. This can be useful, as it is the way to absolutely minimize extraneous reads, however if the cache is not reset, stale values will be returned. That being said, here’s a proper implementation of MANUAL mode::

triangle-exclamation

Common Error When Using Manual Mode.

An common error that can stump teams using Manual mode is when executing code in a for, or while loop. If you don't reset your cache in these other loops, your robot can go haywire!

Here is a proper implementation of Manual mode when using a for or while loop in your code:

This is the part that resets the bulk cache in manual mode.

Measuring Voltage

Something else you can do through the Lynx Module is measure the voltage and current that your hubs are receiving

Getting Battery Voltage

You can find the voltage of the 12V battery supplying robot power using the following line.

Measuring Current

You can also measure the total current draw of the hubs and everything plugged into them by using the getCurrent() method, along with the desired unit

Last updated