Code Monkey home page Code Monkey logo

Comments (5)

jaiveersinghNV avatar jaiveersinghNV commented on May 23, 2024 1

Could you please try again with the latest Isaac ROS DP3 Release?

from isaac_ros_nvblox.

alexmillane avatar alexmillane commented on May 23, 2024

Interesting! It's possible you've found a bug.

Could you upload a video showing the effect so I can try to repro? 😃

from isaac_ros_nvblox.

Veng97 avatar Veng97 commented on May 23, 2024

I've written a simple example that shows how I convert between a standard nav_msg OccupancyGrid and the nvblox DistanceMapSlice so you can test it quickly.

// CostMap color palattes: http://docs.ros.org/en/jade/api/rviz/html/c++/map__display_8cpp_source.html
constexpr int8_t kNoInformation = 0;
constexpr int8_t kFreeSpace = 1;
constexpr int8_t kMinCost = 2;
constexpr int8_t kMaxCost = 98;
constexpr int8_t kInscribedInflatedObstacle = 99;
constexpr int8_t kLethalObstacle = 100;

ObstacleMapping::ObstacleMapping() : Node("obstacle_mapping") {
  RCLCPP_INFO(this->get_logger(), "Launching Obstacle Mapping Node!");

  occupancy_inflation_distance_ = declare_parameter<float>("occupancy_inflation_distance_m", occupancy_inflation_distance_);
  occupancy_max_distance_ = declare_parameter<float>("occupancy_max_distance_m", occupancy_max_distance_);

  // Publishers
  pub_obstacle_map_ = this->create_publisher<nav_msgs::msg::OccupancyGrid>("~/occupancy_grid", rclcpp::SensorDataQoS());

  // Subscribers
  sub_distance_map_slice_ = this->create_subscription<nvblox_msgs::msg::DistanceMapSlice>("/nvblox_node/map_slice", rclcpp::SensorDataQoS(),
                                                                                          std::bind(&ObstacleMapping::DistanceMapSliceCallback, this, std::placeholders::_1));
}

void ObstacleMapping::DistanceMapSliceCallback(const nvblox_msgs::msg::DistanceMapSlice::ConstSharedPtr& msg) {
  // Create occupancy map from nvblox slice
  nav_msgs::msg::OccupancyGrid::UniquePtr occupancy_grid = std::make_unique<nav_msgs::msg::OccupancyGrid>();
  occupancy_grid->header.frame_id = msg->header.frame_id;
  occupancy_grid->header.stamp = msg->header.stamp;

  // Copy map dimensions
  occupancy_grid->info.origin.position = msg->origin;
  occupancy_grid->info.resolution = msg->resolution;
  occupancy_grid->info.width = msg->width;
  occupancy_grid->info.height = msg->height;

  // Allocate the occupancy grid
  size_t map_size = msg->width * msg->height;
  occupancy_grid->data.resize(map_size, kNoInformation);

  // Remap the floating point distance to occupancy grid colors
  const auto k_unknown_value = msg->unknown_value;
  for (size_t i = 0; i < map_size; ++i) {
    // Default: No information
    if (msg->data[i] == k_unknown_value) {
      continue;
    }

    // Lethal obstacle
    if (msg->data[i] <= 0.0F) {
      occupancy_grid->data[i] = kLethalObstacle;
      continue;
    }

    // Inflated obstacle
    if (msg->data[i] <= occupancy_inflation_distance_) {
      occupancy_grid->data[i] = kInscribedInflatedObstacle;
      continue;
    }

    // Free space
    if (msg->data[i] > occupancy_max_distance_) {
      occupancy_grid->data[i] = kFreeSpace;
      continue;
    }

    // Distance scale
    occupancy_grid->data[i] = kMinCost + static_cast<int8_t>((kMaxCost - kMinCost) * (1.0F - std::min((msg->data[i] - occupancy_inflation_distance_) / occupancy_max_distance_, 1.0F)));
  }

  pub_obstacle_map_->publish(std::move(occupancy_grid));
}

The video below should highlight the issue. The point cloud distance slice is shown with the point tiles and the underlying distance map is the OccupancyGrid msg slice. The point cloud distance slice seems completely static, but the other map jumps a bit around. The maps are also not completely aligned, which is likely also related to this same issue.

example.1.webm

from isaac_ros_nvblox.

Veng97 avatar Veng97 commented on May 23, 2024

The jump is no longer present in the new release :)

from isaac_ros_nvblox.

alexmillane avatar alexmillane commented on May 23, 2024

@Veng97 Thank you for your help in finding this. much appreciated 👍

from isaac_ros_nvblox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.