angle_to_stroke.cpp
Go to the documentation of this file.
1 /*
2  * This file auto-generated from script. Do not Edit!
3  * Original : aero_startup/.templates/aero_hardware_interface/Angle2Stroke.hh
4  * Original : aero_description/{my_robot}/headers/Angle2Stroke.hh
5 */
6 
7 #include <vector>
8 #include <algorithm>
9 #include <stdint.h>
10 #include <math.h> // for M_PI
11 #include "angle_to_stroke.h"
12 
13 namespace noid
14 {
15  namespace common
16  {
17 
18 
20 
21  float ShoulderPitchTable (float _angle)
22  {
23  int roundedAngle = static_cast<int>(_angle);
24  if (_angle > roundedAngle + 0.001) ++roundedAngle;
25  int roundedAngleIndex = roundedAngle - ArrayShoulderPitchTableOffset;
26  auto ref = ShoulderPitchTableMap.at(roundedAngleIndex);
27  float stroke = ref.first;
28  float interval = ref.second;
29 
30 
32  return stroke - (roundedAngle - _angle) * interval;
33  }
34  float ShoulderRollTable (float _angle)
35  {
36  int roundedAngle = static_cast<int>(_angle);
37  if (_angle > roundedAngle + 0.001) ++roundedAngle;
38  int roundedAngleIndex = roundedAngle - ArrayShoulderRollTableOffset;
39  auto ref = ShoulderRollTableMap.at(roundedAngleIndex);
40  float stroke = ref.first;
41  float interval = ref.second;
42 
43 
45  return stroke - (roundedAngle - _angle) * interval;
46  }
47  float ElbowPitchTable (float _angle)
48  {
49  int roundedAngle = static_cast<int>(_angle);
50  if (_angle > roundedAngle + 0.001) ++roundedAngle;
51  int roundedAngleIndex = roundedAngle - ArrayElbowPitchTableOffset;
52  auto ref = ElbowPitchTableMap.at(roundedAngleIndex);
53  float stroke = ref.first;
54 
56  float interval = ref.second;
57 
58  return stroke - (roundedAngle - _angle) * interval;
59  }
60  dualJoint WristRollPitchTable (float _angle1, float _angle2)
61  {
62  int roundedAngle1 = static_cast<int>(_angle1);
63  if (_angle1 > roundedAngle1 + 0.001) ++roundedAngle1;
64 
65  int roundedAngle2 = static_cast<int>(_angle2);
66  if (_angle2 > roundedAngle2 + 0.001) ++roundedAngle2;
67 
68  int roundedAngleIndex1 = roundedAngle1 - ArrayWristRollPitchTableOffset1;
69  int roundedAngleIndex2 = roundedAngle2 - ArrayWristRollPitchTableOffset2;
70  auto ref1 = WristRollPitchTableMap1.at(roundedAngleIndex1);
71  auto ref2 = WristRollPitchTableMap2.at(roundedAngleIndex2);
72  float stroke1 = ref1.first, stroke2 = ref2.first;
73  float interval1 = ref1.second, interval2 = ref2.second;
74 
75  stroke1 -= (roundedAngle1 - _angle1) * interval1;
76 
78  stroke2 -= (roundedAngle2 - _angle2) * interval2;
79 
80  return {stroke2 + stroke1, stroke2 - stroke1} ;
81  }
82  dualJoint WaistRollPitchTable (float _angle1, float _angle2)
83  {
84  int roundedAngle1 = static_cast<int>(_angle1);
85  if (_angle1 > roundedAngle1 + 0.001) ++roundedAngle1;
86 
87  int roundedAngle2 = static_cast<int>(_angle2);
88  if (_angle2 > roundedAngle2 + 0.001) ++roundedAngle2;
89 
90  int roundedAngleIndex1 = roundedAngle1 - ArrayWaistRollPitchTableOffset1;
91  int roundedAngleIndex2 = roundedAngle2 - ArrayWaistRollPitchTableOffset2;
92  auto ref1 = WaistRollPitchTableMap1.at(roundedAngleIndex1);
93  auto ref2 = WaistRollPitchTableMap2.at(roundedAngleIndex2);
94  float stroke1 = ref1.first, stroke2 = ref2.first;
95  float interval1 = ref1.second, interval2 = ref2.second;
96 
97  stroke1 -= (roundedAngle1 - _angle1) * interval1;
98 
100  stroke2 -= (roundedAngle2 - _angle2) * interval2;
101 
102  return {stroke2 + stroke1, stroke2 - stroke1} ;
103  }
104  dualJoint NeckRollPitchTable (float _angle1, float _angle2)
105  {
106  int roundedAngle1 = static_cast<int>(_angle1);
107  if (_angle1 > roundedAngle1 + 0.001) ++roundedAngle1;
108 
109  int roundedAngle2 = static_cast<int>(_angle2);
110  if (_angle2 > roundedAngle2 + 0.001) ++roundedAngle2;
111 
112  int roundedAngleIndex1 = roundedAngle1 - ArrayNeckRollPitchTableOffset1;
113  int roundedAngleIndex2 = roundedAngle2 - ArrayNeckRollPitchTableOffset2;
114  auto ref1 = NeckRollPitchTableMap1.at(roundedAngleIndex1);
115  auto ref2 = NeckRollPitchTableMap2.at(roundedAngleIndex2);
116  float stroke1 = ref1.first, stroke2 = ref2.first;
117  float interval1 = ref1.second, interval2 = ref2.second;
118 
119  stroke1 -= (roundedAngle1 - _angle1) * interval1;
120  stroke2 -= (roundedAngle2 - _angle2) * interval2;
121 
122 
124  return {stroke2 + stroke1, stroke2 - stroke1} ;
125  }
126  float LegTable (float _angle)
127  {
128  int roundedAngle = static_cast<int>(_angle);
129  if (_angle > roundedAngle + 0.001) ++roundedAngle;
130  int roundedAngleIndex = roundedAngle - ArrayLegTableOffset;
131  auto ref = LegTableMap.at(roundedAngleIndex);
132  float stroke = ref.first;
133  float interval = ref.second;
134 
135  return stroke - (roundedAngle - _angle) * interval;
136  }
137 
138 
139  }
140 }
141 
float ElbowPitchTable(float _angle)
static const std::vector< std::pair< float, float > > WaistRollPitchTableMap2
static const std::vector< std::pair< float, float > > WaistRollPitchTableMap1
static const int ArrayNeckRollPitchTableOffset1
static const std::vector< std::pair< float, float > > ShoulderPitchTableMap
static const std::vector< std::pair< float, float > > NeckRollPitchTableMap1
static const std::vector< std::pair< float, float > > NeckRollPitchTableMap2
float ShoulderPitchTable(float _angle)
static const int ArrayShoulderPitchTableOffset
static const int ArrayNeckRollPitchTableOffset2
static const int ArrayWristRollPitchTableOffset2
static const int ArrayShoulderRollTableOffset
static const std::vector< std::pair< float, float > > WristRollPitchTableMap2
dualJoint WaistRollPitchTable(float _angle1, float _angle2)
static const int ArrayWristRollPitchTableOffset1
static const int ArrayLegTableOffset
static const int ArrayWaistRollPitchTableOffset2
float ShoulderRollTable(float _angle)
float LegTable(float _angle)
static const std::vector< std::pair< float, float > > ShoulderRollTableMap
static const int ArrayElbowPitchTableOffset
dualJoint NeckRollPitchTable(float _angle1, float _angle2)
static const std::vector< std::pair< float, float > > ElbowPitchTableMap
static const int ArrayWaistRollPitchTableOffset1
static const std::vector< std::pair< float, float > > WristRollPitchTableMap1
dualJoint WristRollPitchTable(float _angle1, float _angle2)
static const std::vector< std::pair< float, float > > LegTableMap


noid_robot_interface
Author(s):
autogenerated on Sat Jul 20 2019 03:44:26