1
0
Fork 0
master
frederic wagner 2022-07-20 17:57:38 +02:00
parent dafca51365
commit b70bebdbac
5 changed files with 54 additions and 19 deletions

View File

@ -7,11 +7,16 @@
* We display remaining distance to next point. * We display remaining distance to next point.
0.06: 0.06:
* Special display for points with steep turns * Special display for points with steep turns.
* Buzz on points with steep turns and unlock * Buzz on points with steep turns and unlock.
* Losing gps is now displayed * Losing gps is now displayed.
0.07: 0.07:
* We now use orientation to detect current segment * We now use orientation to detect current segment
when segments overlap going in both directions. when segments overlap going in both directions.
* File format is now versioned. * File format is now versioned.
0.08:
* Don't use gps course anymore but figure it from previous positions.
* Bugfix: path colors are back.
* Always buzz when reaching waypoint even if unlocked.

View File

@ -1,10 +1,13 @@
- gps direction is weak when speed is low
- water points - water points
---> we group them following path by groups of cst_size and record segments ids marking limits ---> we group them following path by groups of cst_size and record segments ids marking limits
- turn off gps when moving to next waypoint - turn off gps when moving to next waypoint
- meters seem to be a bit too long
- buzzing does not work nicely
-> is_list seems fishy
- store several tracks - store several tracks
- display average speed - display average speed
- dynamic map rescale - dynamic map rescale

View File

@ -1,6 +1,6 @@
let simulated = false; let simulated = false;
let code_version = 7; let file_version = 1;
let code_key = 47490; let code_key = 47490;
class Status { class Status {
@ -46,12 +46,10 @@ class Status {
} }
// now check if we strayed away from path or back to it // now check if we strayed away from path or back to it
let lost = this.is_lost(next_segment); let lost = this.is_lost(next_segment);
if (this.on_path == lost) { if (this.on_path == lost) { // if status changes
if (lost) { if (lost) {
Bangle.buzz(); // we lost path Bangle.buzz(); // we lost path
setTimeout(()=>Bangle.buzz(), 300); setTimeout(()=>Bangle.buzz(), 500);
} else {
Bangle.buzz(); // we found path back
} }
this.on_path = !lost; this.on_path = !lost;
} }
@ -63,9 +61,10 @@ class Status {
this.distance_to_next_point = Math.ceil(this.position.distance(this.path.point(next_point))); this.distance_to_next_point = Math.ceil(this.position.distance(this.path.point(next_point)));
if (this.reaching != next_point && this.distance_to_next_point <= 20) { if (this.reaching != next_point && this.distance_to_next_point <= 20) {
this.reaching = next_point; this.reaching = next_point;
if (Bangle.isLocked()) { let reaching_waypoint = this.path.is_waypoint(next_point);
if (this.path.is_waypoint(next_point)) { if (reaching_waypoint) {
Bangle.buzz(); Bangle.buzz();
if (Bangle.isLocked()) {
Bangle.setLocked(false); Bangle.setLocked(false);
} }
} }
@ -113,8 +112,9 @@ class Status {
let sin = this.sin_direction; let sin = this.sin_direction;
// segments // segments
let current_segment = this.current_segment;
this.path.on_segments(function(p1, p2, i) { this.path.on_segments(function(p1, p2, i) {
if (i == this.current_segment + 1) { if (i == current_segment + 1) {
g.setColor(0.0, 1.0, 0.0); g.setColor(0.0, 1.0, 0.0);
} else { } else {
g.setColor(1.0, 0.0, 0.0); g.setColor(1.0, 0.0, 0.0);
@ -153,7 +153,7 @@ class Path {
let key = header[0]; let key = header[0];
let version = header[1]; let version = header[1];
let points_number = header[2]; let points_number = header[2];
if ((key != code_key)||(version>code_version)) { if ((key != code_key)||(version>file_version)) {
E.showMessage("Invalid gpc file"); E.showMessage("Invalid gpc file");
return; return;
} }
@ -305,13 +305,40 @@ let path = new Path("test.gpc");
let status = new Status(path); let status = new Status(path);
let frame = 0; let frame = 0;
let old_points = []; // remember the at most 3 previous points
function set_coordinates(data) { function set_coordinates(data) {
frame += 1; frame += 1;
let valid_coordinates = !isNaN(data.lat) && !isNaN(data.lon); let valid_coordinates = !isNaN(data.lat) && !isNaN(data.lon);
if (valid_coordinates) { if (valid_coordinates) {
// we try to figure out direction by looking at previous points
// instead of the gps course which is not very nice.
let direction = data.course * Math.PI / 180.0; let direction = data.course * Math.PI / 180.0;
let position = new Point(data.lon, data.lat); let position = new Point(data.lon, data.lat);
status.update_position(position, direction); if (old_points.length == 0) {
old_points.push(position);
} else {
let last_point = old_points[old_points.length-1];
if (last_point.x != position.x || last_point.y != position.y) {
if (old_points.length == 4) {
old_points.shift();
}
old_points.push(position);
}
}
if (old_points.length == 4) {
// let's just take average angle of 3 previous segments
let angles_sum = 0;
for(let i = 0 ; i < 3 ; i++) {
let p1 = old_points[i];
let p2 = old_points[i+1];
let diff = p2.minus(p1);
let angle = Math.atan2(diff.lat, diff.lon);
angles_sum += angle;
}
status.update_position(position, angles_sum / 3.0);
} else {
status.update_position(position, direction);
}
} }
let gps_status_color; let gps_status_color;
if ((frame % 2 == 0)||valid_coordinates) { if ((frame % 2 == 0)||valid_coordinates) {

View File

@ -11,7 +11,7 @@ mod osm;
use osm::InterestPoint; use osm::InterestPoint;
const KEY: u16 = 47490; const KEY: u16 = 47490;
const VERSION: u16 = 7; const FILE_VERSION: u16 = 1;
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Clone, Copy)]
pub struct Point { pub struct Point {
@ -332,7 +332,7 @@ fn save_coordinates<P: AsRef<Path>>(path: P, points: &[Point]) -> std::io::Resul
eprintln!("saving {} points", points.len()); eprintln!("saving {} points", points.len());
writer.write_all(&KEY.to_le_bytes())?; writer.write_all(&KEY.to_le_bytes())?;
writer.write_all(&VERSION.to_le_bytes())?; writer.write_all(&FILE_VERSION.to_le_bytes())?;
writer.write_all(&(points.len() as u16).to_le_bytes())?; writer.write_all(&(points.len() as u16).to_le_bytes())?;
points points
.iter() .iter()

View File

@ -2,7 +2,7 @@
"id": "gipy", "id": "gipy",
"name": "Gipy", "name": "Gipy",
"shortName": "Gipy", "shortName": "Gipy",
"version": "0.07", "version": "0.08",
"description": "Follow gpx files", "description": "Follow gpx files",
"allow_emulator":false, "allow_emulator":false,
"icon": "gipy.png", "icon": "gipy.png",