FireANT

From EQUIS Lab Wiki

Jump to: navigation, search


Contents

Overview

FireANT is a program intended to take input from a heart rate monitor and a cadence Sensor, both of which provide data using the ANT+ protocol, and print the two values to the console every 1/10th of a second. This information can be used as input for exercise games, most notably Libery. See the Liberi Developer Guide for more information about Liberi.

All hardware required for FireANT are available in the EQUIS lab.

  • To detect any ANT+ signals, you must have an ANT+ USB Dongle. For more information on the ANT+ Dongle, see: [1]
  • The Mio Link Heart Rate Monitor keeps track of the wearer's heart rate. For more information on the Mio Link, see: [2]
  • There are two different types of cadence sensor that are supported by FireANT:
    • The Wahoo RPM provides cadence via an accelerometer. For more information on the Wahoo RPM, see: [3]
    • The Garmin Speed/Cadence sensor provides cadence by sending a signal every time it passes over a magnet. For more information on the Garmin Speed/Cadence Sensor, see: [4]

Getting Started

Download the project from the EQUIS Subversion Repository here: svn://equis.cs.queensu.ca:36141/FireAntRefactored/trunk/ Once the project is downloaded, you can run FireAnt.exe from the console or via Visual Studio. You will begin to see the string "0 0" being repeated over and over again. Activate the Heart Rate Monitor, and you will see the first digit change from 0 to the current heart rate being read from the HRM. Activate the cadence sensor, and you will see the second digit change from 0 to the current cadence being read from the sensor.

In order to achieve cadence sensor functionality, it is likely that you will have to modify the AntDevicesDescription.txt file, which dictates which device FireANT scans for cadence values. The procedure for modifying this file is found in the next section.

AntDevicesDescription.txt

In order to inform the program which type of cadence sensor to expect, you will need to modify "AntDevicesDescription.txt". The contents of the text file look like this:

devicetype = 122
devicenum = 0
transtype = 1
channelperiod = 8102
//devicetype = 121
//devicenum = 0
//transtype = 1
//channelperiod = 8086
devicetype = 120
devicenum = 0
transtype = 1
channelperiod = 8070

There are 3 separate configurations in this file, each with 4 properties.

  • The devicetype is an ID which represents the type of sensor.
    • 120 is a Heart Rate Monitor
    • 121 is a Cadence/Speed Sensor (magnetic sensor)
    • 122 is a Cadence Sensor (Wahoo RPM)
      • Note that either the device 121 or 122 must be commented out for FireANT to discover the appropriate sensor. If you are using a Wahoo (122), then comment out 121, and if you are using a magnetic sensor, vice-versa.
  • The devicenum is an ID which represents the actual sensor being used.
    • Set devicenum to 0 for pairing
    • In a room with more than one of each sensor, you will need to provide the devicenum of the sensor you would like to use to prevent pairing with the wrong device. To find out a sensor's devicenum, use SimulANT.
  • Set transtype to 0 for searching, 1 if otherwise.
  • The channelperiod is the frequency for that device.
    • Heart rate monitors have a channelperiod of 8070.
    • Cadence/Speed sensors have a channelperiod of 8086.
    • Cadence sensors have a channelperiod of 8102.

Using SimulANT+ to Find Sensor Information

In order to find the device number of an ANT+ device, you must use SimulANT+ to find the device. SimulANT+ is available on the ANT+ Software Tools Page for any registered member to download. In order to use SimulANT+, you must have an ANT+ dongle connected to your computer. Once the dongle is connected, run SimulANT+ using the executable file SimulANT+.exe.

In order to find a device's devicenum using SimulANT+, follow the following instructions:

  • Select Add Simulator.
  • In the dropdown of the new window, select the option which corresponds to the device you are searching for.
    • For a magnetic cadence sensor, you should select the option Bike Cadence and Speed Sensor.
    • For a Wahoo RPM, you should select the option Bike Cadence Sensor.
  • In the main window, select the device whose device number you seek.
  • In the bottom of the window, there should be two buttons: Turn On and Turn Off. Choose Turn On.
  • The device's device number should appear in the section marked Extended Device Number.

Documentation

The following is the documentation for the FireANT project. All documentation is provided within the source code as well.

Namespace Index

Packages

Here are the packages with brief descriptions (if available):

  • ANTReporting
  • FireAnt

Class Index

Here are the classes, structs, unions and interfaces with brief descriptions:

  • ANTReporting.ANTReporter - Connect to a ANT compatible device and report data from different sensors.
  • ANTReporting.ANTReporterChannelConfiguration
  • ANTReporting.ANTReporterConfiguration
  • FireAnt.Program - This class contains the Main(string[] args) method, and is used to run the program. It handles output to the console, and stores public variables to read from in a Unity Project in the future.

Namespace Documentation

Package ANTReporting

Classes
  • class ANTReporter - Connect to a ANT compatible device and report data from different sensors.
  • class ANTReporterChannelConfiguration
  • class ANTReporterConfiguration

Package FireAnt

Classes
  • class Program - This class contains the Main(string[] args) method, and is used to run the program. It handles output to the console, and stores public variables to read from in a Unity Project in the future.
  • class Resources - A strongly-typed resource class, for looking up localized strings, etc.

Class Documentation

ANTReporting.ANTReporter Class Reference

Connect to a ANT compatible device and report data from different sensors.

Public Member Functions
  • ANTReporter (int nSensors, float lowestCadence) - Construct an ANTReporter, Connect it to a USB device, and initialize channels
  • void ConnectANTUSBDevice () - Connect and initialize an ANT USB device.
  • void ConnectBike () - Connect an exercise bike's cadence monitor to the ANTReporter.
  • void ConnectHeartRateMonitor () - Connect a heart rate monitor to the ANTReporter.
  • void CloseANTReporter () - Closes the ANTReporter's channels and prepares it for destruction.
  • void ConfigureANT () - Resets the system, configures the ANT channel and starts the demo.
  • bool IsReceiverDeviceReady () - Returns true if the receiver device is ready, and false otherwise.
  • float SmoothCadence () - Calculates a weighted average cadence of the set of cadences in memory.
  • float GetHeartRate () - Returns the current heart rate from the HRM.
  • bool IsHeartRateMonitorConnected () - Determines whether or not the heart rate monitor is connected.
  • bool IsBikeConnected () - Determines whether or not the cadence sensor is connected.
  • float GetHRDeviceNumber () - Finds the heart rate monitor's device number.
  • float GetCadenceSensorDeviceNumber () - Finds the cadence sensor's device number.
Properties
  • static ANTReporter Instance [get] - A singleton reference to the ANTReporter itself
  • ANTReporterConfiguration configuration - The configuration of the ANTReporter itself
Constants
  • float BIKE_CADENCE_EVENT_TIMEUNIT = 1f / 1024f
  • float BIKE_CADENCE_EVENT_TIMEROLLOVER = 64f
  • int CUMULATIVE_CADENCE_REVOLUTION_ROLLOVER = 65536
Private Attributes
  • ANT_Device receiverDevice - ANT+ compatible device receiving data
  • ANTReporterChannelConfiguration bikeProfile - Configuration profile for the bike sensor
  • ANT_Channel bikeChannel - Channel of the bike cadence and speed sensor
  • readonly byte bikeChannelNum - The channel number of the bike sensor, as a byte
  • ANTReporterChannelConfiguration hrmProfile - Configuration profile for heart rate monitor
  • ANT_Channel hrmChannel - Channel of the heart rate monitor
  • readonly byte hrmChannelNum - The channel number of the heart rate monitor, as a byte
  • bool cadenceOnly - the discovered cadence sensor is a cadence-only sensor (true) or a cadence+speed sensor (false)
  • byte[] user_network_key - The network key, as a byte array
  • byte user_network_num - The user's network number, as a byte value
  • int nSensors - Number of Sensors On Exercise Bike
  • float lowestCadence - Minimum acceptable Cadence
  • double lowestSensorToSensorTime - lowest time taken to reach the next sensor, so far
  • bool isBikeConnected - True if the bike is connected, false if otherwise.
  • int heartRate - The user's current heart rate.
  • bool isHeartRateMonitorConnected - True if the heart rate monitor is connected, false if otherwise.
Constructor & Destructor Documentation

ANTReporting.ANTReporter.ANTReporter (int nSensors, float lowestCadence) - Construct an ANTReporter, Connect it to a USB device, and initialize channels

  • Parameters:
    • int nSensors - The number of sensors attached to the chassis of the exercise bike.
    • float lowestCadence - The minimum allowable cadence (used for determining if stopped).
Member Function Documentation
  • void ANTReporting.ANTReporter.CloseANTReporter () - Closes the ANTReporter's channels and prepares it for destruction.
  • void ANTReporting.ANTReporter.ConfigureANT () - Resets the system, configures the ANT channel and starts the demo.
  • void ANTReporting.ANTReporter.ConnectANTUSBDevice () - Connect and initialize an ANT USB device.
  • void ANTReporting.ANTReporter.ConnectBike () - Connect an exercise bike's cadence monitor to the ANTReporter.
  • void ANTReporting.ANTReporter.ConnectHeartRateMonitor () - Connect a heart rate monitor to the ANTReporter.
  • float ANTReporting.ANTReporter.GetCadenceSensorDeviceNumber () - Finds the cadence sensor's device number.
    • Returns: The device number.
  • float ANTReporting.ANTReporter.GetHeartRate () - Returns the current heart rate from the HRM.
    • Returns: Current Heart Rate.
  • float ANTReporting.ANTReporter.GetHRDeviceNumber () - Finds the heart rate monitor's device number.
    • Returns: The device number.
  • bool ANTReporting.ANTReporter.IsBikeConnected () - Determines whether or not the cadence sensor is connected.
    • Returns: true if the sensor is connected, false if otherwise.
  • bool ANTReporting.ANTReporter.IsHeartRateMonitorConnected () - Determines whether or not the heart rate monitor is connected.
    • Returns: true if the HRM is connected, false if otherwise.
  • bool ANTReporting.ANTReporter.IsReceiverDeviceReady () - Returns true if the reciever device is ready, and false otherwise.
    • Returns: A boolean value representing the state of the reciever: TRUE = Ready; FALSE = Not Ready.
  • float ANTReporting.ANTReporter.SmoothCadence () - Calculates a weighted average cadence of the set of cadences in memory.
    • Returns:A weighted cadence

The documentation for this class was generated from the following file: C:/Users/LiamCollins/Documents/Visual Studio 2015/Projects/FireAnt/trunk/FireAntRefactored/ANTReporter.cs

ANTReporting.ANTReporterChannelConfiguration Class Reference

Static Public Attributes
  • static readonly byte[] ANT_PLUS_NETWORK_KEY = { 0xB9, 0xA5, 0x21, 0xFB, 0xBD, 0x72, 0xC3, 0x45 }
  • static readonly byte[] PUBLIC_NETWORK_KEY = { 0xE8, 0xE4, 0x21, 0x3B, 0x55, 0x7A, 0x67, 0xC1 }
Properties
  • ANT_ReferenceLibrary.ChannelType USER_ANT_CHANNELTYPE [get]
  • ushort USER_DEVICENUM [get, set]
  • byte USER_DEVICETYPE [get, set]
  • byte USER_TRANSTYPE [get, set]
  • byte USER_RADIOFREQ [get]
  • ushort USER_CHANNELPERIOD [get, set]
  • byte[] USER_NETWORK_KEY [get]
  • byte USER_NETWORK_NUM [get]
Constructor & Destructor Documentation

ANTReporterChannelConfiguration:ANTReporting::ANTReporterChannelConfigurationANTReporting::ANTReporterChannelConfiguration:ANTReporterChannelConfigurationANTReporting.ANTReporterChannelConfiguration.ANTReporterChannelConfiguration (ANT_ReferenceLibrary.ChannelType user_ant_channeltype, ushort user_devicenum, byte user_devicetype, byte user_transtype, byte user_radiofreq, ushort user_channelperiod, byte[] user_network_key, byte user_network_num) - Constructs a ANTReporterChannelConfiguration object, based on 8 numerical parameters.

  • Parameters
    • ANT_ReferenceLibrary.ChannelType user_ant_channeltype - Given as a byte.
    • ushort user_devicenum - The device number.
    • byte user_devicetype - the byte value representing the device's type.
    • byte user_transtype - the byte value representing the transtype.
    • byte user_radiofreq - the frequency of the device's radio signal.
    • ushort user_channelperiod - the channel period for the device (8086 for cadence+speed, 8070 for heart rate).
    • byte[] user_network_key - the network key, as a byte array.
    • byte user_network_num - the network number.

The documentation for this class was generated from the following file: C:/Users/LiamCollins/Documents/Visual Studio 2015/Projects/FireAnt/trunk/FireAntRefactored/ANTReporterChannelConfiguration.cs

ANTReporting.ANTReporterConfiguration Class Reference

Public Member Functions
  • ANTReporterConfiguration (String filePath) - Create an ANTReporterConfiguration object using a given file path.
  • void UpdateTransType (int index, byte transtype) - Updates the transtype at a given index, with a given value.
  • void UpdateDeviceNum (int index, ushort deviceNum) - Updates the device number at a given index, with a given value.
Public Attributes
  • readonly List< ANTReporterChannelConfiguration > channelConfigurations
Constructor & Destructor Documentation

ANTReporting.ANTReporterConfiguration.ANTReporterConfiguration (String filePath) - Create an ANTReporterConfiguration object using a given file path.

  • Parameters*
    • string filePath -the file path.
Member Function Documentation
  • void ANTReporting.ANTReporterConfiguration.UpdateDeviceNum (int index, ushort deviceNum) - Updates the device number at a given index, with a given value.
    • Parameters:
      • int index - the index of the field.
      • ushort deviceNum - the value to update the device number with.
  • void ANTReporting.ANTReporterConfiguration.UpdateTransType (int index, byte transtype) - Updates the transtype at a given index, with a given value.
    • Parameters:
      • int index - the index field.
      • byte transtype - the value to update the transtype with.

The documentation for this class was generated from the following file: C:/Users/LiamCollins/Documents/Visual Studio 2015/Projects/FireAnt/trunk/FireAntRefactored/ANTReporterConfiguration.cs

FireAnt.Program Class Reference

This class contains the Main(string[] args) method, and is used to run the program. It handles output to the console, and stores public variables to read from in a Unity Project in the future.

Static Public Member Functions

  • static void Main (string[] args) - The main method for the program. The program takes two arguments, which are then passed to Init(string[] args).
    • Argument 1: numSensors -> If using the magnetic sensor, how many magnets are attached to the chassis of the bike? If using the Wahoo RPM, set this to 1 or provide no arguments. Default value = 1.
    • Argument 2: minCadence -> The minimum allowable cadence. If the cadence is lower than the minimum then the program will consider the bike to be stationary. Default value = 10.
  • static void Init (string[] args) - Starts a thread and begins retrieving ANT+ signals using ReadDevicesAsync(object data).
  • static void ReadDevicesAsync (object data) - The bulk of the program: Reading devices, outputting data to console. Runs in an infinite loop, waiting for 1/10th of a second before outputting the next value set.

Static Public Attributes

  • static float HeartRate
  • static float Cadence
  • static bool isMoving

The documentation for this class was generated from the following file: C:/Users/LiamCollins/Documents/Visual Studio 2015/Projects/FireAnt/trunk/FireAntRefactored/Program.cs

Personal tools