Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaeyoung-Lim committed Jan 18, 2024
1 parent 1ad2df9 commit 97af8cc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
16 changes: 13 additions & 3 deletions include/grid_map_geo/grid_map_geo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct Location {

class GridMapGeo {
public:
GridMapGeo(const std::string frame_id = "map");
GridMapGeo(const std::string& frame_id = "map");
virtual ~GridMapGeo();

/**
Expand Down Expand Up @@ -91,6 +91,16 @@ class GridMapGeo {
*/
std::string getCoordinateName() { return coordinate_name_; };


/**
* @brief Overloading terrain loading with only elevation
*
* @param map_path Path to dsm path (Supported formats are *.tif)
*/
bool Load(const std::string& map_path) {
Load(map_path, "");
}

/**
* @brief Helper function for loading terrain from path
*
Expand All @@ -99,7 +109,7 @@ class GridMapGeo {
* @return true Successfully loaded terrain
* @return false Failed to load terrain
*/
bool Load(const std::string& map_path, const std::string color_map_path = "");
bool Load(const std::string& map_path, const std::string &color_map_path);

/**
* @brief Initialize grid map from a geotiff file
Expand Down Expand Up @@ -170,7 +180,7 @@ class GridMapGeo {
*/
void AddLayerNormals(std::string reference_layer);

geometry_msgs::msg::TransformStamped static_transformStamped;
geometry_msgs::msg::TransformStamped static_transformStamped_;

protected:
grid_map::GridMap grid_map_;
Expand Down
1 change: 0 additions & 1 deletion launch/load_multiple_tif_launch.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<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="first_tif_loader" output="screen">
Expand Down
4 changes: 2 additions & 2 deletions src/grid_map_geo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
#include <gdal/ogr_spatialref.h>
#endif

GridMapGeo::GridMapGeo(const std::string frame_id) { frame_id_ = frame_id; }
GridMapGeo::GridMapGeo(const std::string& frame_id) { frame_id_ = frame_id; }

GridMapGeo::~GridMapGeo() {}

bool GridMapGeo::Load(const std::string &map_path, const std::string color_map_path) {
bool GridMapGeo::Load(const std::string &map_path, const std::string &color_map_path) {
bool loaded = initializeFromGeotiff(map_path);
if (!color_map_path.empty()) { // Load color layer if the color path is nonempty
bool color_loaded = addColorFromGeotiff(color_map_path);
Expand Down
22 changes: 11 additions & 11 deletions src/test_tif_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ class MapPublisher : public rclcpp::Node {
Eigen::Vector3d map_origin;
map_->getGlobalOrigin(epsg, map_origin);

geometry_msgs::msg::TransformStamped static_transformStamped;
static_transformStamped.header.frame_id = map_->getCoordinateName();
static_transformStamped.child_frame_id = map_->getGridMap().getFrameId();
static_transformStamped.transform.translation.x = map_origin(0);
static_transformStamped.transform.translation.y = map_origin(1);
static_transformStamped.transform.translation.z = 0.0;
static_transformStamped.transform.rotation.x = 0.0;
static_transformStamped.transform.rotation.y = 0.0;
static_transformStamped.transform.rotation.z = 0.0;
static_transformStamped.transform.rotation.w = 1.0;
geometry_msgs::msg::TransformStamped static_transformStamped_;
static_transformStamped_.header.frame_id = map_->getCoordinateName();
static_transformStamped_.child_frame_id = map_->getGridMap().getFrameId();
static_transformStamped_.transform.translation.x = map_origin.x();
static_transformStamped_.transform.translation.y = map_origin.y();
static_transformStamped_.transform.translation.z = 0.0;
static_transformStamped_.transform.rotation.x = 0.0;
static_transformStamped_.transform.rotation.y = 0.0;
static_transformStamped_.transform.rotation.z = 0.0;
static_transformStamped_.transform.rotation.w = 1.0;

tf_broadcaster_->sendTransform(static_transformStamped);
tf_broadcaster_->sendTransform(static_transformStamped_);
}

private:
Expand Down

0 comments on commit 97af8cc

Please sign in to comment.