-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Needs a node instance to get the time * Move rviz config to the rviz directory * Use new grid map shared pointer API for converting to ROS messages * Install new node in the ament index Signed-off-by: Ryan Friedman <[email protected]>
- Loading branch information
Showing
7 changed files
with
39 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,12 +37,13 @@ | |
* @author Jaeyoung Lim <[email protected]> | ||
*/ | ||
|
||
#include <grid_map_geo/grid_map_geo.h> | ||
#include <grid_map_msgs/GridMap.h> | ||
#include <ros/ros.h> | ||
#include <grid_map_geo/grid_map_geo.hpp> | ||
#include <grid_map_msgs/msg/grid_map.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
#include <grid_map_ros/GridMapRosConverter.hpp> | ||
|
||
#include <gdal/ogr_spatialref.h> | ||
#include <gdal/ogr_geometry.h> | ||
|
||
constexpr int ESPG_WGS84 = 4326; | ||
constexpr int ESPG_CH1903_LV03 = 21781; | ||
|
@@ -67,7 +68,8 @@ void transformCoordinates(int src_coord, const double &x, const double &y, const | |
} | ||
|
||
void LoadTerrainFromVrt(std::string path, const Eigen::Vector3d &query_position, const Eigen::Vector2d &offset, | ||
grid_map::GridMap &map, grid_map::GridMap &vrt_map_object) { | ||
grid_map::GridMap &map, grid_map::GridMap &vrt_map_object, | ||
rclcpp::Node::SharedPtr node_ptr) { | ||
std::shared_ptr<GridMapGeo> vrt_map = std::make_shared<GridMapGeo>(); | ||
|
||
Eigen::Vector3d query_position_lv03 = query_position; | ||
|
@@ -80,7 +82,7 @@ void LoadTerrainFromVrt(std::string path, const Eigen::Vector3d &query_position, | |
std::cout << " - map_center_wgs84:" << map_center_wgs84.transpose() << std::endl; | ||
/// TODO: Discover extent from corners | ||
Eigen::Vector2d extent_wgs84(0.5, 0.5); | ||
vrt_map->initializeFromVrt(path, map_center_wgs84.head(2), extent_wgs84); | ||
vrt_map->initializeFromVrt(path, map_center_wgs84.head(2), extent_wgs84, node_ptr); | ||
std::cout << " - Success!" << std::endl; | ||
|
||
/// TODO: Loaded VRT map | ||
|
@@ -115,15 +117,16 @@ void LoadTerrainFromVrt(std::string path, const Eigen::Vector3d &query_position, | |
} | ||
|
||
int main(int argc, char **argv) { | ||
ros::init(argc, argv, "terrain_loader"); | ||
ros::NodeHandle nh(""); | ||
ros::NodeHandle nh_private("~"); | ||
rclcpp::init(argc, argv); | ||
// ros::init(argc, argv, "terrain_loader"); | ||
auto node = rclcpp::Node::make_shared("terrain_loader"); | ||
// ros::NodeHandle nh(""); | ||
// ros::NodeHandle nh_private("~"); | ||
|
||
ros::Publisher map_pub = nh.advertise<grid_map_msgs::GridMap>("grid_map", 1, true); | ||
ros::Publisher map_pub2 = nh.advertise<grid_map_msgs::GridMap>("grid_map2", 1, true); | ||
auto map_pub = node->create_publisher<grid_map_msgs::msg::GridMap>("grid_map", rclcpp::QoS(1).transient_local()); | ||
auto map_pub2 = node->create_publisher<grid_map_msgs::msg::GridMap>("grid_map2", rclcpp::QoS(1).transient_local()); | ||
|
||
std::string path; | ||
nh_private.param<std::string>("terrain_path", path, "resources/cadastre.tif"); | ||
auto const path = node->declare_parameter("terrain_path", "resources/cadastre.tif"); | ||
|
||
Eigen::Vector3d test_position = Eigen::Vector3d(783199.15, 187585.10, 0.0); | ||
|
||
|
@@ -133,18 +136,22 @@ int main(int argc, char **argv) { | |
|
||
grid_map::GridMap map; | ||
grid_map::GridMap vrt_map; | ||
LoadTerrainFromVrt(path, query_position, offset.head(2), map, vrt_map); | ||
LoadTerrainFromVrt(path, query_position, offset.head(2), map, vrt_map, node); | ||
std::cout << "i: " << i << " offset: " << offset.transpose() << std::endl; | ||
|
||
grid_map_msgs::GridMap msg; | ||
grid_map::GridMapRosConverter::toMessage(map, msg); | ||
map_pub.publish(msg); | ||
// grid_map_msgs::msg::GridMap msg; | ||
auto msg = grid_map::GridMapRosConverter::toMessage(map); | ||
if(msg) { | ||
map_pub->publish(std::move(msg)); | ||
} | ||
|
||
grid_map_msgs::GridMap msg2; | ||
grid_map::GridMapRosConverter::toMessage(vrt_map, msg2); | ||
map_pub2.publish(msg2); | ||
auto msg2 = grid_map::GridMapRosConverter::toMessage(vrt_map); | ||
if (msg2) { | ||
map_pub2->publish(std::move(msg2)); | ||
} | ||
} | ||
|
||
ros::spin(); | ||
rclcpp::spin(node); | ||
rclcpp::shutdown(); | ||
return 0; | ||
} |