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

environment_preload: fix windows compiler warnings #2246

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
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
11 changes: 8 additions & 3 deletions src/systems/environment_preload/EnvironmentPreload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class gz::sim::systems::EnvironmentPreloadPrivate
public: bool visualize{false};

/// \brief Sample resolutions
public: math::Vector3d samples;
public: math::Vector3<unsigned int> samples;

/// \brief Is the file loaded
public: bool fileLoaded{false};
Expand Down Expand Up @@ -106,8 +106,13 @@ class gz::sim::systems::EnvironmentPreloadPrivate
// Only visualize if a file exists
return;
}
auto converted = msgs::Convert(_resChanged);
if (this->samples == converted)
math::Vector3<unsigned int> converted{
static_cast<unsigned int>(ceil(_resChanged.x())),
static_cast<unsigned int>(ceil(_resChanged.y())),
static_cast<unsigned int>(ceil(_resChanged.z()))};
if (this->samples.X() == converted.X() &&
this->samples.Y() == converted.Y() &&
this->samples.Z() == converted.Z())
{
// If the sample has not changed return.
// This is because resampling is expensive.
Expand Down
10 changes: 5 additions & 5 deletions src/systems/environment_preload/VisualizationTool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void EnvironmentVisualizationTool::Step(
const UpdateInfo &_info,
const EntityComponentManager &_ecm,
const std::shared_ptr<components::EnvironmentalData> &_data,
double _xSamples, double _ySamples, double _zSamples)
unsigned int _xSamples, unsigned int _ySamples, unsigned int _zSamples)
{
if (this->finishedTime)
{
Expand Down Expand Up @@ -114,7 +114,7 @@ void EnvironmentVisualizationTool::Step(
/////////////////////////////////////////////////
void EnvironmentVisualizationTool::Visualize(
const std::shared_ptr<components::EnvironmentalData> &_data,
double _xSamples, double _ySamples, double _zSamples)
unsigned int _xSamples, unsigned int _ySamples, unsigned int _zSamples)
{
for (auto key : _data->frame.Keys())
{
Expand All @@ -126,13 +126,13 @@ void EnvironmentVisualizationTool::Visualize(
auto dy = step.Y() / _ySamples;
auto dz = step.Z() / _zSamples;
std::size_t idx = 0;
for (std::size_t x_steps = 0; x_steps < ceil(_xSamples); x_steps++)
for (std::size_t x_steps = 0; x_steps < _xSamples; x_steps++)
{
auto x = lower_bound.X() + x_steps * dx;
for (std::size_t y_steps = 0; y_steps < ceil(_ySamples); y_steps++)
for (std::size_t y_steps = 0; y_steps < _ySamples; y_steps++)
{
auto y = lower_bound.Y() + y_steps * dy;
for (std::size_t z_steps = 0; z_steps < ceil(_zSamples); z_steps++)
for (std::size_t z_steps = 0; z_steps < _zSamples; z_steps++)
{
auto z = lower_bound.Z() + z_steps * dz;
auto res = frame.LookUp(session, math::Vector3d(x, y, z));
Expand Down
12 changes: 6 additions & 6 deletions src/systems/environment_preload/VisualizationTool.hh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class EnvironmentVisualizationTool

/// \brief Create publisher structures whenever a new environment is made
/// available.
/// \param[in] _data Data to be visuallized
/// \param[in] _data Data to be visualized
/// \param[in] _info simulation info for current time step
private: void CreatePointCloudTopics(
const std::shared_ptr<components::EnvironmentalData> &_data,
Expand All @@ -81,32 +81,32 @@ class EnvironmentVisualizationTool
/// \brief Step the visualizations
/// \param[in] _info The simulation info including timestep
/// \param[in] _ecm The Entity-Component-Manager
/// \param[in] _data The data to be visuallized
/// \param[in] _data The data to be visualized
/// \param[in] _xSample Samples along x
/// \param[in] _ySample Samples along y
/// \param[in] _zSample Samples along z
public: void Step(
const UpdateInfo &_info,
const EntityComponentManager &_ecm,
const std::shared_ptr<components::EnvironmentalData> &_data,
double _xSamples, double _ySamples, double _zSamples);
unsigned int _xSamples, unsigned int _ySamples, unsigned int _zSamples);

/// \brief Publishes a sample of the data
/// \param[in] _data The data to be visuallized
/// \param[in] _data The data to be visualized
/// \param[in] _xSample Samples along x
/// \param[in] _ySample Samples along y
/// \param[in] _zSample Samples along z
private: void Visualize(
const std::shared_ptr<components::EnvironmentalData> &_data,
double _xSamples, double _ySamples, double _zSamples);
unsigned int _xSamples, unsigned int _ySamples, unsigned int _zSamples);

/// \brief Get the point cloud data.
private: void Publish();

/// \brief Resize the point cloud structure (used to reallocate
/// memory when resolution changes)
/// \param[in] _ecm The Entity-Component-Manager
/// \param[in] _data The data to be visuallized
/// \param[in] _data The data to be visualized
/// \param[in] _xSample Samples along x
/// \param[in] _ySample Samples along y
/// \param[in] _zSample Samples along z
Expand Down
Loading