4 from jsk_topic_tools
import ConnectionBasedTransport
6 from pcl_msgs.msg
import ModelCoefficients
9 from dynamic_reconfigure.server
import Server
10 from jsk_pcl_ros.cfg
import ExtractTopPolygonLikelihoodConfig
14 super(ExtractTopPolygonLikelihood, self).
__init__()
16 self.
_pub = self.advertise(
"~output", PolygonArray, queue_size=1)
17 self.
_pub_coef = self.advertise(
"~output/coefficients", ModelCoefficientsArray, queue_size=1)
25 self._sync.registerCallback(self.
callback)
27 self._sub.sub.unregister()
28 self._sub_coef.sub.unregister()
30 if len(msg.polygons) > 0:
32 max_index =
max(xrange(len(msg.polygons)), key=
lambda i: msg.likelihood[i])
34 res.header = msg.header
35 res.polygons = [msg.polygons[max_index]]
36 res.likelihood = [msg.likelihood[max_index]]
38 rospy.loginfo(
"Ignore result because of too small likelihood: {0} < {1}".format(
39 msg.likelihood[max_index],
42 self._pub.publish(res)
43 res_coef = ModelCoefficientsArray()
44 res_coef.header = msg.header
45 res_coef.coefficients = [msg_coef.coefficients[max_index]]
46 self._pub_coef.publish(res_coef)
49 if __name__ ==
"__main__":
50 rospy.init_node(
"extract_top_polygon_likelihood")
double max(const OneDataStat &d)
wrapper function for max method for boost::function