Skip to content
Merged
Changes from all commits
Commits
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
21 changes: 10 additions & 11 deletions src/systems/lookup_wheel_slip/LookupWheelSlip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <sdf/Geometry.hh>
#include <sdf/Heightmap.hh>

#include "gz/sim/components/SourceFilePath.hh"
#include "gz/sim/components/Geometry.hh"
#include "gz/sim/components/World.hh"
#include "gz/sim/Link.hh"
Expand Down Expand Up @@ -212,22 +213,19 @@ void LookupWheelSlip::Configure(const Entity &_entity,
return;
}

// transformation matrix from world to image coordinates
std::string filePath;
if (common::isFile(this->dataPtr->slipMapFilename))
{
filePath = this->dataPtr->slipMapFilename;
}
else if (common::isRelativePath(this->dataPtr->slipMapFilename))
// find the slip map file
auto modelPath =
_ecm.ComponentData<components::SourceFilePath>(_entity);
std::string filePath = common::findFile(asFullPath(
this->dataPtr->slipMapFilename, modelPath.value()), false);
if (filePath.empty())
{
auto *component =
_ecm.Component<components::WorldSdf>(worldEntity(_ecm));
const std::string rootPath =
common::parentPath(component->Data().Element()->FilePath());
std::string path = common::joinPaths(rootPath,
this->dataPtr->slipMapFilename);
if (common::isFile(path))
filePath = path;
filePath = common::findFile(asFullPath(this->dataPtr->slipMapFilename,
component->Data().Element()->FilePath()), false);
}
if (filePath.empty())
{
Expand All @@ -237,6 +235,7 @@ void LookupWheelSlip::Configure(const Entity &_entity,
return;
}
gzdbg << "Using slip_map: " << filePath << std::endl;
// transformation matrix from world to image coordinates
this->dataPtr->slipMapImg.Load(filePath);
this->dataPtr->slipMapRgb = this->dataPtr->slipMapImg.RGBData();
this->dataPtr->worldToImgTransform(0, 0) =
Expand Down
Loading