- 3.0.2 rigid body dynamics module.
plotResultsTrajectories.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 template <size_t NJOINTS>
10 {
11 #ifdef PLOTTING_ENABLED
12 
13  using namespace ct::core;
14 
15  try
16  {
17  plot::ion();
18  plot::figure();
19 
20  for (size_t jointId = 0; jointId < NJOINTS; jointId++)
21  {
22  std::vector<double> position;
23  std::vector<double> velocity;
24  std::vector<double> time_state;
25  for (size_t j = 0; j < stateTraj.getDataArray().size(); j++)
26  {
27  position.push_back(stateTraj.getDataArray()[j](jointId));
28  velocity.push_back(stateTraj.getDataArray()[j](jointId + 6));
29  time_state.push_back(stateTraj.getTimeArray()[j]);
30  }
31 
32 
33  plot::subplot(NJOINTS, 2, 2 * jointId + 1);
34  plot::plot(time_state, position);
35  plot::title("position");
36 
37  plot::subplot(NJOINTS, 2, 2 * jointId + 2);
38  plot::plot(time_state, velocity);
39  plot::title("velocity");
40  }
41  plot::show();
42  } catch (const std::exception& e)
43  {
44  std::cout << e.what() << std::endl;
45  }
46 #else
47  std::cout << "Plotting is disabled." << std::endl;
48 #endif
49 }
bool plot(const Eigen::Ref< const Eigen::MatrixXd > &x, const Eigen::Ref< const Eigen::MatrixXd > &y, const std::map< std::string, std::string > &keywords)
void show(bool block=true)
DiscreteArray< T, Alloc > & getDataArray()
void title(const std::string &titlestr)
tpl::TimeArray< SCALAR > & getTimeArray()
void plotResultsTrajectories(const ct::core::StateTrajectory< 2 *NJOINTS > &stateTraj)
Definition: plotResultsTrajectories.h:9
bool subplot(const size_t nrows, const size_t ncols, const size_t plot_number)
bool figure(std::string i="")