mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-08 17:08:28 -04:00
AP_Common: Location: add offset(Vector3p &ned_offset)
This commit is contained in:
parent
6e1e1f6596
commit
a9c62fa565
@ -306,6 +306,14 @@ void Location::offset(ftype ofs_north, ftype ofs_east)
|
|||||||
offset_latlng(lat, lng, ofs_north, ofs_east);
|
offset_latlng(lat, lng, ofs_north, ofs_east);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// extrapolate latitude/longitude given distances (in meters) north
|
||||||
|
// and east. Note that this is metres, *even for the altitude*.
|
||||||
|
void Location::offset(const Vector3p &ofs_ned)
|
||||||
|
{
|
||||||
|
offset_latlng(lat, lng, ofs_ned.x, ofs_ned.y);
|
||||||
|
alt += -ofs_ned.z * 100; // m -> cm
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* extrapolate latitude/longitude given bearing and distance
|
* extrapolate latitude/longitude given bearing and distance
|
||||||
* Note that this function is accurate to about 1mm at a distance of
|
* Note that this function is accurate to about 1mm at a distance of
|
||||||
|
@ -79,6 +79,9 @@ public:
|
|||||||
// extrapolate latitude/longitude given distances (in meters) north and east
|
// extrapolate latitude/longitude given distances (in meters) north and east
|
||||||
static void offset_latlng(int32_t &lat, int32_t &lng, ftype ofs_north, ftype ofs_east);
|
static void offset_latlng(int32_t &lat, int32_t &lng, ftype ofs_north, ftype ofs_east);
|
||||||
void offset(ftype ofs_north, ftype ofs_east);
|
void offset(ftype ofs_north, ftype ofs_east);
|
||||||
|
// extrapolate latitude/longitude given distances (in meters) north
|
||||||
|
// and east. Note that this is metres, *even for the altitude*.
|
||||||
|
void offset(const Vector3p &ofs_ned);
|
||||||
|
|
||||||
// extrapolate latitude/longitude given bearing and distance
|
// extrapolate latitude/longitude given bearing and distance
|
||||||
void offset_bearing(ftype bearing_deg, ftype distance);
|
void offset_bearing(ftype bearing_deg, ftype distance);
|
||||||
|
@ -113,6 +113,19 @@ TEST(Location, LocOffsetDouble)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Location, LocOffset3DDouble)
|
||||||
|
{
|
||||||
|
Location loc {
|
||||||
|
-353632620, 1491652373, 60000, Location::AltFrame::ABSOLUTE
|
||||||
|
};
|
||||||
|
// this is ned, so our latitude should change, and our new
|
||||||
|
// location should be above the original:
|
||||||
|
loc.offset(Vector3d{1000, 0, -10});
|
||||||
|
EXPECT_EQ(loc.lat, -353542788);
|
||||||
|
EXPECT_EQ(loc.lng, 1491652373);
|
||||||
|
EXPECT_EQ(loc.alt, 61000);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(Location, Tests)
|
TEST(Location, Tests)
|
||||||
{
|
{
|
||||||
Location test_location;
|
Location test_location;
|
||||||
|
Loading…
Reference in New Issue
Block a user