ros2 / rviz

ROS 3D Robot Visualizer
BSD 3-Clause Clear License
298 stars 212 forks source link

Suggestion: Dynamic texture update for costmap #937

Open Eric-Bwr opened 1 year ago

Eric-Bwr commented 1 year ago

In swatch.cpp one can update a texture. The issue is that the texture is just being recreated instead of updated if the size doesnt change aswell as the number of components. One could use something like this:

buffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox &pb = buffer->getCurrentLock();
auto *data = static_cast<uint8_t*>(pb.data);
size_t pitch = pb.rowPitch;
for(uint32_t y = 0; y < map.info.height; ++y){
  for(uint32_t x = 0; x < map.info.width; ++x){
    data[pitch * y + x] = map.data[pitch * y + x];`
  }
}
buffer->unlock();

I used foxy but this is present on all branches...

-> rviz_default_plugins/src/rviz_default_plugins/displays/map/swatch.cpp

I suggest implementing a dynamicUpdate() Method or something with a better name when one just wants to update the data FAST. I use the costmap for displaying live data which changes rapidly. I do think it could be usefull.

clalancette commented 1 year ago

Sorry, this isn't enough information to figure out what you mean. Can you give an example of a problem you are seeing, what platform you are using, the ROS distribution you are using, and a better description of what changes you think will help?

Eric-Bwr commented 1 year ago

Oh sorry, I needed to head to a meeting so I forgot about this :/ It should be clear now :)