Menu

checksum error Urg_driver::get_distance(): no response

Anonymous
2017-07-22
2017-11-28
  • Anonymous

    Anonymous - 2017-07-22

    Hi HOKUYO Engineer.
    I am using UST-10LX Scanning Rangefinder. Firmware version is 2.23.
    I programming in Windows 10(64bit) c++ 11. The sensor is straight connection with my computer.
    My issue is that after my application run after about a hour later it out put "checksum error Urg_driver::get_distance(): no response"!
    I am use another thread for my Kinect sensor, my UST-10LX run in the main thread.
    My code like below

    void RadarSensor::GetFrameData()
    {
        vector<long> data;
        long time_stamp = 0;
    
        if (!urg.get_distance(data, &time_stamp)) {
            cout << "Urg_driver::get_distance(): " << urg.what() << endl;
        }
        const long min_distance = urg.min_distance();
        const long max_distance = urg.max_distance();
        size_t data_n = data.size();
    
        for (size_t i = 0; i < data_n; ++i) {
            long l = data[i];
    
            if ((l <= min_distance) || (l >= max_distance)) {
                continue;
            }
            const double radian = urg.index2rad(static_cast<int>(i));
            long x = sensor_x + static_cast<long>(l * sin(radian));
            long y = sensor_y + static_cast<long>(l * cos(radian));
    
            if (x < 0 || x > wall_width || y < 0 || y > wall_height)
            {
                continue;
            }
        }
    }
    

    appreciated for any help!

     
  • Anonymous

    Anonymous - 2017-07-24

    I found that this issue happen randomly, it may happen some minutes since the application start,
    some times it happen about an hour since the application start.It happen in both single thread and mulitiple thread.
    If I take a break point in Visual Studio,this issue can happen very frequently.
    After the checksum error, no response will occur infinity.
    Thank you!

     
  • m-nagata

    m-nagata - 2017-07-24

    I checked the source code, but there is no problem in particular.

    Perhaps you are doing a process that takes time other than GetFrameData on the main thread?
    If so, it may be delayed to retrieve measured data from the Windows receive buffer on Windows.
    (What happens frequently during debugging seems to be that measurement data has accumulated in the receive buffer when stopped at a breakpoint.)

    Could you please try the following?
    "Delete GetFrameData () on the main thread, only execute GetFrameData () on another thread."

     
  • Anonymous

    Anonymous - 2017-07-24

    Hi,m-nagata! Thank you so much for your help!

    Why the checksum error occur?
    The sensor return measured data 40 times every second, if receive the buffer not fast enough, for example 30 times every second,another new buffer will overwrite the old buffer,then the checksum error occur in this situation. Is that right?
    OK, I will try your suggestion.

    Thank you so much,have a good day!

     
  • m-nagata

    m-nagata - 2017-07-25

    Why the checksum error occur?

    The Urglibrary's get_distance method extracts data by 1 scan at a time from the buffer.
    So, if more than 2 scan of data is accumulated in the buffer, it is necessary to execute it several times.
    ※ If you need data of every scan with UST - 10LX, get_distance must be executed 40 times during 1s.

    In this case, it is considered that an error occurred in the following flow.
    · Buffer overflowed, normal measurement data did not exist
    · Sum check was done with abnormal measurement data, and it became checksum error.

    • Since the get_distance method received error data, we sent a stop measurement command.
      · The sensor received the measurement stop command and stopped the measurement.
      · Measurement data can not be received, but the program returns no response because it executes get_distance.
     
  • Anonymous

    Anonymous - 2017-07-26

    Hi, m-nagata. Thank you for your professional anwser.

    I have move GetFrameData() function in single thread, the checksum error rarely occured, occured an average of every two hours.
    since the error occured not so often, I can just ignore it and continue to get measurement data. So what is the right way to achieve this, I try it as below:

    std::unique_ptr<RadarSensor> radar = std::make_unique<RadarSensor>();
    radar->SetupRadarSensor();
    
    class RadarSensor
    {
    public:
        RadarSensor()
    
        ~RadarSensor();
    
        void SetupRadarSensor()
        {
            if (!urg.open(information.device_or_ip_name(),
                information.baudrate_or_port_number(),
                information.connection_type())) {
                cout << "Urg_driver::open(): " << information.device_or_ip_name() << ": " << urg.what() << endl;
            }
    
            urg.set_scanning_parameter(urg.deg2step(-90), urg.deg2step(+90), 0);
            urg.start_measurement(Urg_driver::Distance, Urg_driver::Infinity_times, 0);
        }
    
        // this function will called every frame
        void GetFrameData()
        {
            vector<long> data;
            long time_stamp = 0;
    
            if (!urg.get_distance(data, &time_stamp)) {
                cout << "Urg_driver::get_distance(): " << urg.what() << endl;
    
                //if the error occured I will close it and create another new instance
                urg.close();
                radar = std::make_unique<RadarSensor>();
                radar->SetupRadarSensor();
                continue;
            }
            static const long min_distance = urg.min_distance();
            static const long max_distance = urg.max_distance();
            size_t data_n = data.size();
    
            for (size_t i = 0; i < data_n; ++i) {
                long l = data[i];
    
                if ((l <= min_distance) || (l >= max_distance)) {
                    continue;
                }
                const double radian = urg.index2rad(static_cast<int>(i));
                long x = sensor_x + static_cast<long>(l * sin(radian));
                long y = sensor_y + static_cast<long>(l * cos(radian));
    
                if (x < 0 || x > wall_width || y < 0 || y > wall_height)
                {
                    continue;
                }
            }
        }
    
    private:
        Connection_information information;
        Urg_driver urg;
    };
    

    Is it the best way to achieve it?

     
  • Anonymous

    Anonymous - 2017-07-27

    Maybe it is not get_distance executed not fast enough, is it possible that the application disconnect UST-10LX for a while, then measurement data accumulated in the buffer, after reconnect and called get_distance the error occured? Is it something could cause UST-10LX disconnect sometime?

     
  • m-nagata

    m-nagata - 2017-07-27

    So what is the right way to achieve this, I try it as below:
    I also tried running the same program.
    I think that there are differences in the operating environment, but it has been running normally for more than 4 hours.

    Maybe it is not get_distance executed not fast enough
    In your source code, X and Y coordinates are calculated immediately after get_distance (). Can you make that calculation different thread?

     
  • Anonymous

    Anonymous - 2017-11-28

    I've had the same problem. Have you solved it?

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB