#include <ros/ros.h>
#include <sensor_msgs/Range.h>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include "pibot_msgs/avoid.h"
#include <libusb-1.0/libusb.h>



class UltrasonicNode {
public:
    ros::NodeHandle nh;
    ros::Publisher ultrasonic_pub;
    libusb_device_handle *dev_handle;
    libusb_device **devs;
    libusb_context *ctx = NULL;
    int r;
    ssize_t cnt;
    float range;
    // boost::asio::io_service io;
    // boost::asio::serial_port serial;

public:
    // UltrasonicNode() : nh("~"), serial(io), ultrasonic_pub(nh.advertise<sensor_msgs::Range>("ultrasonic", 1)) {
        // std::string port_name;
        // nh.param<std::string>("port", port_name, "/dev/ttyUSB0");
        // serial.open(port_name);
        // serial.set_option(boost::asio::serial_port_base::baud_rate(9600));
    // }
    UltrasonicNode();
    ~UltrasonicNode();


    void readUltrasonic();
};
 