Austin Schuh | 7400da0 | 2018-01-28 19:54:58 -0800 | [diff] [blame^] | 1 | /*! |
| 2 | @page getting_started Getting Started |
| 3 | |
| 4 | In order to get you started with using the Control Toolbox, there are several useful resources available. First make sure |
| 5 | you have installed the Control Toolbox as described in the \ref install_guide "Installation Guide". Afterwards you can |
| 6 | follow the Tutorials below. |
| 7 | |
| 8 | - \subpage tut_basics "Basics Tutorial" |
| 9 | - \subpage core_tutorials "ct core Tutorials" |
| 10 | - \subpage optcon_tutorials "ct optcon Tutorials" |
| 11 | - \subpage rbd_tutorials "ct rbd Tutorials" |
| 12 | |
| 13 | If you need additional support, feel free to create an issue on Bitbucket or contact the developers. |
| 14 | |
| 15 | \page tut_basics Basic Tutorial |
| 16 | @tableofcontents |
| 17 | |
| 18 | \section tut_basics_pkg Creating a ROS package |
| 19 | CT is middleware free. Therefore, you are not bound to use ROS or catkin. However, for the sake of simplicity we will use catkin in this tutorial. |
| 20 | Make sure you have succesfully downloaded and compiled CT according to our @ref gs instructions. Afterwards go to your catkin workspace |
| 21 | and create a new package |
| 22 | |
| 23 | \code{.sh} |
| 24 | cd ~/catkin_ws/src |
| 25 | catkin_create_pkg my_ct_project roscpp ct_core ct_rbd ct_optcon ct_models |
| 26 | \endcode |
| 27 | |
| 28 | In this example, we made \a my_ct_project dependent on all CT packages. This is not strictly necessary, however there is no harm to it either. |
| 29 | |
| 30 | |
| 31 | \section tut_basics_exec Creating our first executable |
| 32 | |
| 33 | First, we are going to simulate the dynamics of a damped oscillator. Let's create our main file |
| 34 | |
| 35 | \include DampedOscillator.cpp |
| 36 | |
| 37 | So what happens in this code? We first include ct/core.h. This includes all relevant headers from CT Core. Other CT modules have similar header files |
| 38 | such as \a ct/rbd.h . If you were to include ct/rbd.h you would not have to include ct/core.h anymore. It is automatically included. |
| 39 | |
| 40 | Then, we create a state vector and set it to zero. Afterwards, we can create a shared pointer to a ct::core::SecondOrderSystem |
| 41 | which is a damped oscillator. It is derived from type ct::core::System, which means we can directly plug it into a ct::core::Integrator. Here, we have many |
| 42 | choices such as ct::core::IntegratorEuler or ct::core::ODE45. Here, we chose a fourth-order Runge-Kutta integrator. We then simulate (integrate) it forward |
| 43 | for 1 second with a time step of 0.001 seconds. Finally, we print the new state. |
| 44 | |
| 45 | |
| 46 | \section tut_basics_system Creating our first system |
| 47 | In the example above, we have been using an oscillator that is provided with CT. However, we might want to model our own system. Here, we will model |
| 48 | a simple mass point subject to friction. However, if you are interested in more sophisticated models, especially Rigid Body Dynamics, make sure you |
| 49 | check out the tutorials in ct_rbd as well. |
| 50 | |
| 51 | First we create our system within a header Masspoint.h |
| 52 | |
| 53 | \include Masspoint.h |
| 54 | |
| 55 | As before, we can now integrate this system forward |
| 56 | |
| 57 | \include MasspointIntegration.cpp |
| 58 | |
| 59 | |
| 60 | */ |