def sensorInfoPublisher():
    si_publisher = rospy.Publisher('sensor_info', SensorInformation, queue_size = 10)
    rospy.init_node('sensor_info_publisher', anonymous=False)
    rate = rospy.Rate(10)

    # Create a new SensorInformation object and fill in its contents.
    sensor_info = SensorInformation()

    # Fill in the header information.
    sensor_info.sensor_data.header.stamp = rospy.Time.now()
    sensor_info.sensor_data.header.frame_id = 'distance_sensor_frame'

    # Fill in the sensor data information.
    sensor_info.sensor_data.radiation_type = sensor_info.sensor_data.ULTRASOUND
    sensor_info.sensor_data.field_of_view = 0.5 # Field of view of the sensor in rad.
    sensor_info.sensor_data.min_range = 0.02 # Minimum distance range of the sensor in m.
    sensor_info.sensor_data.max_range = 2.0 # Maximum distance range of the sensor in m.

    # Fill in the manufacturer name and part number.
    sensor_info.maker_name = 'The Ultrasound Company'
    sensor_info.part_number = 123456

    while not rospy.is_shutdown():
        # Read the sensor data from a simulated sensor.
        sensor_info.sensor_data.range = getSensorData(sensor_info.sensor_data.radiation_type,
            sensor_info.sensor_data.min_range, sensor_info.sensor_data.max_range)

        # Publish the sensor information on the /sensor_info topic.
        si_publisher.publish(sensor_info)
        # Print log message if all went well.
        rospy.loginfo("All went well. Publishing topic {}".format(sensor_info.sensor_data.range))
        rate.sleep()
예제 #2
0
def sensorInfoPublisher():
    si_publisher = rospy.Publisher('sensor_info', SensorInformation, queue_size = 10)
    rospy.init_node('sensor_info_publisher', anonymous=False)
    rate = rospy.Rate(1)

    #create a new SensorInformation object and fill in its contents. 
    sensor_info=SensorInformation()
    #fill in the header information
    sensor_info.sensor_data.header.stamp= rospy.Time.now()
    sensor_info.sensor_data.header.frame_id = 'distance_sensor_frame'
    # fill in the sensor information data 
    sensor_info.sensor_data.radiation_type = sensor_info.sensor_data.ULTRASOUND
    sensor_info.sensor_data.field_of_view = 0.5
    sensor_info.sensor_data.min_range = 0.02
    sensor_info.sensor_data.max_range = 2.00
    #fill in the manufacturer name and the part number 
    sensor_info.maker_name= 'THE ULTRASOUND COMPANY'
    sensor_info.part_number = 123456



    while not rospy.is_shutdown():
        sensor_info.sensor_data.range = getSensorData(sensor_info.sensor_data.radiation_type, sensor_info.sensor_data.min_range,sensor_info.sensor_data.max_range)
	si_publisher.publish(sensor_info)
        #printing a log message if all went well 
	rospy.loginfo('All went welll. Publishing topic')
	rate.sleep()
예제 #3
0
def simplePublisher():
    si_publisher= rospy.Publisher('sensor_info', SensorInformation, queue_size = 10)
    rospy.init_node('sensor_info_publisher', anonymous=False)
    rate = rospy.Rate(1)

    # The string to be published on the topic
    topic1_content = "Welcome to Hello (Real) World with ROS!!!"
    sensor_info = SensorInformation()

    sensor_info.sensor_data.header.stamp = rospy.Time.now()
    sensor_info.sensor_data.header.frame_id = 'distance_sensor_frame'

    sensor_info.sensor_data.radiation_type = sensor_info.sensor_data.ULTRASOUND
    sensor_info.sensor_data.field_of_view=0.5
    sensor_info.sensor_data.min_range=0.02
    sensor_info.sensor_data.max_range=2.00

    sensor_info.maker_name = 'The Ultrasound Company'
    sensor_info.part_number = 123456

 
    while not rospy.is_shutdown():
        sensor_info.sensor_data.range = getSensorData(sensor_info.sensor_data.radiation_type, sensor_info.sensor_data.min_range, sensor_info.sensor_data.max_range)
        si_publisher.publish(sensor_info)
	rospy.loginfo ('ALL WENT WELL. PUBLISHING TOPIC ')
        rate.sleep()
예제 #4
0
def simplePublisher():
    ult_publish = rospy.Publisher('ultrasonic',
                                  UltrasonicSensor,
                                  queue_size=10)
    rospy.init_node('ultrasonic_publisher', anonymous=False)
    rate = rospy.Rate(1)

    # create a new ultrasonic object
    ultrasonic_info = UltrasonicSensor()

    # fill the header of range data type, http://docs.ros.org/en/melodic/api/sensor_msgs/html/msg/Range.html
    ultrasonic_info.sensor_data.header.stamp = rospy.Time.now()
    ultrasonic_info.sensor_data.header.frame_id = 'distance_sensor_frame'

    # fill the range data type information
    ultrasonic_info.sensor_data.radiation_type = ultrasonic_info.sensor_data.ULTRASOUND
    ultrasonic_info.sensor_data.field_of_view = 0.5
    ultrasonic_info.sensor_data.min_range = 0.002
    ultrasonic_info.sensor_data.max_range = 5.000

    # fill the info about ultrasonic that we defined
    ultrasonic_info.maker_name = "Zero-Inside"
    ultrasonic_info.part_number = 00000
    ultrasonic_info.sensor_type = "Analog"

    while not rospy.is_shutdown():

        # feed .range to fake sensor data function
        ultrasonic_info.sensor_data.range = getSensorData(
            ultrasonic_info.sensor_data.radiation_type,
            ultrasonic_info.sensor_data.min_range,
            ultrasonic_info.sensor_data.max_range)

        ult_publish.publish(ultrasonic_info)
        rospy.loginfo("publish new message!")
        rospy.loginfo(ultrasonic_info)
        rate.sleep()