Skip to content

Commit d48f9d6

Browse files
Added a test, added print statements for keepout zones, turned off z obs avoidance for granite
1 parent 5616c44 commit d48f9d6

File tree

2 files changed

+103
-8
lines changed

2 files changed

+103
-8
lines changed

mobility/planner_scp_gusto/src/optim.cc

+60-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ TOP::TOP(decimal_t Tf_, int N_)
108108
x0 << 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0;
109109
xg << 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0;
110110

111-
// TODO(acauligi): read off params server
111+
// Defaults are ISS params (will be written by planner_scp_gusto_nodelet)
112112
radius_ = 0.26;
113113
mass = 9.583788668;
114114
J << 0.153427995, 0, 0,
@@ -1055,12 +1055,26 @@ void TOP::SetSimpleConstraints() {
10551055
}
10561056

10571057
if (enforce_state_bounds || enforce_obs_avoidance_const) {
1058+
if (enforce_state_bounds) {
1059+
std::cout << "[TOP::SetSimpleConstraints] MinPos: " << MinPos().transpose() << std::endl;
1060+
std::cout << "[TOP::SetSimpleConstraints] MaxPos: " << MaxPos().transpose() << std::endl;
1061+
}
1062+
if (enforce_obs_avoidance_const) {
1063+
if (keep_out_zones_.size() == 0) {
1064+
std::cout << "ERROR: No keep-out zones provided for obstacle avoidance constraints. Ignoring." << std::endl;
1065+
} else {
1066+
std::cout << "[TOP::SetSimpleConstraints] ko box min: " << keep_out_zones_.back().min().transpose()
1067+
<< std::endl;
1068+
std::cout << "[TOP::SetSimpleConstraints] ko box max: " << keep_out_zones_.back().max().transpose()
1069+
<< std::endl;
1070+
}
1071+
}
10581072
for (size_t ii = 0; ii < N; ii++) {
10591073
for (size_t jj = 0; jj < 3; jj++) { // x, y, z only for now
10601074
decimal_t lb = MinPos()[jj];
10611075
decimal_t ub = MaxPos()[jj];
10621076

1063-
if (enforce_obs_avoidance_const) {
1077+
if (enforce_obs_avoidance_const && (keep_out_zones_.size() > 0) && (!is_granite || (jj != 2))) {
10641078
// Obstacle avoidance logic
10651079
Eigen::AlignedBox3d box = keep_out_zones_.back();
10661080
Eigen::Vector3d ko_min = box.min();
@@ -3144,7 +3158,9 @@ int main() {
31443158
bool test_warm_start = false;
31453159

31463160
bool test_state_bound_constraints = false;
3147-
bool test_obs_avoidance_translation = true;
3161+
bool test_obs_avoidance_translation = false;
3162+
3163+
bool granite_obs_avoidance = true;
31483164

31493165
int num_problems = 0;
31503166

@@ -3525,6 +3541,47 @@ int main() {
35253541
}
35263542
}
35273543

3544+
if (granite_obs_avoidance) {
3545+
scp::TOP* top;
3546+
top = new scp::TOP(20., 401);
3547+
top->is_granite = true;
3548+
top->enforce_obs_avoidance_const = true;
3549+
top->use_nn_warm_start = false;
3550+
top->x0 << -0.3, 0.3, -0.67, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0;
3551+
top->xg << 0.2, -0.3, -0.67, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0;
3552+
if (top->is_granite) {
3553+
top->radius_ = 0.26;
3554+
top->mass = 18.9715;
3555+
top->J << 0.2517, 0.0, 0.0, 0.0, 0.2517, 0.0, 0.0, 0.0, 0.2517;
3556+
top->Jinv = top->J.inverse();
3557+
3558+
Eigen::AlignedBox3d kiz;
3559+
kiz.extend(Eigen::Vector3d(-1, -1, -0.75));
3560+
kiz.extend(Eigen::Vector3d(1, 1, -0.6));
3561+
top->keep_in_zones_.push_back(kiz);
3562+
3563+
top->x_min(0) = -1.0;
3564+
top->x_max(0) = 1.0;
3565+
top->x_min(1) = -1.0;
3566+
top->x_max(1) = 1.0;
3567+
top->x_min(2) = -0.75;
3568+
top->x_max(2) = -0.6;
3569+
}
3570+
3571+
Eigen::AlignedBox3d smallObstacle;
3572+
smallObstacle.extend(Eigen::Vector3d(-0.25, -0.25, -2));
3573+
smallObstacle.extend(Eigen::Vector3d(0., 0., 0));
3574+
top->keep_out_zones_.push_back(smallObstacle);
3575+
3576+
if (!top->Solve()) {
3577+
std::cout << "Problem could not be solved!" << std::endl;
3578+
} else {
3579+
std::cout << "Problem solved!" << std::endl;
3580+
top->WriteTrajectoryToFile("output_granite_obs_avoidance");
3581+
}
3582+
std::cout << "--------------------------------------------" << std::endl;
3583+
}
3584+
35283585
// scp::TOP* top;
35293586
// top = new scp::TOP(20., 801);
35303587
// for (int ii = 0; ii < 100; ii++) {

mobility/planner_scp_gusto/src/simple/plot_simple.ipynb

+43-5
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)