Skip to content

Commit 2d775ff

Browse files
JafarAbdiv4hn
authored andcommitted
GeneratorMockup: Add solutions_per_compute argument
1 parent 79869b8 commit 2d775ff

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

core/test/stage_mockups.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ double PredefinedCosts::cost() const {
4646
return c;
4747
}
4848

49-
GeneratorMockup::GeneratorMockup(PredefinedCosts&& costs)
50-
: Generator{ "GEN" + std::to_string(++id_) }, costs_{ std::move(costs) } {}
49+
GeneratorMockup::GeneratorMockup(PredefinedCosts&& costs, std::size_t solutions_per_compute)
50+
: Generator{ "GEN" + std::to_string(++id_) }
51+
, costs_{ std::move(costs) }
52+
, solutions_per_compute_{ solutions_per_compute } {}
5153

5254
void GeneratorMockup::init(const moveit::core::RobotModelConstPtr& robot_model) {
5355
ps_.reset(new planning_scene::PlanningScene(robot_model));
@@ -63,7 +65,8 @@ bool GeneratorMockup::canCompute() const {
6365
void GeneratorMockup::compute() {
6466
++runs_;
6567

66-
spawn(InterfaceState(ps_), costs_.cost());
68+
for (std::size_t i = 0; canCompute() && i < solutions_per_compute_; ++i)
69+
spawn(InterfaceState(ps_), costs_.cost());
6770
}
6871

6972
MonitoringGeneratorMockup::MonitoringGeneratorMockup(Stage* monitored, PredefinedCosts&& costs)

core/test/stage_mockups.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ struct GeneratorMockup : public Generator
4040

4141
PredefinedCosts costs_;
4242
size_t runs_{ 0 };
43+
std::size_t solutions_per_compute_;
4344

4445
static unsigned int id_;
4546

4647
// default to one solution to avoid infinity loops
47-
GeneratorMockup(PredefinedCosts&& costs = PredefinedCosts{ std::list<double>{ 0.0 }, true });
48+
GeneratorMockup(PredefinedCosts&& costs = PredefinedCosts{ std::list<double>{ 0.0 }, true },
49+
std::size_t solutions_per_compute = 1);
4850
GeneratorMockup(std::initializer_list<double> costs)
4951
: GeneratorMockup{ PredefinedCosts{ std::list<double>{ costs }, true } } {}
5052

0 commit comments

Comments
 (0)