Revision 25400c71 examples/yarp_icub/src/icub_data_receiver.cpp
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 { |
Also available in: Unified diff