humotion / examples / yarp_icub / include / icub_jointinterface.h @ 18e9b892
History | View | Annotate | Download (3.792 KB)
1 | 8c6c1163 | Simon Schulz | #pragma once
|
---|---|---|---|
2 | #include <humotion/server/joint_interface.h> |
||
3 | #include <boost/bimap.hpp> |
||
4 | #include <yarp/dev/PolyDriver.h> |
||
5 | ea7a702d | Simon Schulz | #include <yarp/dev/IControlMode.h> |
6 | 8c6c1163 | Simon Schulz | #include <yarp/dev/IControlLimits2.h> |
7 | #include <yarp/dev/ControlBoardInterfaces.h> |
||
8 | #include <yarp/os/Time.h> |
||
9 | #include <yarp/sig/Vector.h> |
||
10 | #include "icub_jointinterface.h" |
||
11 | #include <humotion/server/server.h> |
||
12 | #include <yarp/os/Network.h> |
||
13 | #include <yarp/os/RateThread.h> |
||
14 | #include <yarp/os/Time.h> |
||
15 | #include <yarp/os/Property.h> |
||
16 | #include <yarp/os/Port.h> |
||
17 | #include <yarp/dev/ControlBoardInterfaces.h> |
||
18 | #include "icub_data_receiver.h" |
||
19 | |||
20 | class iCubDataReceiver; |
||
21 | 0d0f5ca1 | Simon Schulz | class iCubFaceInterface; |
22 | 8c6c1163 | Simon Schulz | |
23 | class iCubJointInterface : public humotion::server::JointInterface{ |
||
24 | public:
|
||
25 | iCubJointInterface(std::string scope); |
||
26 | ~iCubJointInterface(); |
||
27 | |||
28 | ea29304b | Simon Schulz | //void store_incoming_position(int humotion_id, double position, double timestamp);
|
29 | //void store_incoming_velocity(int humotion_id, double position, double timestamp);
|
||
30 | 8c6c1163 | Simon Schulz | void run();
|
31 | |||
32 | 35b3ca25 | Simon Schulz | int convert_icub_jointid_to_humotion(int id); |
33 | int convert_humotion_jointid_to_icub(int id); |
||
34 | |||
35 | 8c6c1163 | Simon Schulz | enum JOINT_ID_ENUM{
|
36 | ICUB_ID_NECK_TILT = 0,
|
||
37 | ICUB_ID_NECK_ROLL = 1,
|
||
38 | ICUB_ID_NECK_PAN = 2,
|
||
39 | ICUB_ID_EYES_BOTH_UD = 3,
|
||
40 | ICUB_ID_EYES_PAN = 4,
|
||
41 | ICUB_ID_EYES_VERGENCE = 5,
|
||
42 | ICUB_ID_EYES_LEFT_LID_LOWER, |
||
43 | ICUB_ID_EYES_LEFT_LID_UPPER, |
||
44 | ICUB_ID_EYES_RIGHT_LID_LOWER, |
||
45 | ICUB_ID_EYES_RIGHT_LID_UPPER, |
||
46 | ICUB_ID_EYES_LEFT_BROW, |
||
47 | ICUB_ID_EYES_RIGHT_BROW, |
||
48 | ICUB_ID_LIP_LEFT_UPPER, |
||
49 | ICUB_ID_LIP_LEFT_LOWER, |
||
50 | ICUB_ID_LIP_CENTER_UPPER, |
||
51 | ICUB_ID_LIP_CENTER_LOWER, |
||
52 | ICUB_ID_LIP_RIGHT_UPPER, |
||
53 | ICUB_ID_LIP_RIGHT_LOWER, |
||
54 | ICUB_JOINT_ID_ENUM_SIZE |
||
55 | }; |
||
56 | |||
57 | 35b3ca25 | Simon Schulz | yarp::dev::PolyDriver *get_yarp_polydriver() { return &yarp_polydriver_; }
|
58 | |||
59 | 8c6c1163 | Simon Schulz | static const int MAIN_LOOP_FREQUENCY = 50; |
60 | |||
61 | protected:
|
||
62 | void disable_joint(int e); |
||
63 | 35b3ca25 | Simon Schulz | void publish_target(int e, float position, float velocity); |
64 | 8c6c1163 | Simon Schulz | void enable_joint(int e); |
65 | void execute_motion();
|
||
66 | |||
67 | private:
|
||
68 | 35b3ca25 | Simon Schulz | yarp::dev::PolyDriver yarp_polydriver_; |
69 | |||
70 | std::vector<double> pv_mix_last_error_;
|
||
71 | std::vector<double> pv_mix_pid_p_;
|
||
72 | std::vector<double> pv_mix_pid_d_;
|
||
73 | |||
74 | // yarp views
|
||
75 | yarp::dev::IVelocityControl *yarp_ivel_; |
||
76 | 372eec67 | Simon Schulz | //yarp::dev::IPositionControl *yarp_ipos_;
|
77 | 1f748ce7 | Simon Schulz | |
78 | 35b3ca25 | Simon Schulz | //yarp::dev::IEncodersTimed *yarp_iencs_;
|
79 | yarp::dev::IControlLimits *yarp_ilimits_; |
||
80 | yarp::dev::IAmplifierControl *yarp_amp_; |
||
81 | yarp::dev::IPidControl *yarp_pid_; |
||
82 | yarp::dev::IControlMode *yarp_icontrol_; |
||
83 | |||
84 | yarp::sig::Vector yarp_commands_; |
||
85 | |||
86 | float target_angle_[ICUB_JOINT_ID_ENUM_SIZE];
|
||
87 | float target_velocity_[ICUB_JOINT_ID_ENUM_SIZE];
|
||
88 | |||
89 | |||
90 | void init_controller();
|
||
91 | void init_id_map();
|
||
92 | void init_pv_mix_pid();
|
||
93 | void insert_icupid_to_humotionid_mapping(int icubid, int humotionid); |
||
94 | |||
95 | |||
96 | void store_icub_joint_target(int icub_id, float position, float velocity); |
||
97 | |||
98 | //*******************************************
|
||
99 | |||
100 | |||
101 | ea7a702d | Simon Schulz | void set_joint_enable_state(int e, bool enabled); |
102 | 35b3ca25 | Simon Schulz | //double target_angle[ICUB_JOINT_ID_ENUM_SIZE];
|
103 | //double target_angle_previous[ICUB_JOINT_ID_ENUM_SIZE];
|
||
104 | 8c6c1163 | Simon Schulz | |
105 | iCubDataReceiver *icub_data_receiver; |
||
106 | void init_joints();
|
||
107 | |||
108 | std::string scope; |
||
109 | 1f748ce7 | Simon Schulz | //yarp::sig::Vector positions;
|
110 | //yarp::sig::Vector velocities;
|
||
111 | 35b3ca25 | Simon Schulz | |
112 | 8c6c1163 | Simon Schulz | |
113 | 372eec67 | Simon Schulz | void store_min_max(yarp::dev::IControlLimits *ilimits, int icub_id); |
114 | 8c6c1163 | Simon Schulz | |
115 | 1f748ce7 | Simon Schulz | //float last_pos_eye_vergence;
|
116 | //float last_pos_eye_pan;
|
||
117 | // float last_vel_eye_vergence;
|
||
118 | //float last_vel_eye_pan;
|
||
119 | 8c6c1163 | Simon Schulz | |
120 | 372eec67 | Simon Schulz | //void store_joint(int id, float value);
|
121 | 87b50988 | Simon Schulz | void set_target_in_velocitymode(int id); |
122 | 8c6c1163 | Simon Schulz | |
123 | |||
124 | 1f748ce7 | Simon Schulz | //int convert_enum_to_motorid(int e);
|
125 | //int convert_motorid_to_enum(int id);
|
||
126 | 8c6c1163 | Simon Schulz | |
127 | 35b3ca25 | Simon Schulz | iCubFaceInterface *face_interface_; |
128 | 8c6c1163 | Simon Schulz | |
129 | typedef boost::bimap<int, int > enum_id_bimap_t; |
||
130 | typedef enum_id_bimap_t::value_type enum_id_bimap_entry_t;
|
||
131 | enum_id_bimap_t enum_id_bimap; |
||
132 | }; |