apl-ocean-engineering / sonar_image_proc

Other
12 stars 3 forks source link

sonar_image_proc

pre-commit

Code to draw data from forward-looking imaging sonars.

If built for ROS, it will build a node/nodelet draw_sonar which subscribes to an marine_acoustic_msgs/ProjectedSonarImage and publishes a sensor_msgs/Image.

The core library contains no ROS dependencies, and can be linked into non-ROS applications.

ROS Interfaces (draw_sonar_node)

rosrun sonar_image_proc draw_sonar_node

Subscribers

Subscribes to the topic sonar_image of type marine_acoustic_msgs/ProjectedSonarImage.

Publishers

By default publishes three sensor_msgs/Image topics:

If the param publish_timing is true, the node will track the elapsed time to draw each sonar image and publish that information to the topic sonar_image_proc_timing as a std_msgs/String containing a JSON dict.

If the param publish_old is true, the node will also draw the sonar using the old draw_sonar algorithm for comparison.

Params

If max_range is set to a non-zero value, images will be clipped/dropped to that max range (or the actual sonar range, whichever is smaller).

If publish_timing is true the node will publish performance information as a JSON string to the topic sonar_image_proc_timing. Defaults to true

If publish_old is true the node will also draw the sonar using the old algorithm to the topic old_drawn_sonar. Defaults to false

If publish_histogram is true the node will publish a "raw" histogram information as a UInt32MultiArray to the topic histogram. It contains a vector of unsigned ints giving the count for each intensity value -- so for 8 bit data the vector will be 256 elements in length, and for 16-bit data it will be 65536 elements in length.

bag2sonar

The program bag2sonar reads in a bagfile containing a ProjectedSonarImage topic, draws the sonar image and writes those images to new bagfile in a Image topic.

Usage:

$ rosrun sonar_image_proc bag2sonar
Usage:

   bag2sonar [options]  <input file(s)>

Draw sonar from a bagfile:
  -h [ --help ]                         Display this help message
  -l [ --logscale ]                     Do logscale
  --min-db arg (=0)                     Min db
  --max-db arg (=0)                     Max db
  --osd                                 If set, include the on-screen display
                                        in output
  -o [ --output-bag ] arg               Name of output bagfile
  -t [ --output-topic ] arg (=/drawn_sonar)
                                        Topic for images in output bagfile

Note that bag2sonar is not a conventional ROS node, it is intended to run as a standalone commandline program. It uses ros_storage to read the input bagfile sequentially, rather than subscribing to a topic.

histogram_drawer

python/histogram_drawer is a Python script which subscribes to the histogram topic and uses numpy+Matplotlib to bin the data (into a fixed set of 128 bin right now), and draw a plot to the topic drawn_histogram.

Python API

Long term, I'd like to be able to call this drawing function from Python, however we're not there yet.

There IS a totally separate python node that publishes a pointcloud for visualization in rviz:

rosrun sonar_image_proc sonar_pointcloud.py

API

Sonar drawing is implemented in the SonarDrawer class, which takes an instance of an AbstractSonarInterface and returns a cv::Mat. SonarDrawer computes and stores pre-calculated matrices to accelerate the drawing.

A convenience function drawSonar is also provided. It is a trivial wrapper which creates an instance of SonarDrawer then calls it. Calls to drawSonar do not retain the cached matrices and are less efficient.

Related Packages

License

Licensed under BSD 3-clause license.