Skip to content
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
14 changes: 4 additions & 10 deletions blast/blast_optimization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ struct Guess {
enum GuessType : u32 {
custom,
random,
from_list,
rrt_connect
shotgun,
from_list
};

GuessType type = random;
Expand All @@ -57,17 +57,11 @@ struct Guess {
candidates(std::move(m)) {
}

// Constructor for Guess::random, initializing n_random_shots
// Constructor for Guess::shotgun, initializing n_random_shots
explicit Guess(u32 shots) :
type(Guess::random),
type(Guess::shotgun),
n_random_shots(shots) {
}

// Constructor for Guess::rrt_connect, initializing parameter
explicit Guess(real param) :
type(Guess::rrt_connect),
parameter(param) {
}
};

enum ConstraintType : unsigned {
Expand Down
14 changes: 6 additions & 8 deletions blast/optimization/initial_guess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ inline Array get_best_x_segments(Optimization* opt) {
inline Array init_guess_segments(Optimization* opt) {
Array x(opt->bspline.x_len(opt->task));
switch (opt->guess.type) {
case Guess::rrt_connect: {
// auto x = guess_rrt<og::RRTConnect>(opt); todo: create and use opt->guess.parameter for range
std::cout << "RRTConnect is not yet supported" << std::endl;
case Guess::random: {
x = guess_random(opt->bspline, opt->task);
break;
}
case Guess::random: {
case Guess::shotgun: {
x = guess_shot_mean_segments(opt);
break;
}
Expand Down Expand Up @@ -148,12 +147,11 @@ inline Array get_best_x(Optimization* opt) {
inline Array init_guess(Optimization* opt) {
Array x(opt->bspline.x_len(opt->task));
switch (opt->guess.type) {
case Guess::rrt_connect: {
// auto x = guess_rrt<og::RRTConnect>(opt); todo: create and use opt.guess.parameter for range
std::cout << "RRTConnect is not yet supported" << std::endl;
case Guess::random: {
x = guess_random(opt->bspline, opt->task);
break;
}
case Guess::random: {
case Guess::shotgun: {
x = guess_shot_mean(opt);
break;
}
Expand Down
3 changes: 1 addition & 2 deletions examples/example_02_trajectory_optimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ int main() {
// Guess::random tries n_shot random starting points and picks the best
// one as the initial solution for the optimizer.
// -----------------------------------------------------------------------
opt.guess.type = Guess::random;
opt.guess.n_random_shots = 50;
opt.guess.type = Guess::random;

// -----------------------------------------------------------------------
// Step 6 — Run the optimizer.
Expand Down
3 changes: 1 addition & 2 deletions examples/example_03_collision_avoidance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ int main() {
std::cout << "Attempt " << attempt << "/" << max_attempts << "... ";

// Draw a fresh random initial guess for each attempt.
opt.guess.type = Guess::random;
opt.guess.n_random_shots = 30;
opt.guess.type = Guess::random;

// optimize() with with_segments (the default) reduces collision constraints
// to one worst-case value per B-spline segment, keeping the problem tractable
Expand Down
4 changes: 0 additions & 4 deletions tests/test_helper/test_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,6 @@ inline host_fn bool is_close(const Guess& guess1, const Guess& guess2, real eps
if (is_close(guess1.n_random_shots, guess2.n_random_shots))
return false;
break;
case Guess::rrt_connect:
if (!is_close(guess1.parameter, guess2.parameter))
return false;
break;
default:
Assert(false);
}
Expand Down
Loading