17#ifndef GAZEBO_PHYSICS_POPULATION_HH_
18#define GAZEBO_PHYSICS_POPULATION_HH_
22#include <ignition/math/Pose3.hh>
23#include <ignition/math/Vector3.hh>
24#include <boost/shared_ptr.hpp>
25#include <boost/scoped_ptr.hpp>
39 class PopulationPrivate;
45 public: ignition::math::Vector3d
size;
54 public: ignition::math::Vector3d
step;
57 public: ignition::math::Pose3d
pose;
90 public:
Population(sdf::ElementPtr _sdf, boost::shared_ptr<World> _world);
104 private:
bool PopulateOne(
const sdf::ElementPtr _population);
112 private:
template<
typename T>
bool ValueFromSdf(
113 const sdf::ElementPtr &_sdfElement,
const std::string &_element,
116 if (_sdfElement->HasElement(_element))
118 _value = _sdfElement->Get<T>(_element);
121 gzerr <<
"Unable to find <" << _element <<
"> inside the population tag"
132 private:
bool ElementFromSdf(
const sdf::ElementPtr &_sdfElement,
133 const std::string &_element, sdf::ElementPtr &_value);
143 private:
bool ParseSdf(sdf::ElementPtr _population,
144 PopulationParams &_params);
153 private:
void CreatePosesBoxRandom(
const PopulationParams &_populParams,
154 std::vector<ignition::math::Vector3d> &_poses);
164 private:
void CreatePosesBoxUniform(
const PopulationParams &_populParams,
165 std::vector<ignition::math::Vector3d> &_poses);
177 private:
void CreatePosesBoxGrid(
const PopulationParams &_populParams,
178 std::vector<ignition::math::Vector3d> &_poses);
187 private:
void CreatePosesBoxLinearX(
const PopulationParams &_populParams,
188 std::vector<ignition::math::Vector3d> &_poses);
197 private:
void CreatePosesBoxLinearY(
const PopulationParams &_populParams,
198 std::vector<ignition::math::Vector3d> &_poses);
207 private:
void CreatePosesBoxLinearZ(
const PopulationParams &_populParams,
208 std::vector<ignition::math::Vector3d> &_poses);
220 private:
void CreatePosesCylinderRandom(
221 const PopulationParams &_populParams,
222 std::vector<ignition::math::Vector3d> &_poses);
235 private:
void CreatePosesCylinderUniform(
236 const PopulationParams &_populParams,
237 std::vector<ignition::math::Vector3d> &_poses);
241 private: boost::scoped_ptr<PopulationPrivate> dataPtr;
Stores all the posible parameters that define a population.
Definition: Population.hh:43
int rows
Number of rows used when models are distributed as a grid.
Definition: Population.hh:48
std::string modelName
Name of the model.
Definition: Population.hh:66
ignition::math::Pose3d pose
The reference frame of the population's region.
Definition: Population.hh:57
double radius
Radius of the cylinder's base containing the models.
Definition: Population.hh:60
int cols
Number of columns used when models are distributed as a grid.
Definition: Population.hh:51
std::string region
Type region in which the objects will be spawned. E.g.: box.
Definition: Population.hh:78
std::string modelSdf
Contains the sdf representation of the model.
Definition: Population.hh:69
ignition::math::Vector3d size
The three side lengths of the box.
Definition: Population.hh:45
int modelCount
Number of models to spawn.
Definition: Population.hh:72
double length
Length of the cylinder containing the models.
Definition: Population.hh:63
std::string distribution
Object distribution. E.g.: random, grid.
Definition: Population.hh:75
ignition::math::Vector3d step
Distance between models when they are distributed as a grid.
Definition: Population.hh:54
Class that automatically populates an environment with multiple objects based on several parameters t...
Definition: Population.hh:86
bool PopulateAll()
Generate and spawn multiple populations into the world.
Population(sdf::ElementPtr _sdf, boost::shared_ptr< World > _world)
Constructor.
virtual ~Population()
Destructor.
#define gzerr
Output an error message.
Definition: Console.hh:50
Forward declarations for the common classes.
Definition: Animation.hh:27