-
Notifications
You must be signed in to change notification settings - Fork 20
Support large vrt from ArduPilot SRTM1 terrain server #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ros2
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
map_publisher: | ||
ros__parameters: | ||
gdal_dataset_path: /vsizip/vsicurl/https://terrain.ardupilot.org/SRTM1/N09E047.hgt.zip/N09E047.hgt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does the I tried to directly query the terrain server with gdalinfo, but didn't work:
|
||
gdal_dataset_color_path: "resources/sargans_color.tif" | ||
max_map_width: 3601 | ||
max_map_height: 3601 | ||
map_origin_latitude: 47.033333 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would we want to declare this not from the file but externally? Is this maybe because the map alignment was not correct before #36 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I needed to declare it somewhere and wanted to provide a reasonable default. Another approach would be to have them as launch arguments. Once we add capability to dynamically load based on UAV location, then this can be removed. |
||
map_origin_longitude: 9.433333 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,9 +35,18 @@ | |
#define GRID_MAP_GEO_TRANSFORM_H | ||
|
||
#include <Eigen/Dense> | ||
#include <array> | ||
#include <cassert> | ||
|
||
enum class ESPG { ECEF = 4978, WGS84 = 4326, WGS84_32N = 32632, CH1903_LV03 = 21781 }; | ||
|
||
struct Location { | ||
ESPG espg{ESPG::WGS84}; | ||
// <east (lat), north (lng), up (alt)> | ||
//! @todo Switch to geographic_msgs/GeoPoint to make x-y not confusing? | ||
Eigen::Vector3d position{Eigen::Vector3d::Zero()}; | ||
}; | ||
|
||
/** | ||
* @brief Helper function for transforming using gdal | ||
* | ||
|
@@ -58,4 +67,53 @@ Eigen::Vector3d transformCoordinates(ESPG src_coord, ESPG tgt_coord, const Eigen | |
*/ | ||
Eigen::Vector3d transformCoordinates(ESPG src_coord, const std::string wkt, const Eigen::Vector3d source_coordinates); | ||
|
||
#endif // GRID_MAP_GEO_TRANSFORM_H | ||
struct Corners { | ||
ESPG espg{ESPG::WGS84}; | ||
Eigen::Vector2d top_left{Eigen::Vector2d::Zero()}; | ||
Eigen::Vector2d top_right{Eigen::Vector2d::Zero()}; | ||
Eigen::Vector2d bottom_left{Eigen::Vector2d::Zero()}; | ||
Eigen::Vector2d bottom_right{Eigen::Vector2d::Zero()}; | ||
}; | ||
|
||
/** | ||
* @brief Helper function converting from image to geo coordinates | ||
* | ||
* @ref | ||
https://gdal.org/tutorials/geotransforms_tut.html#transformation-from-image-coordinate-space-to-georeferenced-coordinate-space | ||
* @see GDALApplyGeoTransform | ||
* | ||
* @param geoTransform The 6-element Geo transform | ||
* @param imageCoords The image-coordinates <row, column>, also called <pixel, line> | ||
|
||
* @return The geo-coordinates in <x, y> | ||
*/ | ||
inline Eigen::Vector2d imageToGeo(const std::array<double, 6> geoTransform, const Eigen::Vector2i imageCoords) { | ||
const auto x_pixel = imageCoords.x(); | ||
const auto y_line = imageCoords.y(); | ||
|
||
return {geoTransform.at(0) + x_pixel * geoTransform.at(1) + y_line * geoTransform.at(2), | ||
geoTransform.at(3) + x_pixel * geoTransform.at(4) + y_line * geoTransform.at(5)}; | ||
} | ||
|
||
/** | ||
* @brief Helper function converting from geo to image coordinates. Assumes no rotation. | ||
* Uses the assumption that GT2 and GT4 are zero | ||
* | ||
* @ref | ||
* https://gis.stackexchange.com/questions/384221/calculating-inverse-polynomial-transforms-for-pixel-sampling-when-map-georeferen | ||
* @see GDALApplyGeoTransform | ||
* | ||
* @param geoTransform The 6-element forward Geo transform | ||
* @param geoCoords The geo-coordinates in <x, y> | ||
* | ||
* @return The image-coordinates in <row, column>, also called <pixel, line> | ||
*/ | ||
inline Eigen::Vector2d geoToImageNoRot(const std::array<double, 6>& geoTransform, const Eigen::Vector2d geoCoords) { | ||
assert(geoTransform.at(2) == 0); // assume no rotation | ||
assert(geoTransform.at(4) == 0); // assume no rotation | ||
|
||
return {(geoCoords.x() - geoTransform.at(0)) / geoTransform.at(1), | ||
(geoCoords.y() - geoTransform.at(3)) / geoTransform.at(5)}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure whether we want to be able to freely choose geoCoords within the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is currently used when a user loads a large VRT, and wants to set the map origin in geo coordinates. Could you give me a little more detail on how one can set the map origin using TF? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The map is always placed at (0, 0, 0) and the tf specifies how that frame_id is placed in the datum (e.g. CH1903). This way the map is aligned automatically through tfs, and we don't need to worry where the rviz is looking at. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are dynamically setting the map from the launch file, and eventually loading tiles dynamically, will (0, 0, 0) be where the first map was loaded? |
||
} | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<launch> | ||
<arg name="rviz" default="true"/> | ||
<arg name="location" default="sargans"/> | ||
<node pkg="tf2_ros" exec="static_transform_publisher" name="world_map" args="--frame-id world --child-frame-id map"/> | ||
|
||
<node pkg="grid_map_geo" exec="map_publisher" name="map_publisher" namespace="grid_map_geo" output="screen"> | ||
<param name="gdal_dataset_path" value="$(find-pkg-share grid_map_geo)/resources/sargans.tif"/> | ||
<param name="gdal_dataset_color_path" value="$(find-pkg-share grid_map_geo)/resources/sargans_color.tif"/> | ||
|
||
<!-- These values match sargans.tif, but could be increased with no effect on sargans --> | ||
<param name="max_map_width" value="748"/> | ||
<param name="max_map_height" value="1220"/> | ||
</node> | ||
|
||
<group if="$(var rviz)"> | ||
<node pkg="rviz2" exec="rviz2" name="rviz2" args="-d $(find-pkg-share grid_map_geo)/rviz/config.rviz"/> | ||
</group> | ||
</launch> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<launch> | ||
<arg name="rviz" default="true"/> | ||
<arg name="location" default="sargans"/> | ||
<node pkg="tf2_ros" exec="static_transform_publisher" name="world_map" args="--frame-id world --child-frame-id map"/> | ||
|
||
<node pkg="grid_map_geo" exec="test_tif_loader" name="test_tif_loader" namespace="grid_map_geo" output="screen"> | ||
<param name="tif_path" value="$(find-pkg-share grid_map_geo)/resources/sargans.tif"/> | ||
<param name="tif_color_path" value="$(find-pkg-share grid_map_geo)/resources/sargans_color.tif"/> | ||
</node> | ||
|
||
<group if="$(var rviz)"> | ||
<node pkg="rviz2" exec="rviz2" name="rviz2" args="-d $(find-pkg-share grid_map_geo)/rviz/config.rviz"/> | ||
</group> | ||
</launch> |
Uh oh!
There was an error while loading. Please reload this page.