Lynx Modules
Representing the control hub in your code
Resources
GM0's Page on Lynx Modules - Must read!
GM0's Lynx Module Code - Must Read!
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
We highly recommend that you don't use this mode! Making use of bulk reads can significantly speed up the loop times of your robot, making your autonomous and teleop periods alot smoother.
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.
Make sure not to query the same sensor more than once in the same loop, as it can lead to errors!
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::
Although you can call query the same sensor as many times as you want in a single loop with manual mode, you must clear your cache at the start of every loop!
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