SampleData.h
Go to the documentation of this file.
1 #ifndef _RDL_BENCHMARK_SAMPLE_DATA_H__
2 #define _RDL_BENCHMARK_SAMPLE_DATA_H__
3 
5 
6 struct SampleData
7 {
8  SampleData() : count(0), q(NULL), qdot(NULL), qddot(NULL), tau(NULL)
9  {
10  }
11 
13  {
14  deleteData();
15  }
16 
17  SampleData(const SampleData &data)
18  {
19  count = data.count;
20 
25 
26  for(int si = 0; si < count; si++)
27  {
28  q[si] = data.q[si];
29  qdot[si] = data.qdot[si];
30  qddot[si] = data.qddot[si];
31  tau[si] = data.tau[si];
32  }
33  }
34 
36  {
37  if(this != &data)
38  {
39  deleteData();
40  *this = SampleData(data);
41  }
42  return *this;
43  }
44 
45  unsigned int count;
50 
51  void deleteData()
52  {
53  count = 0;
54 
55  if(q)
56  {
57  delete[] q;
58  }
59  q = NULL;
60 
61  if(qdot)
62  {
63  delete[] qdot;
64  }
65  qdot = NULL;
66 
67  if(qddot)
68  {
69  delete[] qddot;
70  }
71  qddot = NULL;
72 
73  if(tau)
74  {
75  delete[] tau;
76  }
77  tau = NULL;
78  }
79 
80  void fillRandom(int dof_count, int sample_count)
81  {
82  deleteData();
83  count = sample_count;
84 
89 
90  for(int si = 0; si < count; si++)
91  {
92  q[si].resize(dof_count);
93  qdot[si].resize(dof_count);
94  qddot[si].resize(dof_count);
95  tau[si].resize(dof_count);
96 
97  for(int i = 0; i < dof_count; i++)
98  {
99  q[si][i] = (static_cast<double>(rand()) / static_cast<double>(RAND_MAX)) * 2. - 1.;
100  qdot[si][i] = (static_cast<double>(rand()) / static_cast<double>(RAND_MAX)) * 2. - 1.;
101  qddot[si][i] = (static_cast<double>(rand()) / static_cast<double>(RAND_MAX)) * 2. - 1.;
102  tau[si][i] = (static_cast<double>(rand()) / static_cast<double>(RAND_MAX)) * 2. - 1.;
103  }
104  }
105  }
106 };
107 
108 #endif
RobotDynamics::Math::VectorNd * qddot
Definition: SampleData.h:48
SampleData()
Definition: SampleData.h:8
RobotDynamics::Math::VectorNd * tau
Definition: SampleData.h:49
Eigen::VectorXd VectorNd
unsigned int count
Definition: SampleData.h:45
SampleData & operator=(const SampleData &data)
Definition: SampleData.h:35
void deleteData()
Definition: SampleData.h:51
RobotDynamics::Math::VectorNd * q
Definition: SampleData.h:46
void fillRandom(int dof_count, int sample_count)
Definition: SampleData.h:80
SampleData(const SampleData &data)
Definition: SampleData.h:17
RobotDynamics::Math::VectorNd * qdot
Definition: SampleData.h:47


rdl_benchmark
Author(s):
autogenerated on Tue Apr 20 2021 02:25:39