tysik / obstacle_detector

A ROS package for 2D obstacle detection based on laser range data.
540 stars 205 forks source link

Subscribe to circles-center-x #8

Closed tiberium24 closed 6 years ago

tiberium24 commented 6 years ago

Hello, Do you know why i cant subscribe to circles? I am trying to get the last message but it says out of index.

%%% def callback(msg): result=PoseWithCovariance() result.pose.position.x=msg.circles[-1].center.x

def main():

rospy.init_node("republisher")
pub=rospy.Publisher("target_pos_lidar", PoseWithCovariance, queue_size=1000)
sub=rospy.Subscriber("raw_obstacles", Obstacles, callback)
r=rospy.Rate(10)
result=PoseWithCovariance()
while not rospy.is_shutdown():
    pub.publish(result)
    r.sleep()
tysik commented 6 years ago

Maybe sometimes you don't receive any circles in which case the index will be out of bounds.

Mateusz

wt., 3 lip 2018, 05:56 użytkownik tiberium24 notifications@github.com napisał:

Hello, Do you know why i cant subscribe to circles? I am trying to get the last message but it says out of index.

%%% def callback(msg): result=PoseWithCovariance() result.pose.position.x=msg.circles[-1].center.x

def main():

rospy.init_node("republisher") pub=rospy.Publisher("target_pos_lidar", PoseWithCovariance, queue_size=1000) sub=rospy.Subscriber("raw_obstacles", Obstacles, callback) r=rospy.Rate(10) result=PoseWithCovariance() while not rospy.is_shutdown(): pub.publish(result) r.sleep()

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tysik/obstacle_detector/issues/8, or mute the thread https://github.com/notifications/unsubscribe-auth/ABafEkLokZ5MiQISMK2aKveeatVc4xkCks5uCutogaJpZM4VAQcK .

tiberium24 commented 6 years ago

Thanks i got it to work