Fixed an issue where boats sometimes sailed towards the wind when attempting to turn from bearing just under 360 degrees to a bearing just over 360 degrees.
This required an update to the boundary detection code.
Visualiser:
Appear to have fixed issue where clock didn't display correctly. Previous commit only fixed certain circumstances.
#story[873]
Added comments/documentation to most classes.
Cleaned up heaps of repeated code, dead code, redundant stuff, etc...
Mock.App:
Now actually exits the program if catastrophic errors occur, rather than silently doing nothing.
Mock.Constants:
Added race prestart and preparatory times.
Removed TEST_VELOCITIES.
Mock.PolarParser:
Now uses Bearing class.
Mock.Angle:
Now implements the Comparable interface.
Also supports .equals.
Mock.Azimuth and Bearing:
Can convert between them easily.
Mock.Boat:
Now uses Bearing, and has some helper functions like setVMG, calculateMetersTravelled(time), moveforwards(distance, time).
Mock.Marker:
Removed. This wasn't really used, and was redundant.
Mock.GPSCoordinate:
Moved a lot of helper GPS related functions into the GPSCoordinate class, instead of being scattered around the codebase.
Mock.Polars:
Polars now uses Bearing.
Mock.VMG:
Now uses Bearing.
Mock.Race:
Added a RaceStatusEnum member.
Added a RaceTypeEnum member.
Now uses Bearing/Azimuth.
Moved the message creation/sending into their own functions.
The RaceStatus updates correctly through out the race (Prestart, Warning, Preparatory, Started, Finished).
Network.RaceStatusEnum:
Added race status enum.
Network.RaceTypeEnum:
Added.
Fixed an issue in updatePositions(...) where unconstrained bounds could be passed into the calculateVMG function (e.g., lower = -182391, upper = 188221), but they need to be in the interval [0, 360).
Mock.Polars:
Added more test cases. Still working on getting the assertions correct.
Refactored and bugfixed the calculateVMG(...) function. There were a few bugs (and ugly "fixes") because we didn't bother enforcing a strict interval on the lower and upper bound angles.
Also added a few more comments to explain the function better.
#story[873]
- Error where mock would not read in the files when running from the jar.
- Error where the AC35 stream now no longer sends us packets with information that is set for 0 for boat location.
#story[881] #pair[fwy13, esa46
An alternate tacking implementation during race simulate. Doesn't handle keeping the boats in-bounds, and sometimes has issues with landing directly on a mark.
Also seems to use wrong starting velocities (from the XML file).
#story[873]
Fixed a bug where calculateVMG was placing velocity into the VMG object, instead of speed.
Maybe fixed a bug when a bearingLowerBound which is greater than bearingUpperBound is provided.
Added another test case.
Mock.Constants:
Added knots to millimeters per second conversion factor.
Mock.Boat:
Added calculateDIstanceToNextMarker function, which returns the distance, in nautical miles, to the next mark.
Mock.Race:
Added wind direction as a race property.
Added wind speed as a race property.
The race status messages sent by Race now use Race's wind speed and direction.
#story[873]
made speed and bearing members private - had accidentally forget the visibility specifier.
Mock.Polars:
Added linear interpolation between speed values (e.g., if the wind speed is 15.9kn, it will interpolate between the 12kn and 16kn data). This allows for wind speeds less than 4kn (the lowest wind speed in the data file). It does not extrapolate anything for wind speeds larger than 30kn (the largest wind speed in the data file).
Also refactored some of the code into some interpolation functions.
#story[873]
Fixed a bug where duplicate estimates could be added to the Polar table (this happened when the angle was 0, so the "negative" angle became 360, which is equivalent).
Now has a list of angle values for each wind speed, rather than checking if Pair<WindSpeed, WindAngle> exists in the map.
calculateVMG now uses linear interpolation between two adjacent angles (e.g., if data file contains angles 0, 30, 45, etc.. it can interpolate and find an optimal VMG angle between those, for example, 17 degrees).
Added a third test for when we provide a wind speed which is lower than any wind speed values in the Polars table. Still need to actually calculate correct VMG values by hand.
#story[873]
Mock.Polars. addEstimate also builds up a unique list of angles from the data file, instead of dynamically generating that when calculating a VMG.
addEstimate also adds estimates with negative angles (e.g., 45deg+windSpeed+boatSpeed, and -45deg+windSpeed+boatSpeed).
calculateVMG now accepts an upper and lower bounds to the allowed VMG bearing it returns - this way you can get VMGs only within a certain angle interval (e.g., [16, 99] degrees).
Also fixed some bugs in calculateVMG where it wasn't actually using the angles and such correctly.
Improved the test case slightly, but still need to calculate correct values by hand.
#story[873]
-race class now stores the boundary
-updatePositions now checks if the boat is with the course
-update positions now sets heading and speed based on the vmg
-updated azimuth to now accept a start and finish gps rather that finding it itself
-added a calculatebearingtodestination method that finds the azimuth to the dest from the boat
-updated boat tests to use the new azimuth method
#story[873]
- The issue was with accuracy. Average of two coords is fine fo two point fairly close together (<1km), but not for very very large distances.
- We only ever use it for small ranges so changed tests to reflect that
#story[881]
Added the Polars.calculateVMG function, which calculates the VMG from a given wind angle, wind speed, and angle to destination. In may not be completely correct at the moment, so it's a work in progress.
#story[873]
Fixed a bug where the polar parser would attempt to insert (wind speed, windspeed, windangle) instead of (windspeed, windangle, boatspeed).
Removed some unused constructors from RaceXMLReader, and fixed a bug where it wouldn't actually use the polar table correctly.
Boat's constructor now expects a Polars table.
Added some comments to the Polars class, and specified the HashMap's template parameters
Added PolarsTest - which needs to be implemented properly when the VMG calculations have been added.
#story[900]
- Mock.StreamedCourseXMLReader populates participant and mark list from BoatDataSource
- Added CompoundMarker class to accommodate Mark data from Boat XML
- Had to check for Yacht type in Visualiser.BoatXMLReader
- Added a missing coordinate value to raceTest.xml
- Marker class still exists due to large number of tests, which should be transitioned to CompoundMark
- IMPORTANT: race is no longer functional
#story[881]
Network:
Moved the Network message classes from the Utils package to the Messages package.
Renamed BoatLocationMessage to BoatLocation and BoatStatusMessage to BoatStatus to be consistent with other message classes.
Renamed the BoatStatus enumeration to BoatStatusEnum as it conflicted with BoatStatus (the message).
Moved the BoatStatusEnum and MessageType enumerations from the Utils package to the Messages/Enums package.
Changed the BoatStatusEnum and MessageType enumerations to use map look ups in the enum.fromByte(b) method - this means that there's less copy and pasted values, and the fromByte function doesn't need to be modified if new enumerations are added.
Added a sequenceNumber member to the Heartbeat class.
Added an InvalidMessageException in the package Networking/Exceptions. This is thrown when a message is read, but it is invalid in some way.
Refactored/tidied up the Networking/BinaryMessageEncoder and Decoder classes. The decoder throws InvalidMessageExceptions instead of returning null.
Visualiser:
VisualiserInput now wraps a DataInputStream around the socket. This provides the stream.readFully(buffer) function, which is a blocking read, removing the need for busy wait loops. Replaced the getBytes() function with getNextMessage() and getNextMessageBytes(). These read the next message from the socket, and return it as a message object and a byte array, respectively.
Changed the current heartbeat timeout to 10 seconds. Added some work-in-progress code to attempt to reconnect when connection is lost. It currently doesn't work. I think Fan-Wu was doing a proper implementation, however.
VisualiserInput also has a queue of received events. Currently not really used, but could be useful in the future. Events get added as they are read.
Changed VisualiserInputs main loop to use instanceOf instead of switch+case. Feedback wanted - are there any downsides to using this instanceOf method?
#story[778,782]