Cobra

The Cobra Line Follower provides an array of line IR reflective sensors to be used for detecting a line. The Cobra uses four QRE1113 sensors for detecting the line.

../../_images/cobra-1.jpg
Electrical Characteristics

Function

Min

Nom

Max

Input Voltage

3.3VDC

5VDC

5VDC

Current

25mA

70mA

100mA

Sensing Distance

2mm

3mm

Analog Module

To plug the Cobra into the VMXpi the analog module is required.

../../_images/cobra-2.png

The Cobra will plug directly into the analog module. The module will then use the provided JST SH to JST GH cable to connect to the i2c port on the VMXpi.

Programming the Cobra

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
//import the Cobra Library
import com.studica.frc.Cobra;

//Create the Cobra Object
private Cobra cobra;

//Constuct a new instance
cobra = new Cobra();
// or if sensor is using 3.3V
cobra = new Cobra(3.3F);

//Can then use these accssors to get data
cobra.getVoltage(channel); //returns a float
cobra.getRawValue(channel); //returns a double

The accessor methods will output either the voltage (0 - 5V) or the raw ADC value (0 - 2047).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
//Include the Cobra Library
#include "studica/Cobra.h"

//Constructors
studica::Cobra cobra{};
// or if sensor is using 3.3V
studica::Cobra cobra{3.3F};

//Use these to access data
cobra.GetVoltage(channel); //returns a float
cobra.GetRawValue(channel); //returns a double

The accessor functions will output either the voltage (0 - 5V) or the raw ADC value (0 - 2047).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
//Include the Cobra Library
#include "Cobra_ros.h"

/**
 * Constructor
 * Cobra's ros threads (publishers and services) will run asynchronously in the background
 */
ros::NodeHandle nh; //internal reference to the ROS node that the program will use to interact with the ROS system
VMXPi vmx(true, (uint8_t)50); //realtime bool and the update rate to use for the VMXPi AHRS/IMU interface, default is 50hz within a valid range of 4-200Hz

CobraROS cobra(&nh, &vmx); //default device address is 0x48 and default voltage is 5.0F
// or can use
CobraROS cobra(&nh, &vmx, deviceAddress);
// or if sensor is using 3.3V, refVoltage(3.3F)
CobraROS cobra(&nh, &vmx, deviceAddress, refVoltage);

// Use these to directly access data
cobra.GetVoltage(channel); //returns a float
cobra.GetRawValue(channel); //returns an int

The accessor functions will output either the voltage (0 - 5V) or the raw ADC value (0 - 2047).

Important

Subscribe to Cobra topics to access the data being published and write callbacks to pass messages between various processes.