35 roslib.load_manifest(
'dense_laser_assembler')
42 from roslib
import rostime
50 def __init__(self, req_callback, max_mech_len, max_laser_done_len, max_laser_wait_len) :
73 self._mech_lock.acquire()
74 self._mech_q.append(msg)
77 self._mech_lock.release()
80 self._laser_wait_lock.acquire()
81 self._laser_wait_q.append(msg)
83 self._laser_wait_q.pop(0)
84 self._laser_wait_lock.release()
91 self._mech_lock.acquire()
94 oldest_mech_time = self.
_mech_q[0].header.stamp
95 newest_mech_time = self.
_mech_q[-1].header.stamp
97 self._mech_lock.release()
100 self._laser_wait_lock.acquire()
102 scan_interval = [ (x.header.stamp,
104 x.header.stamp+rostime.Duration().from_seconds(len(x.ranges)*x.time_increment))
107 laser_pending_q = [x
for i,x
in enumerate(self.
_laser_wait_q)
108 if scan_interval[i][1] < newest_mech_time
and 109 scan_interval[i][0] > oldest_mech_time]
112 if scan_interval[i][1] >= newest_mech_time]
114 self._laser_wait_lock.release()
122 self._laser_done_lock.acquire()
125 self._laser_done_q.pop(0)
126 self._laser_done_lock.release()
127 self._mech_lock.release()
133 scan_end = scan_msg.header.stamp + rostime.Duration().from_seconds(len(scan_msg.ranges)*scan_msg.time_increment)
134 mech_before = [x
for x
in mech_q
if x.header.stamp < scan_msg.header.stamp][-1]
135 mech_after = [x
for x
in mech_q
if x.header.stamp > scan_end][0]
138 ind = [x.name
for x
in mech_before.joint_states].index(
'laser_tilt_mount_joint')
139 pos_before = mech_before.joint_states[ind].position
140 time_before= mech_before.header.stamp
143 ind = [x.name
for x
in mech_after.joint_states].index(
'laser_tilt_mount_joint')
144 pos_after = mech_after.joint_states[ind].position
145 time_after= mech_after.header.stamp
147 elapsed = (time_after - time_before).to_seconds()
153 key_rays = [0, len(scan_msg.ranges)-1]
154 time_during = [ scan_msg.header.stamp
155 + rostime.Duration().from_seconds(scan_msg.time_increment*x)
157 time_normalized = [ (x - time_before).to_seconds()/elapsed
for x
in time_during]
158 if any( [x > 1
for x
in time_normalized])
or any( [x < 0
for x
in time_normalized] ) :
159 print(
'Error computing normalized time')
160 pos_during = [ pos_before * (1-x) + pos_after * x
for x
in time_normalized ]
163 elem.pos = pos_during
169 self._laser_done_lock.acquire()
171 if x.scan.header.stamp <= end
and 172 x.scan.header.stamp >= start]
173 self._laser_done_lock.release()
178 self._laser_done_lock.acquire()
182 latest_time = rostime.Time().from_seconds(0.0)
183 self._laser_done_lock.release()
189 self._interval_req_lock.acquire()
190 self._interval_req_q.append([start, end])
191 self._interval_req_lock.release()
202 self._interval_req_lock.acquire()
206 self._interval_req_lock.release()
def __init__(self, req_callback, max_mech_len, max_laser_done_len, max_laser_wait_len)
def get_latest_done_scan_time(self)
def get_dense_cloud(self, start, end)
def process_interval_reqs(self)
def _process_pending(self, scan_msg, mech_q)
def add_mech_state(self, msg)
def add_interval_req(self, start, end)