ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This looks suspicious:

min_range = 2.0 
max_range = 2.0

And BTW:

def publish_range(ir_value, publisher): # (instead of range_infrared_sensor_?)
    range_msg = Range()
    range_msg.header.stamp = rospy.Time.now()
    range_msg.header.frame_id = "/base_link"
    range_msg.radiation_type = 0
    range_msg.field_of_view = 1.0
    range_msg.min_range = min_range
    range_msg.max_range = max_range
    range_msg.range = ir_value
    publisher.publish(range_msg)

and the call

publish_range(float(splited_data[0]), ir1_pub)

(or even put the publishers also in a list)

This looks suspicious:

min_range = 2.0 
max_range = 2.0

And BTW:regarding code quality (no duplicated code in range_infrared_sensor_?

def publish_range(ir_value, publisher): # (instead of range_infrared_sensor_?)
     range_msg = Range()
    range_msg.header.stamp = rospy.Time.now()
    range_msg.header.frame_id = "/base_link"
    range_msg.radiation_type = 0
    range_msg.field_of_view = 1.0
    range_msg.min_range = min_range
    range_msg.max_range = max_range
    range_msg.range = ir_value
    publisher.publish(range_msg)

and the call

publish_range(float(splited_data[0]), ir1_pub)

(or even put the publishers also in a list)

This looks suspicious:

min_range = 2.0 
max_range = 2.0

And regarding code quality (no duplicated code in range_infrared_sensor_?range_infrared_sensor_?)

def publish_range(ir_value, publisher): 
    range_msg = Range()
    range_msg.header.stamp = rospy.Time.now()
    range_msg.header.frame_id = "/base_link"
    range_msg.radiation_type = 0
    range_msg.field_of_view = 1.0
    range_msg.min_range = min_range
    range_msg.max_range = max_range
    range_msg.range = ir_value
    publisher.publish(range_msg)

and the call

publish_range(float(splited_data[0]), ir1_pub)

(or even put the publishers also in a list)

This You're on the right path, but this looks suspicious:

min_range = 2.0 
max_range = 2.0

And regarding code quality (no duplicated code in range_infrared_sensor_?)

def publish_range(ir_value, publisher): 
    range_msg = Range()
    range_msg.header.stamp = rospy.Time.now()
    range_msg.header.frame_id = "/base_link"
    range_msg.radiation_type = 0
    range_msg.field_of_view = 1.0
    range_msg.min_range = min_range
    range_msg.max_range = max_range
    range_msg.range = ir_value
    publisher.publish(range_msg)

and the call

publish_range(float(splited_data[0]), ir1_pub)

(or even put the publishers also in a list)