ZJU-FAST-Lab / EGO-Planner-v2

Swarm Playground, the codebase of the paper "Swarm of micro flying robots in the wild"
GNU General Public License v3.0
400 stars 71 forks source link

How is 3d point converted to 1D representation in buffer #14

Closed shubham-shahh closed 2 years ago

shubham-shahh commented 2 years ago

Hi @bigsuperZZZX @USTfgaoaa , my understanding of functions such as GridMap::globalIdx2BufIdx and GridMap::globalIdx2InfBufIdx, is that it converts 3D point to 1D representation for a 1D buffer, correct me If I am wrong I want to understand the working of the function mentioned below

inline int GridMap::globalIdx2BufIdx(const Eigen::Vector3i &id)
{
  int x_buffer = (id(0) - md_.ringbuffer_origin3i_(0)) % md_.ringbuffer_size3i_(0);
  int y_buffer = (id(1) - md_.ringbuffer_origin3i_(1)) % md_.ringbuffer_size3i_(1);
  int z_buffer = (id(2) - md_.ringbuffer_origin3i_(2)) % md_.ringbuffer_size3i_(2);
  if (x_buffer < 0)
    x_buffer += md_.ringbuffer_size3i_(0);
  if (y_buffer < 0)
    y_buffer += md_.ringbuffer_size3i_(1);
  if (z_buffer < 0)
    z_buffer += md_.ringbuffer_size3i_(2);

  return md_.ringbuffer_size3i_(0) * md_.ringbuffer_size3i_(1) * z_buffer + md_.ringbuffer_size3i_(0) * y_buffer + x_buffer;
}

I want to understand the working of this function, how you convert a 3D to 1D, and what's the intuition.

bigsuperZZZX commented 2 years ago

You could refer to this paper for more details: "Real-Time Trajectory Replanning for MAVs using Uniform B-splines and a 3D Circular Buffer".

shubham-shahh commented 2 years ago

thanks, @bigsuperZZZX, I'll look into it. Ill close this issue for now