10 #include <sensor_msgs/Range.h> 17 #if defined(TARGET_LPC1768) 18 const PinName adc_pin = p20;
19 #elif defined(TARGET_KL25Z) || defined(TARGET_NUCLEO_F401RE) 20 const PinName adc_pin = A0;
22 #error "You need to specify a pin for the sensor" 29 for (
int i=0;
i<4;
i++) val += AnalogIn(pin_num).read_u16();
31 return range /322.519685;
40 range_msg.radiation_type = sensor_msgs::Range::ULTRASOUND;
55 if (
t.read_ms() >= range_time ) {
59 range_time =
t.read_ms() + 50;
float getRange_Ultrasound(PinName pin_num)
void publish(const boost::shared_ptr< M > &message) const
ros::Publisher pub_range("/ultrasound",&range_msg)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
sensor_msgs::Range range_msg