Revision 4e9221c4
| src/server/joint_interface.cpp | ||
|---|---|---|
| 104 | 104 |
//! return the timestamped float for the given joints position |
| 105 | 105 |
TimestampedList JointInterface::get_ts_position(int joint_id){
|
| 106 | 106 |
//lock the tsd_list for this access. by doing this we assure |
| 107 |
//that no other thread accessing this element can diturb the |
|
| 107 |
//that no other thread accessing this element can disturb the
|
|
| 108 | 108 |
//following atomic instructions: |
| 109 | 109 |
mutex::scoped_lock scoped_lock(joint_ts_position_map_access_mutex); |
| 110 | 110 |
|
| src/server/server.cpp | ||
|---|---|---|
| 98 | 98 |
float loop_delay = 1000.0 / MOTION_UPDATERATE; |
| 99 | 99 |
boost::system_time timeout = get_system_time() + posix_time::milliseconds(loop_delay); |
| 100 | 100 |
|
| 101 |
//wait for incoming joint data: |
|
| 102 |
while (middleware->ok()){
|
|
| 103 |
//mw tick |
|
| 104 |
middleware->tick(); |
|
| 105 |
|
|
| 106 |
unsigned int incoming_data_count = joint_interface->get_and_clear_incoming_position_count(); |
|
| 107 |
if (incoming_data_count == 0){
|
|
| 108 |
incoming_data_count_invalid++; |
|
| 109 |
if (incoming_data_count_invalid >= MOTION_UPDATERATE){
|
|
| 110 |
printf("> waiting for joint data...\n");
|
|
| 111 |
incoming_data_count_invalid = 0; |
|
| 112 |
} |
|
| 113 |
}else{
|
|
| 114 |
//fine, joint data is arriving, exit waiting loop |
|
| 115 |
break; |
|
| 116 |
} |
|
| 117 |
|
|
| 118 |
thread::sleep(timeout); |
|
| 119 |
timeout = get_system_time() + posix_time::milliseconds(loop_delay); |
|
| 120 |
} |
|
| 121 |
|
|
| 122 |
//fine, data is arriving, activate and run control loop: |
|
| 101 | 123 |
while (middleware->ok()){
|
| 102 | 124 |
//mw tick |
| 103 | 125 |
middleware->tick(); |
Also available in: Unified diff