Bench-MR
A Motion Planning Benchmark for Wheeled Mobile Robots
CHOMP.h
Go to the documentation of this file.
1#pragma once
2
3#include <chomp/ConstraintFactory.h>
4#include <chomp/Map2D.h>
5#include <chomp/chomputil.h>
6#include <mzcommon/DtGrid.h>
7#include <utils/Stopwatch.hpp>
8
10
11using chomp::MatX;
12
13class CHOMP {
14 public:
16
17 ob::PlannerStatus run(const og::PathGeometric &path);
18
19 og::PathGeometric solution() const;
20 std::vector<Point> solutionPath() const;
21
22 double planningTime() const;
23
24 private:
25 static Map2D *_map;
26 Stopwatch _timer;
27 std::vector<Point> _path;
28
29 class Map2DCHelper : public chomp::ChompCollisionHelper {
30 public:
31 enum {
32 NUM_CSPACE = 2,
33 NUM_WKSPACE =
34 3, // actually just 2 but this way I can test matrix dims better
35 NUM_BODIES = 1,
36 };
37
38 const Map2D map;
39
40 explicit Map2DCHelper(const Map2D &m)
41 : ChompCollisionHelper(NUM_CSPACE, NUM_WKSPACE, NUM_BODIES), map(m) {}
42
43 Map2DCHelper()
44 : ChompCollisionHelper(NUM_CSPACE, NUM_WKSPACE, NUM_BODIES), map() {}
45
46 double getCost(const MatX &q, size_t body_index, MatX &dx_dq,
47 MatX &cgrad) override {
48 assert((q.rows() == 2 && q.cols() == 1) ||
49 (q.rows() == 1 && q.cols() == 2));
50
51 dx_dq.conservativeResize(3, 2);
52 dx_dq.setZero();
53
54 dx_dq << 1, 0, 0, 1, 0, 0;
55
56 cgrad.conservativeResize(3, 1);
57
58 vec3f g;
59 float c = map.sampleCost(vec3f((float)q(0), (float)q(1), 0.0), g);
60
61 cgrad << g[0], g[1], 0.0;
62
63 return c;
64 }
65 };
66};
Definition: CHOMP.h:13
ob::PlannerStatus run(const og::PathGeometric &path)
Definition: CHOMP.cpp:38
std::vector< Point > solutionPath() const
Definition: CHOMP.cpp:127
og::PathGeometric solution() const
Definition: CHOMP.cpp:121
double planningTime() const
Definition: CHOMP.cpp:129
Stopwatch implementation to measure elapsed time.
Definition: Stopwatch.hpp:8