23 #include <Eigen/Eigen>
24 #include <rclcpp/rclcpp.hpp>
25 #include <px4_msgs/msg/vehicle_local_position.hpp>
26 #include <px4_ros2/common/context.hpp>
34 class MapProjectionImpl;
65 Eigen::Vector2f
globalToLocal(
const Eigen::Vector2d & global_position)
const;
74 Eigen::Vector3f
globalToLocal(
const Eigen::Vector3d & global_position)
const;
83 Eigen::Vector2d
localToGlobal(
const Eigen::Vector2f & local_position)
const;
92 Eigen::Vector3d
localToGlobal(
const Eigen::Vector3f & local_position)
const;
98 void assertInitalized()
const;
105 void vehicleLocalPositionCallback(px4_msgs::msg::VehicleLocalPosition::UniquePtr msg);
107 rclcpp::Node & _node;
108 std::unique_ptr<MapProjectionImpl> _map_projection_math;
109 rclcpp::Subscription<px4_msgs::msg::VehicleLocalPosition>::SharedPtr _vehicle_local_position_sub;
122 const Eigen::Vector2d & global_position_now,
123 const Eigen::Vector2d & global_position_next);
135 const Eigen::Vector3d & global_position_now,
136 const Eigen::Vector3d & global_position_next)
139 static_cast<Eigen::Vector2d
>(global_position_now.head(2)),
140 static_cast<Eigen::Vector2d
>(global_position_next.head(2)));
153 const Eigen::Vector3d & global_position_now,
154 const Eigen::Vector3d & global_position_next);
166 const Eigen::Vector2d & global_position_now,
167 const Eigen::Vector2d & global_position_next);
179 const Eigen::Vector3d & global_position_now,
180 const Eigen::Vector3d & global_position_next)
183 static_cast<Eigen::Vector2d
>(global_position_now.head(2)),
184 static_cast<Eigen::Vector2d
>(global_position_next.head(2)));
197 const Eigen::Vector2d & global_position_now,
198 const Eigen::Vector2d & global_position_next);
210 const Eigen::Vector3d & global_position_now,
211 const Eigen::Vector3d & global_position_next)
213 const Eigen::Vector2f vector_res =
215 static_cast<Eigen::Vector2d
>(global_position_now.head(2)),
216 static_cast<Eigen::Vector2d
>(global_position_next.head(2)));
217 const double d_alt = -(global_position_next.z() - global_position_now.z());
218 return Eigen::Vector3f {vector_res.x(), vector_res.y(),
static_cast<float>(d_alt)};
232 const Eigen::Vector2d & global_position_line_start,
233 const Eigen::Vector2d & global_position_line_end,
234 float dist_from_start);
248 const Eigen::Vector2d & global_position_now,
249 float heading,
float dist);
263 const Eigen::Vector3d & global_position_now,
264 float heading,
float dist)
267 static_cast<Eigen::Vector2d
>(global_position_now.head(2)), heading, dist);
268 return Eigen::Vector3d {
269 global_position_res.x(),
270 global_position_res.y(),
271 global_position_now.z()};
284 const Eigen::Vector2d & global_position,
285 const Eigen::Vector2f & vector_ne);
297 const Eigen::Vector3d & global_position,
298 const Eigen::Vector3f & vector_ned)
301 static_cast<Eigen::Vector2d
>(global_position.head(2)),
302 static_cast<Eigen::Vector2f
>(vector_ned.head(2)));
303 const double d_alt = -vector_ned.z();
304 return Eigen::Vector3d {global_position_res.x(), global_position_res.y(),
305 global_position.z() + d_alt};
Definition: context.hpp:20
Provides methods to convert between the geographical coordinate system ("global") and the local azimu...
Definition: geodesic.hpp:47
bool isInitialized() const
Eigen::Vector2f globalToLocal(const Eigen::Vector2d &global_position) const
Transform a point in the geographic coordinate system to the local azimuthal equidistant plane using ...
Eigen::Vector2d localToGlobal(const Eigen::Vector2f &local_position) const
Transform a point in the local azimuthal equidistant plane to the geographic coordinate system using ...
Eigen::Vector3d localToGlobal(const Eigen::Vector3f &local_position) const
Transform a point in the local azimuthal equidistant plane to the geographic coordinate system using ...
Eigen::Vector3f globalToLocal(const Eigen::Vector3d &global_position) const
Transform a point in the geographic coordinate system to the local azimuthal equidistant plane using ...
static float horizontalDistanceToGlobalPosition(const Eigen::Vector3d &global_position_now, const Eigen::Vector3d &global_position_next)
Compute the horizontal distance between two global positions in meters.
Definition: geodesic.hpp:134
static Eigen::Vector3d globalPositionFromHeadingAndDist(const Eigen::Vector3d &global_position_now, float heading, float dist)
Compute the global position given another global position, distance and heading see http://www....
Definition: geodesic.hpp:262
static float headingToGlobalPosition(const Eigen::Vector3d &global_position_now, const Eigen::Vector3d &global_position_next)
Compute the heading to the next global position in radians.
Definition: geodesic.hpp:178
static Eigen::Vector3d addVectorToGlobalPosition(const Eigen::Vector3d &global_position, const Eigen::Vector3f &vector_ned)
Compute the global position from adding a local frame vector to the current global position.
Definition: geodesic.hpp:296
static Eigen::Vector3f vectorToGlobalPosition(const Eigen::Vector3d &global_position_now, const Eigen::Vector3d &global_position_next)
Compute the vector to the next global position in meters.
Definition: geodesic.hpp:209
float distanceToGlobalPosition(const Eigen::Vector3d &global_position_now, const Eigen::Vector3d &global_position_next)
Compute the distance between two global positions in meters.
Eigen::Vector2d globalPositionFromLineAndDist(const Eigen::Vector2d &global_position_line_start, const Eigen::Vector2d &global_position_line_end, float dist_from_start)
Compute the global position on the line vector defined by two positions (start -> end) at a certain d...