|
|||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Flock
Provides sort of a java API to the Flock of Birds. Things to remember about the flock:
The flock addresses are numbered starting at 1.
Each time the baud rate changes in the code, the dipswitch settings on the
flock electronics box must be set.
This class handles the high level commands that can be sent to an individual bird or to the flock Master.
It is currently configured so that only the Master sends data back to the host. That is as soon as the flock starts flying, it is put into GROUP MODE. However, settings for individual birds are sent through their respective serial lines.
In this version, as soon as a capture is completed, the data is written to an ascii file called "readable.dat"
Inner Class Summary | |
(package private) class |
Flock.DefaultListener
This class provides a default serial port listener for the flock. |
(package private) class |
Flock.ExamineListener
A class for listening to data elicited by the EXAMINE command. |
Field Summary | |
private int |
ANGLE_ALIGN2_DATA_SIZE
|
private byte |
ANGLE_ALIGN2_PARAM
|
static byte |
ANGLES_DATA
|
private byte |
AUTOCONFIG_PARAM
|
private float |
azimReference
The azimuth (Z) angle for the orientation of the transmitter reference frame |
private Bird[] |
birds
An array to hold all of the birds |
private CaptureData |
captureData
Holds the sensor data stream and process it. |
private byte |
CHANGEVALUE_COMMAND
|
private boolean |
debug
|
private Flock.DefaultListener |
defaultListener
Default listener to catch bytes coming from any serial line. |
private short |
defaultMeasurementRate
The default measurement rate [Hz] for the birds |
private float |
elevReference
The elevation (Y) angle for the orientation of the transmitter reference frame |
private Flock.ExamineListener[] |
eListener
ExamineListeners for each bird |
private byte |
EXAMINE_VALUE_COMMAND
|
private short |
flockSize
Number of birds in the flock. |
private byte |
GROUP_MODE_PARAM
|
private boolean |
groupMode
Indicates that the flock is in GROUP mode. |
private boolean |
isConnected
Indicates that the host is talking to the flock |
private Bird |
master
A reference to the flock master |
private byte |
MATRIX_MODE
|
private int |
maxFlockSize
The total number of birds we own. |
private byte |
MEASUREMENT_RATE_PARAM
|
private short |
measurementRate
The current measurement rate for the birds |
private Capture |
parent
|
private byte |
POINT_COMMAND
|
private java.lang.String[] |
portNames
The 6 port names that we can use |
private byte |
POSITION_ANGLES_MODE
|
private int |
POSITION_ANGLES_NUM_BYTES
|
private byte |
POSITION_MATRIX_MODE
|
private int |
POSITION_MATRIX_NUM_BYTES
|
private byte |
POSITION_MODE
|
private int |
POSITION_NUM_BYTES
|
static byte |
QUATERNION_DATA
|
private static java.lang.String |
readableFileName
Name of ascii file that data gets written to. |
private boolean |
reconfig
Indicates that the flock size needs to be set. |
private byte |
REFERENCE_FRAME2_PARAM
|
private boolean |
referenceFrameChanged
Indicates that the reference frame has been changed using the CHANGE REFERENCE FRAME2 command |
private float |
rollReference
The roll (X) angle for the orientation of the transmitter reference frame |
private byte |
RS232_TO_FBB
|
private byte |
RUN_COMMAND
|
private byte |
SLEEP_COMMAND
|
private boolean |
sleeping
Indicates flock has been put to sleep with the SLEEP command |
private long |
startTime
The time in millis that the streaming started |
private long |
stopTime
The time in millis that the streaming stopped |
private byte |
STREAM_COMMAND
|
private boolean |
streaming
Indicates that the STREAM command is in effect |
Constructor Summary | |
Flock()
kind of a dummy constructor |
|
Flock(Capture app)
Default constructor for Flock. |
Method Summary | |
void |
beginCapture()
Starts capturing data. |
void |
calibrate(int addr,
float[] angles)
Sends the ALIGN2 change command to the bird at this angle. |
private void |
changeAngleAlign2(int addr,
float[] angles)
Changes the alignment angles. |
private void |
changeAngleAlign2(int addr,
float azim,
float elev,
float roll)
Change the X, Y and Z axes of the the sensor for this bird. |
private void |
changeAutoconfig()
Initialize the flock to be a certain size. |
void |
changeMeasurementRate(int addr,
short rate)
Change the measurement rate that the bird returns. |
void |
changeMeasurementRate(short rate)
Change the measurement rate for the whole flock. |
private void |
changeReferenceFrame2(float azimuth,
float elevation,
float roll)
Change the reference frame that is used to measure orientation. |
void |
enableGroupMode()
Tells the flock to go into group mode. |
void |
endCapture()
Ends the capture. |
private void |
examineAngleAlign2(int addr)
Examine the angles sent in the last CHANGE ANGLE ALIGN2 command. |
void |
examineMeasurementRate()
Examine the measurement rate for the whole flock |
void |
examineMeasurementRate(int addr)
Send the EXAMINE command with parameter MEASUREMENT RATE. |
private void |
examineReferenceFrame2()
Examine the angles that were sent to the birds using the CHANGE REFERENCE FRAME2 command. |
void |
fly()
When the flock is running with a master and slaves, this method is used to tell the flock to start flying. |
SerialConnectionListener |
getDefaultListener()
Default listener accessor. |
int |
getFlockSize()
Returns the number of active birds in the flock. |
private java.lang.String |
getQuaternion(byte[] rec)
Interprets the byte data as a record, and then returns a String representation of it, as well as of the birds address. |
boolean |
isGroupMode()
Returns true if the flock is in groupMode, false otherwise. |
boolean |
isStreaming()
Returns true if the flock is in streaming mode, false otherwise. |
boolean |
saveCaptureToFile(java.lang.String filename)
Saves the last capture to a file. |
void |
sendAutoconfig()
Send the changeAutoconfig command as a way to reset the flock if it seems to be having problems. |
void |
sendPointCommand()
Sends the point command to the Master bird. |
private void |
sendPointCommand(int addr)
Sends the point command to the bird at the particular address |
void |
sendSleepCommand()
Sends the sleep command to the Master bird. |
private void |
sendStreamCommand()
Sends the stream command to all of the birds in the flock. |
void |
setAnglesMode()
Put the whole flock into ANGLES mode |
void |
setAnglesMode(int addr)
Put the bird at this address into ANGLES mode. |
void |
setFlockSize(short size)
Sets the size of the flock. |
void |
setMatrixMode()
Put the whole flock into matrix mode |
void |
setMatrixMode(int addr)
Put bird at this address into matrix mode. |
void |
setQuaternionMode()
Put the whole flock into QUATERNION mode |
void |
setQuaternionMode(int addr)
Put bird at this address into QUATERNION mode. |
void |
shutdown()
Puts the birds to sleep and closes the serial connections to the flock. |
private void |
stopStream()
Stops the birds from streaming data. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private final boolean debug
private Capture parent
private short flockSize
private final int maxFlockSize
private final short defaultMeasurementRate
private short measurementRate
private Bird[] birds
private Bird master
private final java.lang.String[] portNames
private CaptureData captureData
private Flock.ExamineListener[] eListener
private Flock.DefaultListener defaultListener
private boolean isConnected
private boolean sleeping
private boolean streaming
private long startTime
private long stopTime
private boolean reconfig
private boolean groupMode
private boolean referenceFrameChanged
private final float azimReference
private final float elevReference
private final float rollReference
private static java.lang.String readableFileName
private final byte POSITION_ANGLES_MODE
private final int POSITION_ANGLES_NUM_BYTES
private final byte POSITION_MATRIX_MODE
private final int POSITION_MATRIX_NUM_BYTES
private final byte POSITION_MODE
private final int POSITION_NUM_BYTES
private final byte MATRIX_MODE
public static final byte QUATERNION_DATA
public static final byte ANGLES_DATA
private final byte CHANGEVALUE_COMMAND
private final byte EXAMINE_VALUE_COMMAND
private final byte POINT_COMMAND
private final byte RUN_COMMAND
private final byte SLEEP_COMMAND
private final byte STREAM_COMMAND
private final byte ANGLE_ALIGN2_PARAM
private final int ANGLE_ALIGN2_DATA_SIZE
private final byte AUTOCONFIG_PARAM
private final byte GROUP_MODE_PARAM
private final byte MEASUREMENT_RATE_PARAM
private final byte REFERENCE_FRAME2_PARAM
private final byte RS232_TO_FBB
Constructor Detail |
public Flock()
public Flock(Capture app)
Method Detail |
public boolean isGroupMode()
public int getFlockSize()
public boolean isStreaming()
public SerialConnectionListener getDefaultListener()
public void setMatrixMode()
public void setMatrixMode(int addr)
addr
- is the address of the bird whose data mode is being set.public void calibrate(int addr, float[] angles)
addr
- The address of the bird whose sensor is being aligned.angles
- the Z Y X angles that give the new sensor orientation frame.private void changeAngleAlign2(int addr, float azim, float elev, float roll)
We use this command in order to calibrate the sensors. If we measure the sensor's orientation, and then send that orientation to this command without moving the sensors, the next time we measure, the sensor output will all be zero.
The parameters are the difference between the sensor's current orientation and a zeroed orientation.
addr
- The address of the bird whose sensor is being changed.azim
- The azimuth (Z) angle.elev
- The elevevation (Y) angle.roll
- The roll (X) angle.private void changeAngleAlign2(int addr, float[] angles)
addr
- is the address of the bird to be aligned.angles
- the new angles in order Z Y X.changeAngleAlign2(int, float, float, float)
private void examineAngleAlign2(int addr)
changeAngleAlign2(int, float, float, float)
private void changeReferenceFrame2(float azimuth, float elevation, float roll)
azimuth
- The alignment angle in degrees about the transmitter Z axis.elevation
- The alignment angle in degrees about the transmitter Y axis.roll
- The alignment angle in degrees about the transmitter X axis.private void examineReferenceFrame2()
public void changeMeasurementRate(int addr, short rate)
(Note: This member is named changeMeasurementRate
instead of
setMeasurementRate
since it uses the CHANGE VALUE form
of bird command.)
addr
- The address of the bird the command is being sent to.rate
- The rate in cycles/second.public void changeMeasurementRate(short rate)
changeMeasurementRate(int,short)
public void examineMeasurementRate(int addr)
public void examineMeasurementRate()
public void setQuaternionMode()
public void setQuaternionMode(int addr)
addr
- is the address of the bird whose data mode is being set.public void setAnglesMode()
setAnglesMode(int)
public void setAnglesMode(int addr)
public void sendPointCommand()
private void sendPointCommand(int addr)
addr
- is the flock address, range [1-6]public void fly()
public void setFlockSize(short size)
size
- is the number of birds in the flock.public void enableGroupMode()
private void sendStreamCommand()
private void stopStream()
public void sendAutoconfig()
private void changeAutoconfig()
public void sendSleepCommand()
public void beginCapture()
public void endCapture()
public boolean saveCaptureToFile(java.lang.String filename)
filename
- The file that the data will be written to.public void shutdown()
private java.lang.String getQuaternion(byte[] rec)
|
|||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |