typeg_arm/src/stroke_converter.cpp
Go to the documentation of this file.
2 #include "stroke_converter.h"
3 
5 {
6  ROS_INFO("upper's csv_dir is %s", upper_csv_dir.c_str());
7  ROS_INFO("lifter's csv_dir is %s", lifter_csv_dir.c_str());
8 
9  if (makeTable(shoulder_p.table, upper_csv_dir + "/shoulder_p.csv"))
11  if (makeTable(elbow_p.table, upper_csv_dir + "/elbow_p.csv"))
13  if (makeTable(wrist_p.table, upper_csv_dir + "/wrist_p.csv"))
15  if (makeTable(wrist_r.table, upper_csv_dir + "/wrist_r.csv"))
17 
18  if (makeTable(leg.table, lifter_csv_dir + "/leg.csv"))
20 }
21 
23 (std::vector<int16_t>& _strokes, const std::vector<double>& _angles)
24 {
25  static const float rad2Deg = 180.0 / M_PI;
26  static const float scale = 100.0;
27 
29  = setDualAngleToStroke(rad2Deg * _angles[5], rad2Deg * _angles[4],
30  wrist_r.table, wrist_p.table, false);
31 
32  _strokes[0] = static_cast<int16_t>(scale * rad2Deg * _angles[0]);
33  _strokes[1]
34  = static_cast<int16_t>(scale * setAngleToStroke(rad2Deg * _angles[1], shoulder_p.table));
35  _strokes[2]
36  = static_cast<int16_t>(scale * setAngleToStroke(rad2Deg * _angles[2], elbow_p.table));
37  _strokes[3] = static_cast<int16_t>(scale * rad2Deg * _angles[3]);
38  _strokes[4] = static_cast<int16_t>(scale * wrist.two);
39  _strokes[5] = static_cast<int16_t>(scale * wrist.one);
40  _strokes[6] = static_cast<int16_t>(scale * (-rad2Deg * _angles[6] + 50.0) * 0.18);
41 
42  _strokes[7]
43  = static_cast<int16_t>(scale * setAngleToStroke(- rad2Deg * _angles[7], leg.table)); //knee
44  _strokes[8]
45  = static_cast<int16_t>(scale * setAngleToStroke( rad2Deg * _angles[8], leg.table)); //ankle
46 
47 }
48 
50 (std::vector<double>& _angles, const std::vector<int16_t>& _strokes)
51 {
52  static const float deg2Rad = M_PI / 180.0;
53  static const float scale_inv = 0.01;
54 
55  _angles[0] = deg2Rad * scale_inv * _strokes[0];
56  _angles[1] = deg2Rad * setStrokeToAngle(scale_inv * _strokes[1], shoulder_p.inv_table);
57  _angles[2] = deg2Rad * setStrokeToAngle(scale_inv * _strokes[2], elbow_p.inv_table);
58  _angles[3] = deg2Rad * scale_inv * _strokes[3];
59  _angles[4]
60  = deg2Rad * setStrokeToAngle(scale_inv*(_strokes[5] + _strokes[4])*0.5, wrist_p.inv_table);
61  _angles[5]
62  = deg2Rad * setStrokeToAngle(scale_inv*(_strokes[5] - _strokes[4])*0.5, wrist_r.inv_table);
63  _angles[6] = -deg2Rad * (scale_inv * _strokes[6] * 5.556 - 50.0);
64 
65  _angles[7] = -deg2Rad * setStrokeToAngle(scale_inv * _strokes[7], leg.inv_table); // knee
66  _angles[8] = deg2Rad * setStrokeToAngle(scale_inv * _strokes[8], leg.inv_table); // ankle
67 
68 }
69 
std::vector< StrokeMap > table
void Angle2Stroke(std::vector< int16_t > &_strokes, const std::vector< double > &_angles)
bool makeTable(std::vector< StrokeMap > &_table, const std::string _file_name)
float setStrokeToAngle(const float _stroke, const std::vector< StrokeMap > &_inv_table)
std::vector< StrokeMap > inv_table
#define ROS_INFO(...)
void Stroke2Angle(std::vector< double > &_angles, const std::vector< int16_t > &_strokes)
float setAngleToStroke(const float _angle, const std::vector< StrokeMap > &_table)
DiffJoint setDualAngleToStroke(const float _r_angle, const float _p_angle, const std::vector< StrokeMap > &_r_table, const std::vector< StrokeMap > &_p_table, const bool _is_pitch=false)
PLUGINLIB_EXPORT_CLASS(transmission_interface::BiDirectionalEffortJointInterfaceProvider, transmission_interface::RequisiteProvider)
void makeInvTable(std::vector< StrokeMap > &_inv_table, const std::vector< StrokeMap > &_table)


seed_r7_robot_interface
Author(s): Kazuhiro Sasabuchi
autogenerated on Sun Apr 18 2021 02:40:36