21 from sensor_msgs.msg
import PointCloud2, PointField
24 from sensor_msgs.msg
import LaserScan
41 PEPPER_LASER_MIN_ANGLE = -0.523598776
42 PEPPER_LASER_MAX_ANGLE = 0.523598776
43 PEPPER_LASER_FOV = math.fabs(PEPPER_LASER_MIN_ANGLE)+math.fabs(PEPPER_LASER_MAX_ANGLE)
45 PEPPER_LASER_MIN_RANGE = 0.1
46 PEPPER_LASER_MAX_RANGE = 5.0
49 PEPPER_LASER_GROUND_SHOVEL_POINTS = 3
50 PEPPER_LASER_GROUND_LEFT_POINTS = 1
51 PEPPER_LASER_GROUND_RIGHT_POINTS = 1
53 PEPPER_LASER_SRD_POINTS = 15
58 PEPPER_MEM_KEY_GROUND_SHOVEL =
'Device/SubDeviceList/Platform/LaserSensor/Front/Shovel/' 59 PEPPER_MEM_KEY_GROUND_LEFT =
'Device/SubDeviceList/Platform/LaserSensor/Front/Vertical/Left/' 60 PEPPER_MEM_KEY_GROUND_RIGHT =
'Device/SubDeviceList/Platform/LaserSensor/Front/Vertical/Right/' 61 PEPPER_MEM_KEY_SRD_FRONT =
'Device/SubDeviceList/Platform/LaserSensor/Front/Horizontal/' 62 PEPPER_MEM_KEY_SRD_LEFT =
'Device/SubDeviceList/Platform/LaserSensor/Left/Horizontal/' 63 PEPPER_MEM_KEY_SRD_RIGHT =
'Device/SubDeviceList/Platform/LaserSensor/Right/Horizontal/' 67 PARAM_LASER_RATE =
'~laser_rate' 68 PARAM_LASER_RATE_DEFAULT = PEPPER_LASER_FREQ
71 PARAM_LASER_SHOVEL_FRAME =
'~laser_shovel_frame_id' 72 PARAM_LASER_SHOVEL_FRAME_DEFAULT =
'ShovelLaser_frame' 74 PARAM_LASER_GROUND_LEFT_FRAME =
'~laser_ground_left_frame_id' 75 PARAM_LASER_GROUND_LEFT_FRAME_DEFAULT =
'VerticalLeftLaser_frame' 77 PARAM_LASER_GROUND_RIGHT_FRAME =
'~laser_ground_right_frame_id' 78 PARAM_LASER_GROUND_RIGHT_FRAME_DEFAULT =
'VerticalRightLaser_frame' 80 PARAM_LASER_SRD_FRONT_FRAME =
'~laser_srd_front_frame_id' 81 PARAM_LASER_SRD_FRONT_FRAME_DEFAULT =
'SurroundingFrontLaser_frame' 83 PARAM_LASER_SRD_LEFT_FRAME =
'~laser_srd_left_frame_id' 84 PARAM_LASER_SRD_LEFT_FRAME_DEFAULT =
'SurroundingLeftLaser_frame' 86 PARAM_LASER_SRD_RIGHT_FRAME =
'~laser_srd_right_frame_id' 87 PARAM_LASER_SRD_RIGHT_FRAME_DEFAULT =
'SurroundingRightLaser_frame' 89 TOPIC_LASER_SHOVEL =
'~/laser/shovel/' 90 TOPIC_LASER_GROUND_LEFT =
'~/laser/ground_left/' 91 TOPIC_LASER_GROUND_RIGHT =
'~/laser/ground_right/' 92 TOPIC_LASER_SRD_FRONT =
'~/laser/srd_front/' 93 TOPIC_LASER_SRD_LEFT =
'~/laser/srd_left/' 94 TOPIC_LASER_SRD_RIGHT =
'~/laser/srd_right/' 96 PEPPER_LASER_SUB_NAME =
'pepper_ros_laser' 98 def __init__(self, pointcloud=True, laserscan=False):
102 NaoqiNode.__init__(self,
'pepper_node')
151 rospy.loginfo(
"Connecting to NaoQi at %s:%d", self.
pip, self.
pport)
155 print "could not start either laser or memory proxy" 159 ''' the idea here is to get the point xy 160 calculate the length from the origin (range) 161 assumption: field of view spanning from very min to very max 167 for i
in xrange(scanNum, 0, -1):
168 keyX = keyPrefix +
'Seg' +
'%02d' % (i,) +
'/X/Sensor/Value' 169 keyY = keyPrefix +
'Seg' +
'%02d' % (i,) +
'/Y/Sensor/Value' 170 tmp_array.append(keyX)
171 tmp_array.append(keyY)
172 memData = self.memProxy.getListData(tmp_array)
173 for i
in xrange(0, len(tmp_array), 2):
176 ranges.append(math.sqrt(math.pow(x, 2.0) + math.pow(y, 2.0)))
181 for i
in xrange(scanNum,0,-1):
182 keyX = keyPrefix+
'Seg'+
'%02d'%(i,)+
'/X/Sensor/Value' 183 keyY = keyPrefix+
'Seg'+
'%02d'%(i,)+
'/Y/Sensor/Value' 184 x = self.memProxy.getData(keyX)
185 y = self.memProxy.getData(keyY)
189 ba = struct.pack(
'%sf' %len(scans), *scans)
193 pointCloudMsg = PointCloud2()
194 pointCloudMsg.header.frame_id = frameID
195 pointCloudMsg.header.stamp = rospy.Time.now()
196 pointCloudMsg.height = 1
197 pointCloudMsg.width = scanNum
198 pointCloudMsg.is_dense =
False 199 pointCloudMsg.is_bigendian =
False 200 pointCloudMsg.fields = [PointField(
'x', 0, PointField.FLOAT32, 1),
201 PointField(
'y', 4, PointField.FLOAT32, 1),
202 PointField(
'z', 8, PointField.FLOAT32, 1)]
203 pointCloudMsg.point_step = 4*3
204 pointCloudMsg.row_step = pointCloudMsg.point_step* pointCloudMsg.width
209 laserScanMsg = LaserScan()
210 laserScanMsg.header.frame_id = frameID
282 shovelScan.header.stamp = rospy.Time.now()
288 groundLeftScan.header.stamp = rospy.Time.now()
294 groundRightScan.header.stamp = rospy.Time.now()
300 srdFrontScan.header.stamp = rospy.Time.now()
306 srdLeftScan.header.stamp = rospy.Time.now()
312 srdRightScan.header.stamp = rospy.Time.now()
319 self.laserShovelPublisher.publish(shovelScan)
320 self.laserGroundLeftPublisher.publish(groundLeftScan)
321 self.laserGroundRightPublisher.publish(groundRightScan)
322 self.laserSRDFrontPublisher.publish(srdFrontScan)
323 self.laserSRDLeftPublisher.publish(srdLeftScan)
324 self.laserSRDRightPublisher.publish(srdRightScan)
329 shovelPC.header.stamp = rospy.Time.now()
335 groundLeftPC.header.stamp = rospy.Time.now()
341 groundRightPC.header.stamp = rospy.Time.now()
347 srdFrontPC.header.stamp = rospy.Time.now()
353 srdLeftPC.header.stamp = rospy.Time.now()
359 srdRightPC.header.stamp = rospy.Time.now()
366 self.pcShovelPublisher.publish(shovelPC)
367 self.pcGroundLeftPublisher.publish(groundLeftPC)
368 self.pcGroundRightPublisher.publish(groundRightPC)
369 self.pcSRDFrontPublisher.publish(srdFrontPC)
370 self.pcSRDLeftPublisher.publish(srdLeftPC)
371 self.pcSRDRightPublisher.publish(srdRightPC)
374 self.laserRate.sleep()
377 if __name__ ==
'__main__':
string PARAM_LASER_SRD_FRONT_FRAME_DEFAULT
int PEPPER_LASER_SRD_POINTS
float PEPPER_LASER_MIN_RANGE
string PARAM_LASER_SRD_RIGHT_FRAME
def fetchPCValues(self, keyPrefix, scanNum)
int PEPPER_LASER_GROUND_LEFT_POINTS
string PEPPER_MEM_KEY_GROUND_RIGHT
string PARAM_LASER_GROUND_RIGHT_FRAME
string PARAM_LASER_SRD_RIGHT_FRAME_DEFAULT
string TOPIC_LASER_GROUND_RIGHT
float PEPPER_LASER_MIN_ANGLE
string PARAM_LASER_SRD_LEFT_FRAME_DEFAULT
float PEPPER_LASER_MAX_RANGE
string TOPIC_LASER_SHOVEL
laserGroundRightPublisher
string PARAM_LASER_GROUND_RIGHT_FRAME_DEFAULT
int PEPPER_LASER_GROUND_RIGHT_POINTS
string TOPIC_LASER_SRD_RIGHT
string PARAM_LASER_SHOVEL_FRAME_DEFAULT
string PARAM_LASER_GROUND_LEFT_FRAME_DEFAULT
string PARAM_LASER_SRD_FRONT_FRAME
string TOPIC_LASER_SRD_FRONT
string PEPPER_MEM_KEY_SRD_FRONT
string PEPPER_MEM_KEY_GROUND_SHOVEL
float PEPPER_LASER_MAX_ANGLE
string PEPPER_MEM_KEY_SRD_LEFT
def fetchLaserValues(self, keyPrefix, scanNum)
string PEPPER_MEM_KEY_GROUND_LEFT
laserSRDFrontPublisher_test
string PARAM_LASER_SHOVEL_FRAME
string PARAM_LASER_GROUND_LEFT_FRAME
string PEPPER_MEM_KEY_SRD_RIGHT
def createLaserMessage(self, frameID, keyPrefix, scanNum)
int PEPPER_LASER_GROUND_SHOVEL_POINTS
string TOPIC_LASER_GROUND_LEFT
def get_proxy(self, name, warn=True)
string TOPIC_LASER_SRD_LEFT
string PARAM_LASER_SRD_LEFT_FRAME
def createPointCloudMessage(self, frameID, keyPrefix, scanNum)
def __init__(self, pointcloud=True, laserscan=False)