Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and quimortiz committed Nov 14, 2023
1 parent 0b803dc commit 0688732
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ jobs:
- name: Install latest ompl
run: |
# sudo apt install libompl-dev -y
cd
cd
mkdir __local
git clone https://github.com/ompl/ompl
cd ompl
cd ompl
git checkout e2994e5
mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=~/__local && make install -j4
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ add_library(motion_primitives ./src/motion_primitives/motion_primitives.cpp)
add_library(
optimization
./src/optimization/ocp.cpp ./src/optimization/options.cpp
./src/optimization/croco_models.cpp ./src/optimization/generate_ocp.cpp ./src/optimization/multirobot_optimization.cpp)
./src/optimization/croco_models.cpp ./src/optimization/generate_ocp.cpp
./src/optimization/multirobot_optimization.cpp)

add_library(sst ./src/ompl/sst.cpp ./src/ompl/robots.cpp)
add_library(rrt_to ./src/ompl/rrt_to.cpp ./src/ompl/robots.cpp)
Expand Down
57 changes: 31 additions & 26 deletions include/dynoplan/dbastar/options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,46 +95,51 @@ struct Time_benchmark {
};
};



/**
* @brief Options for the dbastar algorithm
*
* It is used to load the options from a yaml file/boost options and to pass them to the
* the function dbastar.
* It also prints all the options to a file.
*
*/
* @brief Options for the dbastar algorithm
*
* It is used to load the options from a yaml file/boost options and to pass
* them to the the function dbastar. It also prints all the options to a file.
*
*/
struct Options_dbastar {

bool fix_seed = 0; // use 1 to fix the seed of srand to 0
float delta = .3; // discontinuity bound
float alpha = .5; // How discontinuity bound is shared between expansion and reaching
float delta = .3; // discontinuity bound
float alpha =
.5; // How discontinuity bound is shared between expansion and reaching
float connect_radius_h = .5; // Connection radius for heuristic (only ROADMAP)
std::string motionsFile = ""; // file with motion primitives
std::string motionsFile = ""; // file with motion primitives
std::vector<Motion> *motions_ptr = nullptr; // Pointer to loaded motions
std::string outFile = "/tmp/dynoplan/out_db.yaml"; // output file to write some results
float maxCost = std::numeric_limits<float>::infinity(); // Cost bound during search
int heuristic = 0; // which heuristic to use
size_t max_motions = 1e4; // Max number of motions to use in the search
std::string outFile =
"/tmp/dynoplan/out_db.yaml"; // output file to write some results
float maxCost =
std::numeric_limits<float>::infinity(); // Cost bound during search
int heuristic = 0; // which heuristic to use
size_t max_motions = 1e4; // Max number of motions to use in the search
double heu_resolution = .5; // used only for ROADMAP heuristic
double delta_factor_goal = 1; // Acceptable distance to goal (in terms of delta)
double cost_delta_factor = 1; // Rate to add cost to the discontinuity
double delta_factor_goal =
1; // Acceptable distance to goal (in terms of delta)
double cost_delta_factor = 1; // Rate to add cost to the discontinuity
size_t num_sample_trials = 3000; // Used in Roadmap heuristic
size_t max_size_heu_map = 1000; // Used in Roadmap heuristic
size_t max_expands = 1e6; // Max expands -- used as one of the stopping criteria
size_t max_size_heu_map = 1000; // Used in Roadmap heuristic
size_t max_expands =
1e6; // Max expands -- used as one of the stopping criteria
bool cut_actions = false; // Cut input primitives to have more primitives
bool debug = false;
int limit_branching_factor = 20; // Limit on branching factor to encourage more deep search
bool use_collision_shape = true; // Use collision shapes (if available for the dynamics)
int limit_branching_factor =
20; // Limit on branching factor to encourage more deep search
bool use_collision_shape =
true; // Use collision shapes (if available for the dynamics)
bool new_invariance = false; // If true, allow for system dependent invariance
std::vector<Heuristic_node> *heu_map_ptr = nullptr; // Pointer to a loaded heuristic map
std::string heu_map_file; // File that contains the heuristic map
std::vector<Heuristic_node> *heu_map_ptr =
nullptr; // Pointer to a loaded heuristic map
std::string heu_map_file; // File that contains the heuristic map
bool add_after_expand = false; // this does not improve cost of closed

double search_timelimit = 1e4; // in ms
double search_timelimit = 1e4; // in ms
double heu_connection_radius = 1; // connection radius for ROADMAP heuristic
bool use_nigh_nn = true; // use nigh for nearest neighbor.
bool use_nigh_nn = true; // use nigh for nearest neighbor.
bool check_cols = true;

void add_options(po::options_description &desc);
Expand Down
16 changes: 9 additions & 7 deletions include/dynoplan/idbastar/idbastar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ struct Info_out_idbastar : dynobench::Info_out {
};

struct Options_idbAStar {
double delta_0 = .3; // initial delta
size_t num_primitives_0 = 1000; // initial number of primitives
double delta_rate = .9; // rate to decrease delta
double delta_0 = .3; // initial delta
size_t num_primitives_0 = 1000; // initial number of primitives
double delta_rate = .9; // rate to decrease delta
double num_primitives_rate = 1.5; // rate to increase number of primitives
double timelimit = 10; // Time limit in seconds
size_t max_it = 10; // Maximum number of iterations
double timelimit = 10; // Time limit in seconds
size_t max_it = 10; // Maximum number of iterations
size_t max_num_sol = 5; // Stop when you reach this number of solutions
size_t max_motions_primitives = 1e4; // Maximum number of primitives to load frol file
bool new_schedule = true; // Schedule for delta and number of primitives of the TRO paper.
size_t max_motions_primitives =
1e4; // Maximum number of primitives to load frol file
bool new_schedule =
true; // Schedule for delta and number of primitives of the TRO paper.
bool add_primitives_opt = true; // Add primitives after optimization

void add_options(po::options_description &desc) {
Expand Down
8 changes: 4 additions & 4 deletions include/dynoplan/optimization/multirobot_optimization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string>

bool execute_optimizationMultiRobot(const std::string &env_file,
const std::string &initial_guess_file,
const std::string &output_file,
const std::string &dynobench_base,
bool sum_robots_cost);
const std::string &initial_guess_file,
const std::string &output_file,
const std::string &dynobench_base,
bool sum_robots_cost);
3 changes: 1 addition & 2 deletions src/optimization/generate_ocp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ generate_problem(const Generate_params &gen_args,

std::vector<ptr<Cost>> feats_run;

if (gen_args.model_robot->name == "joint_robot") {
if (gen_args.model_robot->name == "joint_robot") {

auto ptr_derived = std::dynamic_pointer_cast<dynobench::Joint_robot>(
gen_args.model_robot);
Expand All @@ -111,7 +111,6 @@ generate_problem(const Generate_params &gen_args,
print_vec(goal_times.data(), goal_times.size());
CSTR_(gen_args.N);


if (goal_times.size()) {
Eigen::VectorXd weights = Eigen::VectorXd::Zero(nx);
for (size_t j = 0; j < goal_times.size(); j++) {
Expand Down
17 changes: 6 additions & 11 deletions src/optimization/main_multirobot_optimization.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#include "dynobench/multirobot_trajectory.hpp"
#include <algorithm>
#include <boost/program_options.hpp>
#include <chrono>
#include <fstream>
#include <iostream>
#include <iterator>
#include <yaml-cpp/yaml.h>
#include "dynobench/multirobot_trajectory.hpp"

// OMPL headers

#include <dynoplan/optimization/ocp.hpp>
#include <dynoplan/optimization/multirobot_optimization.hpp>



#include <dynoplan/optimization/ocp.hpp>

int main(int argc, char *argv[]) {

Expand All @@ -27,12 +24,10 @@ int main(int argc, char *argv[]) {
desc.add_options()("help", "produce help message")(
"env,e", po::value<std::string>(&envFile)->required())(
"init,i", po::value<std::string>(&initFile)->required())(
"out,o", po::value<std::string>(&outFile)->required())
(
"out,o", po::value<std::string>(&outFile)->required())(
"base,b", po::value<std::string>(&dynobench_base)->required())

(
"sum,s", po::value<bool>(&sum_robots_cost)->required());
("sum,s", po::value<bool>(&sum_robots_cost)->required());

try {
po::variables_map vm;
Expand All @@ -49,6 +44,6 @@ int main(int argc, char *argv[]) {
return 1;
}

execute_optimizationMultiRobot(envFile, initFile, outFile,
dynobench_base, sum_robots_cost);
execute_optimizationMultiRobot(envFile, initFile, outFile, dynobench_base,
sum_robots_cost);
}
17 changes: 7 additions & 10 deletions src/optimization/multirobot_optimization.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#include <string>
#include "dynobench/motions.hpp"
#include <vector>
#include <dynoplan/optimization/ocp.hpp>
#include <dynobench/multirobot_trajectory.hpp>
#include <dynoplan/optimization/multirobot_optimization.hpp>

#include <dynoplan/optimization/ocp.hpp>
#include <string>
#include <vector>

bool execute_optimizationMultiRobot(const std::string &env_file,
const std::string &initial_guess_file,
const std::string &output_file,
const std::string &dynobench_base,
bool sum_robots_cost) {
const std::string &initial_guess_file,
const std::string &output_file,
const std::string &dynobench_base,
bool sum_robots_cost) {

using namespace dynoplan;
using namespace dynobench;
Expand Down Expand Up @@ -86,7 +85,5 @@ bool execute_optimizationMultiRobot(const std::string &env_file,
multi_out.to_yaml_format("/tmp/check5.yaml");
multi_out.to_yaml_format(output_file.c_str());


return true;

}
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ find_package(Boost REQUIRED COMPONENTS unit_test_framework)

add_executable(
test_optimization
./optimization/test_optimization_base.cpp
./optimization/test_optimization_0.cpp
./optimization/test_optimization_base.cpp
./optimization/test_optimization_0.cpp
./optimization/test_optimization_1.cpp
./optimization/test_optimization_cli.cpp
./optimization/test_optimization_multirobot.cpp)
Expand Down
3 changes: 2 additions & 1 deletion test/optimization/test_optimization_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ BOOST_AUTO_TEST_CASE(t_method_time_opti) {

if (solver.name == "mpcc" && (problem.name == "quadrotor_0-recovery" ||
problem.name == "quadrotor_0-window")) {
BOOST_TEST_WARN(false, "i skip mpcc in quadrotor_0-recovery and window");
BOOST_TEST_WARN(false,
"i skip mpcc in quadrotor_0-recovery and window");
continue;
}

Expand Down
2 changes: 0 additions & 2 deletions test/optimization/test_optimization_multirobot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ using namespace dynobench;

BOOST_AUTO_TEST_CASE(t_multi_robot_cli) {


std::vector<std::string> run_cmd_new = {
"../main_multirobot_optimization",
"--env",
Expand Down Expand Up @@ -439,4 +438,3 @@ BOOST_AUTO_TEST_CASE(t_hetero_random_2) {

multi_out.to_yaml_format("/tmp/test_gen_p10_n2_1_hetero_solution.yaml");
}

0 comments on commit 0688732

Please sign in to comment.