Changes between Version 1 and Version 2 of Sensors


Ignore:
Timestamp:
Jan 29, 2016, 9:39:58 AM (9 years ago)
Author:
alex
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Sensors

    v1 v2  
    33Here's how to get sensor values that pass through the arduino:
    44
    5 For now look at manipulatorArm, which has an example, and figure it out. Alex will (probably) write a more in depth tutorial tomorrow, but right now he's going to play his weeaboo game.
     5First, you need to register your Subsystem with the sensors system. To do this, you first need to go into Robot.java and after you create your subsystem and run initDefaultCommand() and registerButtons() (if applicable), put the line sensorSys.registerListener(Subsystem Name, ie armSys).
     6
     7Once that's complete, you'll need to go into your Subsystem and make it implement the SensorListener interface via {{{implements SensorListener}}}. For the arm subsystem, this looks like {{{public class ArmSubsystem extends Subsystem implements SensorListener}}}.
     8
     9Once you've done this eclipse should yell at you that you have unimplemented methods. Allow it to implement these and you'll have a new method named receivedValue. receivedValue is called in the handleEvents class and will pass you a hashmap of all the sensors with a tag and a value. Go into the class Sensor.java (singular) in order to see a list of all the sensor values and their tags. If your sensor value isn't there, create it. Don't worry about what the tag is - that's Alex's and sensors team's job. In order to get your sensor data, simply set a variable equal to e.get(Sensor.VALUE_NAME).
     10
     11And that's all! An example can be found in the manipulatorArm branch and the Arm Subsystem. Any questions feel free to ask Alex or Tim.