Revision 25400c71
examples/yarp_icub/include/humotion_yarp_icub/icub_data_receiver.h | ||
---|---|---|
25 | 25 |
* Excellence Initiative. |
26 | 26 |
*/ |
27 | 27 |
|
28 |
#ifndef EXAMPLES_HUMOTION_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_DATA_RECEIVER_H_
|
|
29 |
#define EXAMPLES_HUMOTION_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_DATA_RECEIVER_H_
|
|
28 |
#ifndef EXAMPLES_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_DATA_RECEIVER_H_ |
|
29 |
#define EXAMPLES_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_DATA_RECEIVER_H_ |
|
30 | 30 |
|
31 | 31 |
#include <humotion/server/joint_interface.h> |
32 | 32 |
#include <humotion/server/server.h> |
... | ... | |
54 | 54 |
void run(); |
55 | 55 |
|
56 | 56 |
private: |
57 |
void store_incoming_position(int icub_id, double value, double timestamp);
|
|
58 |
void store_incoming_velocity(int icub_id, double velocity, double timestamp);
|
|
57 |
void store_incoming_position(int icub_id, double value, humotion::Timestamp timestamp);
|
|
58 |
void store_incoming_velocity(int icub_id, double velocity, humotion::Timestamp timestamp);
|
|
59 | 59 |
yarp::sig::Vector calculate_velocities(yarp::sig::Vector positions, |
60 | 60 |
yarp::sig::Vector timestamps); |
61 | 61 |
|
... | ... | |
79 | 79 |
yarp::dev::IEncodersTimed *iencs_; |
80 | 80 |
}; |
81 | 81 |
|
82 |
#endif // EXAMPLES_HUMOTION_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_DATA_RECEIVER_H_ |
|
82 |
#endif // EXAMPLES_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_DATA_RECEIVER_H_ |
examples/yarp_icub/include/humotion_yarp_icub/icub_faceinterface.h | ||
---|---|---|
24 | 24 |
* Forschungsgemeinschaft (DFG) in the context of the German |
25 | 25 |
* Excellence Initiative. |
26 | 26 |
*/ |
27 |
#ifndef EXAMPLES_HUMOTION_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_FACEINTERFACE_H_
|
|
28 |
#define EXAMPLES_HUMOTION_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_FACEINTERFACE_H_
|
|
27 |
#ifndef EXAMPLES_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_FACEINTERFACE_H_ |
|
28 |
#define EXAMPLES_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_FACEINTERFACE_H_ |
|
29 | 29 |
|
30 | 30 |
#include "humotion_yarp_icub/icub_jointinterface.h" |
31 | 31 |
|
... | ... | |
53 | 53 |
yarp::os::BufferedPort<yarp::os::Bottle> emotion_port; |
54 | 54 |
}; |
55 | 55 |
|
56 |
#endif // EXAMPLES_HUMOTION_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_FACEINTERFACE_H_ |
|
56 |
#endif // EXAMPLES_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_FACEINTERFACE_H_ |
examples/yarp_icub/include/humotion_yarp_icub/icub_jointinterface.h | ||
---|---|---|
25 | 25 |
* Excellence Initiative. |
26 | 26 |
*/ |
27 | 27 |
|
28 |
#ifndef EXAMPLES_HUMOTION_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_JOINTINTERFACE_H_
|
|
29 |
#define EXAMPLES_HUMOTION_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_JOINTINTERFACE_H_
|
|
28 |
#ifndef EXAMPLES_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_JOINTINTERFACE_H_ |
|
29 |
#define EXAMPLES_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_JOINTINTERFACE_H_ |
|
30 | 30 |
|
31 | 31 |
#include "humotion_yarp_icub/icub_data_receiver.h" |
32 | 32 |
|
... | ... | |
140 | 140 |
enum_id_bimap_t enum_id_bimap; |
141 | 141 |
}; |
142 | 142 |
|
143 |
#endif // EXAMPLES_HUMOTION_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_JOINTINTERFACE_H_ |
|
143 |
#endif // EXAMPLES_YARP_ICUB_INCLUDE_HUMOTION_YARP_ICUB_ICUB_JOINTINTERFACE_H_ |
examples/yarp_icub/src/icub_data_receiver.cpp | ||
---|---|---|
36 | 36 |
using std::cout; |
37 | 37 |
using std::cerr; |
38 | 38 |
using std::string; |
39 |
|
|
39 | 40 |
using humotion::server::JointInterface; |
41 |
using humotion::Timestamp; |
|
42 |
|
|
40 | 43 |
using yarp::dev::IEncodersTimed; |
41 | 44 |
using yarp::sig::Vector; |
42 | 45 |
|
... | ... | |
108 | 111 |
//! main loop routine, called by yarp rate thread |
109 | 112 |
void iCubDataReceiver::run() { |
110 | 113 |
float velocity; |
114 |
Timestamp timestamp; |
|
111 | 115 |
|
112 | 116 |
// grab pos+vel data: |
113 | 117 |
iencs_->getEncodersTimed(positions_.data(), timestamps_.data()); |
... | ... | |
125 | 129 |
|
126 | 130 |
// publish data to humotion |
127 | 131 |
for (int i = 0; i < positions_.size(); i++) { |
132 |
// convert to humotion timestamp |
|
133 |
timestamp = Timestamp(timestamps_[i]); |
|
128 | 134 |
// store position values |
129 |
store_incoming_position(i, positions_[i], timestamps_[i]);
|
|
135 |
store_incoming_position(i, positions_[i], timestamp); |
|
130 | 136 |
// store velocity |
131 |
store_incoming_velocity(i, velocities_[i], timestamps_[i]);
|
|
137 |
store_incoming_velocity(i, velocities_[i], timestamp); |
|
132 | 138 |
} |
133 | 139 |
|
134 | 140 |
// small hack to tell humotion to update the lid angle |
135 | 141 |
// fixme: use real id |
136 |
store_incoming_position(100, 0.0, timestamps_[0]); |
|
142 |
timestamp = Timestamp::now(); |
|
143 |
store_incoming_position(100, 0.0, timestamp); |
|
137 | 144 |
|
138 | 145 |
#if ICUB_DATA_RECEIVER_DUMP_DATA |
139 | 146 |
dump_incoming_data(); |
... | ... | |
144 | 151 |
//! \param icub _id icub joint id |
145 | 152 |
//! \param position |
146 | 153 |
//! \param timestamp |
147 |
void iCubDataReceiver::store_incoming_position(int icub_id, double position, double timestamp) {
|
|
154 |
void iCubDataReceiver::store_incoming_position(int icub_id, double position, Timestamp timestamp) {
|
|
148 | 155 |
// cout << "store_incoming_position(icub=" << icub_id << ", " << position << ")\n"; |
149 | 156 |
|
150 | 157 |
// store joint position in humotion backend |
... | ... | |
167 | 174 |
icub_jointinterface_->store_incoming_position(JointInterface::ID_EYES_RIGHT_LR, |
168 | 175 |
right, timestamp); |
169 | 176 |
} else if (icub_id == 100) { |
170 |
//HACK |
|
177 |
// HACK
|
|
171 | 178 |
// icub_jointinterface->store_incoming_position(ID_EYES_RIGHT_LID_UPPER, |
172 | 179 |
// lid_angle, timestamp); |
173 | 180 |
} else { |
... | ... | |
186 | 193 |
//! \param icub_id icub joint id |
187 | 194 |
//! \param velocity |
188 | 195 |
//! \param timestamp |
189 |
void iCubDataReceiver::store_incoming_velocity(int icub_id, double velocity, double timestamp) {
|
|
196 |
void iCubDataReceiver::store_incoming_velocity(int icub_id, double velocity, Timestamp timestamp) {
|
|
190 | 197 |
// cout << "store_incoming_velocity(icub=" << icub_id << ", " << velocity << ")\n"; |
191 | 198 |
|
192 | 199 |
// store joint position in humotion backend |
... | ... | |
209 | 216 |
icub_jointinterface_->store_incoming_velocity(JointInterface::ID_EYES_RIGHT_LR, |
210 | 217 |
right, timestamp); |
211 | 218 |
} else if (icub_id == 100) { |
212 |
//HACK |
|
219 |
// HACK
|
|
213 | 220 |
// icub_jointinterface->store_incoming_position(ID_EYES_RIGHT_LID_UPPER, |
214 | 221 |
// lid_angle, timestamp); |
215 | 222 |
} else { |
examples/yarp_icub/src/icub_faceinterface.cpp | ||
---|---|---|
105 | 105 |
//! \param id {0=left, 1=right) |
106 | 106 |
//! \param angle in degrees |
107 | 107 |
void iCubFaceInterface::set_eyebrow_angle(int id, float *target_angle) { |
108 |
|
|
109 | 108 |
if (emotion_port.getOutputCount() > 0) { |
110 | 109 |
double angle = target_angle[id]; |
111 | 110 |
int icub_val = 0; |
examples/yarp_icub/src/icub_jointinterface.cpp | ||
---|---|---|
197 | 197 |
//! \param id of joint |
198 | 198 |
//! \param float value of position |
199 | 199 |
void iCubJointInterface::store_icub_joint_target(int icub_id, float position, float velocity) { |
200 |
//cout << "store_icub_joint_target(" << icub_id << ", " << position << ", ..)\n"; |
|
200 |
// cout << "store_icub_joint_target(" << icub_id << ", " << position << ", ..)\n";
|
|
201 | 201 |
|
202 | 202 |
if ((icub_id == ICUB_ID_NECK_PAN) || (icub_id == ICUB_ID_EYES_VERGENCE)) { |
203 | 203 |
// icub uses an inverted neck pan specification |
... | ... | |
332 | 332 |
// send it to icub face if |
333 | 333 |
face_interface_->set_eyelid_angle(opening); |
334 | 334 |
|
335 |
//eyebrows are set using a special command as well: |
|
335 |
// eyebrows are set using a special command as well:
|
|
336 | 336 |
face_interface_->set_eyebrow_angle(ICUB_ID_EYES_LEFT_BROW, target_angle_); |
337 | 337 |
face_interface_->set_eyebrow_angle(ICUB_ID_EYES_RIGHT_BROW, target_angle_); |
338 | 338 |
|
339 |
//mouth |
|
339 |
// mouth
|
|
340 | 340 |
face_interface_->set_mouth(target_angle_); |
341 | 341 |
|
342 | 342 |
// store joint values which we do not handle on icub here: |
343 |
double timestamp = humotion::Timestamp::now().to_seconds(); |
|
343 |
humotion::Timestamp timestamp = humotion::Timestamp::now(); |
|
344 |
|
|
344 | 345 |
JointInterface::store_incoming_position(ID_LIP_LEFT_UPPER, |
345 | 346 |
target_angle_[ICUB_ID_LIP_LEFT_UPPER], timestamp); |
346 | 347 |
JointInterface::store_incoming_position(ID_LIP_LEFT_LOWER, |
Also available in: Unified diff