Skip to content

Commit f147163

Browse files
committed
Fixed rendering in case multiple static image compositors are used at the same time.
1 parent bc1547a commit f147163

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/compositors/OgreStaticImage.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,11 @@ void OgreStaticImage::CreateRenderPass()
119119
return;
120120
}
121121

122+
static size_t n {0u};
123+
n += 1;
124+
122125
this->dataPtr->material = Ogre::MaterialManager::getSingleton().getByName("StaticImageMat")->clone(
123-
"StaticImageMat/" + this->ogreCamera->getName());
126+
"StaticImageMat/" + this->ogreCamera->getName() + "_" + std::to_string(n));
124127

125128
const auto params = this->dataPtr->material->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
126129
params->setNamedConstant("is_background", this->dataPtr->isBackground);
@@ -130,7 +133,7 @@ void OgreStaticImage::CreateRenderPass()
130133
params->setNamedConstant("color_mode_color", convertColor(this->dataPtr->colorModeColor, this->dataPtr->sceneFormat));
131134

132135
// initialize the texture
133-
const auto texName = this->ogreCamera->getName() + "_staticImageTex";
136+
const auto texName = this->ogreCamera->getName() + "_staticImageTex" + std::to_string(n);
134137
this->dataPtr->texture = Ogre::TextureManager::getSingleton().createManual(
135138
texName, "General", Ogre::TEX_TYPE_2D, this->dataPtr->image.cols, this->dataPtr->image.rows, 1, 0,
136139
this->dataPtr->sceneFormat, Ogre::TU_STATIC_WRITE_ONLY);

src/robot_model_renderer/cras_bag_tools_plugin.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def __init__(self, camera_info_topic, mask_topic=None, description_param=None, d
4444
else:
4545
print('URDF model file "%s" does not exist.' % (description_file,), file=sys.stderr)
4646

47+
self._static_mask_file = None
48+
4749
self._config = RobotModelRendererConfig()
4850
# Default config for this plugin
4951
self._config.renderingMode = RenderingMode.MASK
@@ -89,6 +91,7 @@ def __init__(self, camera_info_topic, mask_topic=None, description_param=None, d
8991
package_path = rospack.get_path(matches[1])
9092
image_file = image_file.replace('$(find %s)' % (matches[1],), package_path)
9193
self._config.staticMaskImage = cv2.imread(image_file, cv2.IMREAD_UNCHANGED)
94+
self._static_mask_file = image_file
9295
except Exception as e:
9396
print("Error reading static mask image %s: %s" % (kwargs[k], str(e)), file=sys.stderr)
9497
else:
@@ -161,8 +164,10 @@ def reset(self):
161164
def _str_params(self):
162165
parts = [
163166
'camera_info_topic=' + self.camera_info_topic,
164-
'mask_topic=' + self.mask_topic
167+
'mask_topic=' + self.mask_topic,
165168
]
169+
if self._static_mask_file is not None:
170+
parts.append('staticMaskImage=' + self._static_mask_file)
166171
if self.description_param != "robot_description":
167172
parts.append('description_param=' + self.description_param)
168173
parent_params = super(RenderCameraMask, self)._str_params()

0 commit comments

Comments
 (0)