Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thermal Camera: Visualize objects with a heat signature #189

Merged
merged 18 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c7fc0de
started incorporating heat signature to thermal objects
adlarkin Dec 22, 2020
62397a8
promising results with hardcoded texture
adlarkin Jan 6, 2021
2bd317e
heat signature for one object is working
adlarkin Jan 12, 2021
06ea76e
enable multiple objects with different heat signatures
adlarkin Jan 13, 2021
a369a6e
allow for users to specify a custom temperature range
adlarkin Jan 13, 2021
df3024d
add check back in to fix missing background
adlarkin Jan 13, 2021
7f5a9fb
Add temperature variations to thermal camera readings based on color …
iche033 Jan 26, 2021
5935aea
Merge branch 'ign-rendering4' into adlarkin/heat_signature_thermal_ca…
adlarkin Jan 26, 2021
d94e0dd
make sure user input temperature range is within [0,655.35] kelvin
adlarkin Jan 26, 2021
cc5df61
Merge branch 'ign-rendering4' into adlarkin/heat_signature_thermal_ca…
adlarkin Jan 26, 2021
6b4bd9d
added heat signature thermal camera test
adlarkin Jan 27, 2021
f4ae55c
added missing test texture and fixed codecheck
adlarkin Jan 27, 2021
8ad2b5d
revert addition of Ogre2Material::PbsToUnlitDatablock helper function
adlarkin Jan 28, 2021
f710f72
address review feedback
adlarkin Jan 28, 2021
70672b2
Merge branch 'ign-rendering4' into adlarkin/heat_signature_thermal_ca…
adlarkin Jan 28, 2021
2f324b4
Merge branch 'ign-rendering4' into adlarkin/heat_signature_thermal_ca…
adlarkin Jan 29, 2021
80e5b81
Merge branch 'ign-rendering4' into adlarkin/heat_signature_thermal_ca…
iche033 Jan 30, 2021
6f1c4be
address windows warnings
adlarkin Feb 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions ogre2/src/Ogre2ThermalCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#endif

#include <math.h>

#include <limits>
#include <string>
#include <variant>

#include <ignition/common/Console.hh>
#include <ignition/math/Helpers.hh>
Expand Down Expand Up @@ -73,6 +76,9 @@ class Ogre2ThermalCameraMaterialSwitcher : public Ogre::RenderTargetListener
/// \brief Pointer to the heat source material
private: Ogre::MaterialPtr heatSourceMaterial;

/// \brief Pointer to heat signature material
private: Ogre::MaterialPtr heatSignatureMaterial;

/// \brief Custom parameter index of temperature data in an ogre subitem.
/// This has to match the custom index specifed in ThermalHeatSource material
/// script in media/materials/scripts/thermal_camera.material
Expand Down Expand Up @@ -145,6 +151,12 @@ Ogre2ThermalCameraMaterialSwitcher::Ogre2ThermalCameraMaterialSwitcher(

this->heatSourceMaterial = res.staticCast<Ogre::Material>();
this->heatSourceMaterial->load();

Ogre::ResourcePtr res2 =
Ogre::MaterialManager::getSingleton().load("ThermalHeatSignature",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
this->heatSignatureMaterial = res2.staticCast<Ogre::Material>();
this->heatSignatureMaterial->load();
}

//////////////////////////////////////////////////
Expand All @@ -162,7 +174,7 @@ void Ogre2ThermalCameraMaterialSwitcher::preRenderTargetUpdate(
Ogre::MovableObject *object = itor.peekNext();
Ogre::Item *item = static_cast<Ogre::Item *>(object);

std::string tempKey = "temperature";
const std::string tempKey = "temperature";
// get visual
Ogre::Any userAny = item->getUserObjectBindings().getUserAny();
if (!userAny.isEmpty() && userAny.getType() == typeid(unsigned int))
Expand All @@ -181,7 +193,8 @@ void Ogre2ThermalCameraMaterialSwitcher::preRenderTargetUpdate(

// get temperature
Variant tempAny = ogreVisual->UserData(tempKey);
if (tempAny.index() != 0)
if (tempAny.index() != 0 &&
!std::holds_alternative<std::string>(tempAny))
{
float temp = -1.0;
try
Expand Down Expand Up @@ -231,6 +244,26 @@ void Ogre2ThermalCameraMaterialSwitcher::preRenderTargetUpdate(
}
}
}
// see if a heat signature exists
else if (auto heatSignature = std::get_if<std::string>(&tempAny))
{
// TODO(adlarkin) set the texture in the material to heatSignature
// before applying the material? Right now, the texture is hardcoded,
// so heatSignature is unused

// set visibility flag so thermal camera can see it
item->addVisibilityFlags(0x10000000);

for (unsigned int i = 0; i < item->getNumSubItems(); ++i)
{
Ogre::SubItem *subItem = item->getSubItem(i);

Ogre::HlmsDatablock *datablock = subItem->getDatablock();
this->datablockMap[subItem] = datablock;

subItem->setMaterial(this->heatSignatureMaterial);
}
}
}
itor.moveNext();
}
Expand Down
16 changes: 16 additions & 0 deletions ogre2/src/media/materials/scripts/thermal.material
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,19 @@ material ThermalHeatSource
}
}
}

material ThermalHeatSignature
{
technique
{
pass
{
fog_override true

texture_unit
{
texture RescueRandy_Thermal.png
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.