1 #include "trajopt/common.hpp"
2 #include "json_marshal.hpp"
3 #include <boost/function.hpp>
4 #include <boost/shared_ptr.hpp>
5 #include "traj_plotter.hpp"
7 namespace sco{
struct OptResults;}
11 using namespace json_marshal;
13 typedef Json::Value TrajOptRequest;
14 typedef Json::Value TrajOptResponse;
18 typedef boost::shared_ptr<TermInfo> TermInfoPtr;
20 typedef boost::shared_ptr<TrajOptProb> TrajOptProbPtr;
21 struct ProblemConstructionInfo;
23 typedef boost::shared_ptr<TrajOptResult> TrajOptResultPtr;
25 TrajOptProbPtr TRAJOPT_API ConstructProblem(
const ProblemConstructionInfo&);
26 TrajOptProbPtr TRAJOPT_API ConstructProblem(
const Json::Value&, OpenRAVE::EnvironmentBasePtr env);
27 TrajOptResultPtr TRAJOPT_API OptimizeProblem(TrajOptProbPtr,
bool plot);
34 #define DEFINE_CREATE(classname) \
35 static TermInfoPtr create() {\
36 TermInfoPtr out(new classname());\
50 VarVector GetVarRow(
int i) {
51 return m_traj_vars.row(i);
53 Var& GetVar(
int i,
int j) {
54 return m_traj_vars.at(i,j);
59 int GetNumSteps() {
return m_traj_vars.rows();}
60 int GetNumDOF() {
return m_traj_vars.cols();}
61 ConfigurationPtr GetRAD() {
return m_rad;}
62 OR::EnvironmentBasePtr GetEnv() {
return m_rad->GetEnv();}
64 void SetInitTraj(
const TrajArray& x) {m_init_traj = x;}
65 TrajArray GetInitTraj() {
return m_init_traj;}
67 TrajPlotterPtr GetPlotter() {
return m_trajplotter;}
73 ConfigurationPtr m_rad;
74 TrajArray m_init_traj;
75 TrajPlotterPtr m_trajplotter;
81 vector<string> cost_names, cnt_names;
82 vector<double> cost_vals, cnt_viols;
93 void fromJson(
const Json::Value& v);
106 void fromJson(
const Json::Value& v);
123 virtual void fromJson(
const Json::Value& v)=0;
127 static TermInfoPtr fromName(
const string& type);
133 typedef TermInfoPtr (*MakerFunc)(void);
134 static void RegisterMaker(
const std::string& type, MakerFunc);
138 static std::map<string, MakerFunc> name2maker;
148 vector<TermInfoPtr> cost_infos;
149 vector<TermInfoPtr> cnt_infos;
152 OR::EnvironmentBasePtr env;
156 void fromJson(
const Value& v);
168 Vector3d pos_coeffs, rot_coeffs;
170 KinBody::LinkPtr link;
171 void fromJson(
const Value& v);
188 void fromJson(
const Value& v);
201 int first_step, last_step;
202 KinBody::LinkPtr link;
203 double max_displacement;
204 void fromJson(
const Value& v);
219 void fromJson(
const Value& v);
226 int first_step, last_step;
227 void fromJson(
const Value& v);
253 void fromJson(
const Value& v);
268 void fromJson(
const Value& v);