Skip to content

Commit 954b59d

Browse files
committed
readme modified
1 parent 76655b9 commit 954b59d

File tree

1 file changed

+92
-7
lines changed

1 file changed

+92
-7
lines changed

README.md

Lines changed: 92 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<img src= "https://github.com/icsl-Jeon/traj_gen/blob/master/img/logo2.png" width="300" >
22

33
## traj_gen : a continuous trajectory generation with simple API (C++/Matlab)
4-
### Version 2.0.1 (Mar 18, 2020)
4+
### Version 2.1.0 (Mar 22, 2020)
55
<img src = "https://travis-ci.com/icsl-Jeon/traj_gen.svg?branch=master"> <img src = "https://img.shields.io/github/license/Naereen/StrapDown.js.svg">
66
<img src=https://img.shields.io/github/v/release/icsl-Jeon/traj_gen?include_prereleases >
77

@@ -12,9 +12,8 @@
1212
<p align = "center">
1313
<img src= "https://github.com/icsl-Jeon/traj_gen/blob/master/img/tutorial.gif">
1414
</p>
15-
1615
*traj_gen* is a continuous trajectory generation package where <u>high order derivatives</u>
17-
along the trajectory are minimized while satisfying waypoints (equality) and axis-parallel box constraint (inequality). The objective and constraints are formulated in *quadratic programming* (QP) to cater the real-time performance. The whole code is written in C++ and Matlab (go to [submodule](https://github.com/icsl-Jeon/traj_gen-matlab) for its API). The C++ API was tested in Ubuntu 14.04/16.04/18.04. ROS wrapper is still developing to provide similar interface with [version 1](https://github.com/icsl-Jeon/traj_gen/tree/deprecated-version1).
16+
along the trajectory are minimized while satisfying waypoints (equality) and axis-parallel box constraint (inequality). The objective and constraints are formulated in *quadratic programming* (QP) to cater the real-time performance. The whole code is written in C++ and Matlab (go to [submodule](https://github.com/icsl-Jeon/traj_gen-matlab) for its API). The C++ API was tested in Ubuntu 14.04/16.04/18.04.
1817

1918
- To parameterize a trajectory, we use two types of curve: 1) **piecewise-polynomials** [1,2] and 2) **a sequence of points** [3].
2019
The difference is optimization variables.
@@ -26,8 +25,8 @@ The difference is optimization variables.
2625
and *loose-pin* denotes a axis-parallel box constraint. The pin is a triplets (time (t), order of derivatives (d), value (x)) where x is
2726
a vector in case of fix-pin while two vectors [xl xu] for the loose-pin.
2827

29-
- We implemented traj_gen in Matlab and C++(upcoming ~ the end of Mar). In case of 2D trajectory generation in Matlab, we provide interactive pin selection (see poly_example/main2D).
30-
Also, we plan to provide ROS support such as the [previous version](https://github.com/icsl-Jeon/traj_gen)
28+
- We implemented traj_gen in Matlab and C++. In case of 2D trajectory generation in Matlab, we provide interactive pin selection (see poly_example/main2D).
29+
Also, we plan to provide ROS support (~end of Mar) such as the [previous version](https://github.com/icsl-Jeon/traj_gen)
3130

3231

3332
## Getting started
@@ -46,7 +45,7 @@ Also, we plan to provide ROS support such as the [previous version](https://gith
4645
$ mkdir build && cd build
4746
$ cmake .. -DCMAKE_CXX_FLAGS=-fPIC
4847
$ sudo make install
49-
```
48+
```
5049
- **Build traj_gen (C++)**
5150
```
5251
$ git clone https://github.com/icsl-Jeon/traj_gen.git
@@ -64,6 +63,9 @@ Also, we plan to provide ROS support such as the [previous version](https://gith
6463
$ ./test_pin
6564
```
6665
### 2. C++ API quick start
66+
67+
### (1) Basic example (PolyTrajGen class)
68+
6769
```cpp
6870
#include <traj_gen2/TrajGen.hpp>
6971
#include <iostream>
@@ -110,7 +112,83 @@ int main(){
110112

111113
```
112114

115+
116+
117+
### (2) Advanced example (PolyTrajGen + OptimTrajGen)
118+
119+
```cpp
120+
#include <traj_gen2/TrajGen.hpp>
121+
#include <iostream>
122+
#include <chrono>
123+
124+
using namespace trajgen;
125+
using namespace Eigen;
126+
using Type = double ;
127+
128+
int main(){
129+
// 1. Prameter setting
130+
// common
131+
const int dim = 3;
132+
time_knots<Type> ts{0,2,4,7};
133+
Vector<Type,3> objWeights(0,1,1);
134+
135+
// polyTrajGen
136+
uint poly_order = 8, max_conti = 4;
137+
PolyParam pp(poly_order,max_conti,ALGORITHM::END_DERIVATIVE); // or ALGORITHM::POLY_COEFF
138+
// optimTrajGen
139+
Type pntDensity = 5;
140+
141+
// 2. Pin
142+
// 2.1 FixPin
143+
FixPin<Type,dim> x1(0.0f,0,Vector<Type,dim>(0,0,0));
144+
FixPin<Type,dim> x2(2.0f,0,Vector<Type,dim>(2,-1,2));
145+
FixPin<Type,dim> x3(4.0f,0,Vector<Type,dim>(5,3,4));
146+
FixPin<Type,dim> x4(7.0f,0,Vector<Type,dim>(7,-5,5));
147+
148+
FixPin<Type,dim> xdot0(0.0f,1,Vector<Type,dim>(0,0,0));
149+
FixPin<Type,dim> xddot0(0.0f,2,Vector<Type,dim>(0,0,0));
150+
151+
// 2.2 LoosePin
152+
LoosePin<Type,dim> passCube(3.0f,0,Vector<Type,dim>(3,-3,1),Vector<Type,dim>(4.2,-2,2));
153+
154+
std::vector<Pin<Type,dim>*> pinSet{&x1,&x2,&x3,&x4,&xdot0,&xddot0,&passCube}; // to prevent downcasting slicing, vector of pointers
155+
156+
// Let's test the two trajGen class
157+
TrajGen<Type,dim>** pTrajGenSet = new TrajGen<Type,dim>*[2];
158+
pTrajGenSet[0] = new PolyTrajGen<Type,dim>(ts,pp);
159+
pTrajGenSet[1] = new OptimTrajGen<Type,dim>(ts,pntDensity);
160+
bool verbose = false;
161+
bool isSolved = false;
162+
string TrajGenClass[2] = {"PolyTraj","OptimTraj"};
163+
164+
Type t_eval = 3; d_order d_eval = 1;
165+
166+
for (uint i = 0 ; i <2 ; i++) {
167+
auto begin = std::chrono::steady_clock::now();
168+
pTrajGenSet[i]->setDerivativeObj(objWeights);
169+
pTrajGenSet[i]->addPinSet(pinSet);
170+
isSolved = pTrajGenSet[i]->solve(verbose);
171+
printf("For %s, The evaluated value for (t=%.2f, d=%d) : ",TrajGenClass[i].c_str(),t_eval,d_eval);
172+
if (isSolved)
173+
cout << pTrajGenSet[i]->eval(t_eval,d_eval).transpose() << endl;
174+
else
175+
cout << "Failed. " << endl;
176+
177+
auto end= std::chrono::steady_clock::now();
178+
179+
std::cout << "Total time : " <<
180+
std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count()*1e-3 << "[ms]" << std::endl;
181+
}
182+
return 0;
183+
184+
}
185+
186+
```
187+
188+
189+
113190
### 3. Using traj_gen in your cmake project (CMakeLists.txt)
191+
114192
```
115193
find_package(TrajGen REQUIRED)
116194
...
@@ -136,11 +214,18 @@ target_link_libraries( your_exe .... traj_gen )
136214

137215
- *Maximum continuity* : the maximally imposed continuity order between neighboring segements. Higher value of this parameter enhances the quality of smoothness. However, too high value of this value restricts the dof for optimization, downgrading the opitimization result.
138216

139-
140217
- **optimTrajGen**
141218
- *Point density* : the number of posed points per time [s]. For long-ranged trajectory, thus, the total number of variables will increase leading to the burden of the optimization.
142219

220+
### Public methods
221+
222+
- Please run the following command to open the dedicated doxygen:
143223

224+
```
225+
firefox cpp/docs/html/index.html
226+
```
227+
228+
144229

145230
### Reference
146231

0 commit comments

Comments
 (0)