Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Clang Robot committed Aug 17, 2024
1 parent 883f88d commit b65b35a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ class GridManager {
~GridManager() = default;

/**
* @brief Update the grid with a polygon and a value to update corresponding cells with.
* @brief Update the grid with a polygon and a value to update corresponding
* cells with.
*/
void update_grid(int8_t *grid,
const Eigen::Array<float, 2, Eigen::Dynamic> &vertices,
int value);

/**
* @brief Draw a line on the grid and update the value of the cells it passes through.
* @brief Draw a line on the grid and update the value of the cells it passes
* through.
*/
void draw_line(int x0, int y0, int x1, int y1, int8_t *grid, int value);

/**
* @brief Fill a polygon on the grid and update the value of the cells it covers.
* @brief Fill a polygon on the grid and update the value of the cells it
* covers.
*/
void fill_polygon(int8_t *grid,
const Eigen::Array<float, 2, Eigen::Dynamic> &polygon,
Expand Down
2 changes: 1 addition & 1 deletion mission/landmark_server/src/grid_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void GridManager::fill_polygon(
for (int y = min_y; y < max_y; y++) {
if (x >= 0 && x < static_cast<int>(width_) && y >= 0 &&
y < static_cast<int>(height_) && point_in_polygon(x, y, polygon)) {
grid[y * width_ + x] += value;
grid[y * width_ + x] += value;
}
}
}
Expand Down
18 changes: 10 additions & 8 deletions mission/map_manager/include/map_manager/map_manager_ros.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef MAP_MANAGER_HPP
#define MAP_MANAGER_HPP

#include "geometry_msgs/msg/transform_stamped.hpp"
#include "nav_msgs/srv/get_map.hpp"
#include <geometry_msgs/msg/polygon_stamped.hpp>
#include <nav_msgs/msg/occupancy_grid.hpp>
#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/nav_sat_fix.hpp>
#include "geometry_msgs/msg/transform_stamped.hpp"
#include <tf2_ros/static_transform_broadcaster.h>

#include <pcl/PointIndices.h>
Expand Down Expand Up @@ -47,13 +47,15 @@ class MapManagerNode : public rclcpp::Node {
constexpr double deg2rad(double degrees) const;
std::array<double, 2> lla2flat(double lat, double lon) const;
std::array<double, 2> flat2lla(double px, double py) const;
/**
* @brief Publishes static transform from world NED to world SEU to use for foxglove visualization.
*
*/
void publish_foxglove_vis_frame(const rclcpp::Time& time) const;
/**
* @brief Publishes static transform from world NED to world SEU to use for
* foxglove visualization.
*
*/
void publish_foxglove_vis_frame(const rclcpp::Time &time) const;

void publish_map_to_odom_tf(double map_lat, double map_lon, const rclcpp::Time& time) const;
void publish_map_to_odom_tf(double map_lat, double map_lon,
const rclcpp::Time &time) const;

geometry_msgs::msg::PolygonStamped
processCoordinates(const std::vector<std::array<double, 2>> &coordinates);
Expand All @@ -76,7 +78,7 @@ class MapManagerNode : public rclcpp::Node {
rclcpp::Publisher<geometry_msgs::msg::PolygonStamped>::SharedPtr
landmask_pub_;
rclcpp::Service<nav_msgs::srv::GetMap>::SharedPtr grid_service_;
rclcpp::Publisher<sensor_msgs::msg::NavSatFix>::SharedPtr map_origin_pub_;
rclcpp::Publisher<sensor_msgs::msg::NavSatFix>::SharedPtr map_origin_pub_;
bool map_origin_set_ = false;
bool use_predef_landmask_;
double map_origin_lat_;
Expand Down
84 changes: 41 additions & 43 deletions mission/map_manager/src/map_manager_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ MapManagerNode::MapManagerNode(const rclcpp::NodeOptions &options)
map_pub_ = this->create_publisher<nav_msgs::msg::OccupancyGrid>(
"map", qos_transient_local);

map_origin_pub_ = this->create_publisher<sensor_msgs::msg::NavSatFix>("/map/origin", qos_transient_local);

map_origin_pub_ = this->create_publisher<sensor_msgs::msg::NavSatFix>(
"/map/origin", qos_transient_local);

if (this->get_parameter("use_predef_map_origin").as_bool()) {
map_origin_lat_ = this->get_parameter("map_origin_lat").as_double();
Expand Down Expand Up @@ -140,53 +140,51 @@ std::array<double, 2> MapManagerNode::lla2flat(double lat, double lon) const {
return {px, py};
}

void MapManagerNode::publish_map_to_odom_tf(double map_lat, double map_lon, const rclcpp::Time& time) const
{
// Setup the transform
geometry_msgs::msg::TransformStamped transformStamped;

transformStamped.header.stamp = time;
transformStamped.header.frame_id = "map";
transformStamped.child_frame_id = "odom";

auto [x, y] = lla2flat(map_lat, map_lon);

transformStamped.transform.translation.x = -x;
transformStamped.transform.translation.y = -y;
transformStamped.transform.translation.z = 0;

transformStamped.transform.rotation.x = 0.0;
transformStamped.transform.rotation.y = 0.0;
transformStamped.transform.rotation.z = 0.0;
transformStamped.transform.rotation.w = 1.0;
void MapManagerNode::publish_map_to_odom_tf(double map_lat, double map_lon,
const rclcpp::Time &time) const {
// Setup the transform
geometry_msgs::msg::TransformStamped transformStamped;

// Broadcast the static transform
static_tf_broadcaster_->sendTransform(transformStamped);
transformStamped.header.stamp = time;
transformStamped.header.frame_id = "map";
transformStamped.child_frame_id = "odom";

}

void MapManagerNode::publish_foxglove_vis_frame(const rclcpp::Time& time) const
{
// Setup the transform
geometry_msgs::msg::TransformStamped transformStamped;
auto [x, y] = lla2flat(map_lat, map_lon);

transformStamped.header.stamp = time;
transformStamped.header.frame_id = "map";
transformStamped.child_frame_id = "map_visualization";
transformStamped.transform.translation.x = -x;
transformStamped.transform.translation.y = -y;
transformStamped.transform.translation.z = 0;

transformStamped.transform.translation.x = 0.0;
transformStamped.transform.translation.y = 0.0;
transformStamped.transform.translation.z = 0.0;
// NED to SEU
transformStamped.transform.rotation.x = 0.0;
transformStamped.transform.rotation.y = 1.0;
transformStamped.transform.rotation.z = 0.0;
transformStamped.transform.rotation.w = 0.0;
transformStamped.transform.rotation.x = 0.0;
transformStamped.transform.rotation.y = 0.0;
transformStamped.transform.rotation.z = 0.0;
transformStamped.transform.rotation.w = 1.0;

// Broadcast the static transform
static_tf_broadcaster_->sendTransform(transformStamped);
// Broadcast the static transform
static_tf_broadcaster_->sendTransform(transformStamped);
}

}
void MapManagerNode::publish_foxglove_vis_frame(
const rclcpp::Time &time) const {
// Setup the transform
geometry_msgs::msg::TransformStamped transformStamped;

transformStamped.header.stamp = time;
transformStamped.header.frame_id = "map";
transformStamped.child_frame_id = "map_visualization";

transformStamped.transform.translation.x = 0.0;
transformStamped.transform.translation.y = 0.0;
transformStamped.transform.translation.z = 0.0;
// NED to SEU
transformStamped.transform.rotation.x = 0.0;
transformStamped.transform.rotation.y = 1.0;
transformStamped.transform.rotation.z = 0.0;
transformStamped.transform.rotation.w = 0.0;

// Broadcast the static transform
static_tf_broadcaster_->sendTransform(transformStamped);
}

std::array<double, 2> MapManagerNode::flat2lla(double px, double py) const {
// Earth constants
Expand Down

0 comments on commit b65b35a

Please sign in to comment.