gps_simulate_start(Gps *gps)
{
g_assert(gps);
-gps->data.lat=60.45;
-gps->data.lon=22.26;
+if (_home.valid) {
+ gps->data.lat=_home.lat;
+ gps->data.lon=_home.lon;
+} else {
+ gps->data.lat=60.45;
+ gps->data.lon=22.26;
+}
+
gps->io.conn=RCVR_FIXED;
gps->data.fix=FIX_2D;
gps->data.satinview=0;
gps_simulate_move(Gps *gps)
{
static gdouble slat=0, slon=0;
-gdouble plat, plon;
+gdouble plat, plon, accel;
gfloat h;
g_assert(gps);
-if (g_random_double()<0.2) {
- slat=g_random_double_range(-0.0009, 0.0009);
- slon=g_random_double_range(-0.0009, 0.0009);
+if (_dest.valid) {
+ _dest.angle=calculate_course(_dest.lat,_dest.lon, gps->data.lat, gps->data.lon);
+
+ accel=0.005*g_random_double();
+ slat=accel*cos(_dest.angle);
+ slon=accel*sin(_dest.angle);
+ g_debug("Sim: %f %f %f %f", slat, slon, accel, _dest.angle);
+} else {
+ if (g_random_double()<0.2) {
+ slat=g_random_double_range(-0.0009, 0.0009);
+ slon=g_random_double_range(-0.0009, 0.0009);
+ }
}
plat=gps->data.lat;
plon=gps->data.lon;
gps->data.lat+=slat;
gps->data.lon+=slon;
+
BOUND(gps->data.lat, -80.0, 80.0);
BOUND(gps->data.lon, -80.0, 80.0);
g_debug("Sim: %f %f", gps->data.lat, gps->data.lon);
-gps->data.speed=1+g_random_double_range(0.1, 10.0);
+gps->data.speed=0;
+
h=calculate_course(plat, plon, gps->data.lat, gps->data.lon);
gps->data.heading=(h<0) ? 360+h : h;
gps->data.time=time(NULL);