Skip to content

Commit

Permalink
Acoustics (DukeRobotics#255)
Browse files Browse the repository at this point in the history
* acoustic branch

* major refactoring

* update matplotlib to use agg backend

* move action to custom_msgs and finalize scripts

* integrated guess

* list comp and refactor

* Acoustic wrapper (DukeRobotics#226)

Adds basic implementation for the main wrapper.

* data generator (DukeRobotics#253)

Co-authored-by: Reed Chen <reedchen19@gmail.com>

* Saleae integration (DukeRobotics#254)

* made guess_processing wrapper

* updated variable names

* got rid of duplicate scripts

* did changes according to comments

* saleae rough draft

* updated saleae.py to have one line command

* spelling changes

* fix saeleae code and name

Co-authored-by: Brandon K Bae <brandon.bae@duke.edu>
Co-authored-by: Spammy0607 <71797727+Spammy0607@users.noreply.github.com>

* Refactor and redesign various interfaces

Refactors the data sim script and the wrapper script for better design.
Updates interfaces to include messages on feedback, and return better
indicators of success.

* allow multiple files for guess

* add readme and launch file, update dockerfiles

* linting

* lint again

* final lint

* use tuple over list for key in dictionary

Co-authored-by: Estelle He <wh103@duke.edu>
Co-authored-by: Reed Chen <reed.chen@duke.edu>
Co-authored-by: Reed Chen <reedchen19@gmail.com>
Co-authored-by: Spammy0607 <71797727+Spammy0607@users.noreply.github.com>
Co-authored-by: Brandon K Bae <brandon.bae@duke.edu>
  • Loading branch information
6 people authored Mar 13, 2021
1 parent fe9b12f commit f78cb02
Show file tree
Hide file tree
Showing 26 changed files with 921 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# ROS_Serial
catkin_ws/src/offboard_comms/ros_lib

# Acoustics
*.csv

# Video and Bags
*.avi
*.bag
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Our codebase is powered by the [Robot Operating System](https://www.ros.org) (RO
The following components make up our software stack:

- Onboard:
* [Acoustics](onboard/catkin_ws/src/acoustics) - Handles the task of locating an underwater hydrophone pinger.
* [AVT Camera](onboard/catkin_ws/src/avt_camera) - Drives our ethernet cameras and publishes a live video feed.
* [Controls](onboard/catkin_ws/src/controls) - Determines thruster outputs given a current and desired state.
* [Computer Vision](onboard/catkin_ws/src/cv) - Locates objects (goals/obstacles) via camera input and machine learning.
Expand Down Expand Up @@ -51,12 +52,12 @@ The general flow of information between components is shown in the diagram below
v / v
Data Pub / Camera View
\ /
Simulation ---> \ /
v v
Sensor Fusion Computer Vision
\ /
\ /
v v
Simulation ---> \ Acoustics /
v | v
Sensor Fusion | Computer Vision
\ | /
\ | /
v v v
Task Planning
|
|
Expand Down
15 changes: 14 additions & 1 deletion core/catkin_ws/src/custom_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ project(custom_msgs)
find_package(catkin REQUIRED COMPONENTS
message_generation
std_msgs
geometry_msgs
actionlib_msgs
)

add_message_files(
Expand All @@ -21,13 +23,24 @@ add_service_files(
EnableModel.srv
)

add_action_files(
FILES
AcousticsProcessing.action
AcousticsGuess.action
AcousticsWrapper.action
Saleae.action
AcousticsData.action
)

generate_messages(
DEPENDENCIES
std_msgs
geometry_msgs
actionlib_msgs
)

## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
catkin_package(
CATKIN_DEPENDS message_runtime std_msgs
CATKIN_DEPENDS message_runtime std_msgs geometry_msgs actionlib_msgs
)
31 changes: 31 additions & 0 deletions core/catkin_ws/src/custom_msgs/action/AcousticsData.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Goal

# Sampling frequency
uint32 samp_f

# Target frequency
uint32 tar_f

# Hydrophone array used
string hydrophone

# Location of the pinger
geometry_msgs/Point location

---
# Result

# Result files where data has been saved. Should be a package URL.
string[] file_paths

---
# Feedback

# Current stage the program is on
uint32 curr_stage

# Total number of stages in program
uint32 total_stages

# Message
string message
28 changes: 28 additions & 0 deletions core/catkin_ws/src/custom_msgs/action/AcousticsGuess.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Goal

# The base filename of the data without the version
string[] file_paths

# Sampling frequency
uint32 samp_f

# Target frequency
uint32 tar_f

---
# Result

# Guess of the location of the pinger
geometry_msgs/Point guess

---
# Feedback

# Current stage the program is on
uint32 curr_stage

# Total number of stages in program
uint32 total_stages

# Message
string message
41 changes: 41 additions & 0 deletions core/catkin_ws/src/custom_msgs/action/AcousticsProcessing.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Goal

# The base filename of the data without the version
string[] file_paths

# Whether the data in the file needs to be split in half
bool if_double

# Sampling frequency
uint32 samp_f

# Target frequency
uint32 tar_f

# Guess of the location of the pinger
geometry_msgs/Point guess
---
# Result

# Horizontal angle to the location of the pinger in radians
float64 hz_angle

# Total number of datasets processed
uint32 total_count

# Total number of datasets that were successfully parsed
uint32 success_count

# Total number of datasets that contained numerically valid data
uint32 valid_count
---
# Feedback

# Total number of datasets that will be processed
uint32 total_count

# Number of datasets that have been processed
uint32 process_count

# Number of datasets that have been processed that were successfully parsed
uint32 success_count
22 changes: 22 additions & 0 deletions core/catkin_ws/src/custom_msgs/action/AcousticsWrapper.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Goal

# Target frequency
uint32 tar_f

---
# Result

# Horizontal angle to the location of the pinger in radians
float64 hz_angle

---
# Feedback

# Current stage the program is on
uint32 curr_stage

# Total number of stages in program
uint32 total_stages

# Message to display
string message
31 changes: 31 additions & 0 deletions core/catkin_ws/src/custom_msgs/action/Saleae.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Goal

# Name of base filename to save to
string save_name

# Which Hydrophone Set
uint32 hydrophone_set

# Number of captures to take
uint32 capture_count

# Duration to perform capture for
uint32 capture_duration

---
# Result

# Result files where data has been saved. Should be a package URL.
string[] file_paths

---
# Feedback

# Current stage the program is on
uint32 curr_stage

# Total number of stages in program
uint32 total_stages

# Message
string message
3 changes: 2 additions & 1 deletion core/catkin_ws/src/custom_msgs/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<license>MIT</license>

<depend>std_msgs</depend>

<depend>geometry_msgs</depend>
<depend>actionlib_msgs</depend>
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>

Expand Down
5 changes: 3 additions & 2 deletions docker/core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ RUN locale-gen en_GB.UTF-8 && locale-gen en_US.UTF-8
# Set a password for root
RUN echo root:robotics | chpasswd

# Allow root to login over ssh
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
# Allow root to login over ssh and forward graphics over ssh
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config && \
echo "X11UseLocalhost no" >> /etc/ssh/sshd_config

# Generate ssh keys
RUN ssh-keygen -A
Expand Down
6 changes: 2 additions & 4 deletions docker/landside/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ FROM ${BASE_IMAGE}

### SSH Settings ###

# Set ssh to not use local X11 so graphics are forwarded to user
RUN echo "X11UseLocalhost no" >> /etc/ssh/sshd_config && \
# Set ssh to use port 2201
echo "Port 2201" >> /etc/ssh/sshd_config
# Set ssh to use port 2201
RUN echo "Port 2201" >> /etc/ssh/sshd_config

### Final Installs ###

Expand Down
10 changes: 8 additions & 2 deletions docker/onboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN echo "Port 2200" >> /etc/ssh/sshd_config

# Update and install tools
RUN apt-get update && apt-get install -y --no-install-recommends \
libceres-dev \
libceres-dev unzip \
python-numpy python-scipy python-future \
python-six python-dateutil python-skimage \
python-pywt python-pandas \
Expand All @@ -25,7 +25,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
rm -rf /var/lib/apt/lists/*

# Get required python packages
RUN pip install pyserial dependency-injector pillow==6 pymba==0.1
RUN pip install pyserial dependency-injector pillow==6 pymba==0.1 saleae

# Install PyTorch and Torchvision
COPY $TARGETPLATFORM/TorchInstaller.sh TorchInstaller.sh
Expand All @@ -47,5 +47,11 @@ RUN git clone https://github.com/muthuArivoli/camera-driver.git && \
RUN rm -rf camera-driver && \
rm Vimba.tgz

# Install Saleae Logic application and add to path
RUN wget -O "logic.zip" "http://downloads.saleae.com/logic/1.2.18/Logic+1.2.18+(64-bit).zip" && \
unzip logic.zip && \
mv "Logic 1.2.18 (64-bit)" "Logic" && \
export PATH="$PATH:$PWD/Logic"

# Set computer type
ENV COMPUTER_TYPE=onboard
16 changes: 16 additions & 0 deletions onboard/catkin_ws/src/acoustics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 2.8.3)
project(acoustics)


## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
find_package(catkin REQUIRED COMPONENTS
actionlib
rospy
custom_msgs
)


catkin_package(
CATKIN_DEPENDS rospy custom_msgs actionlib
)
45 changes: 45 additions & 0 deletions onboard/catkin_ws/src/acoustics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Acoustics

This package handles the calculations for locating an underwater acoustics pinger that is pinging at a certain frequency.

## Execution

To launch the main sampling and processing nodes, you can use the launch file provided. Note that this expects the Logic software to already be running and the saleae device connected via USB.
```
roslaunch acoustics acoustics.launch
```

Refer to the section on the acoustics wrapper structure below for the specific information to send to start processing. To start an action via a GUI (without an action client) refer to this [tutorial](http://wiki.ros.org/actionlib_tutorials/Tutorials/Calling%20Action%20Server%20without%20Action%20Client).

To run the data_sim server that will generate test data, you can use the command:
```
rosrun acoustics data_server.py
```

Refer to the section on structure below for the specific information to send to start the data generation.

## Structure

This package contains 5 nodes to handle various acoustics tasks: the acoustics wrapper, the saleae node, the guess server, the processing server, and the data server.

### Acoustics Wrapper
The acoustics wrapper node provides an external interface (an action server) to allow client code to easily call all of the steps involved in acoustics processing without providing lower level information such as the sampling frequency or file paths for saved data.

The node itself provides an action server of type `custom_msgs/AcousticsWrapper.action`, which client code will use to call the action. Client code is required to provide the target frequency of the pinger (Robosub provides this depending on what course we are using), and the wrapper server will return the horizontal angle to which the pinger is located at. It will also update the client as to which step is being done via its feedback messages.

### Saleae Node

The saleae node interfaces with the saleae and tells it to sample data for a given duration and sample for a given amount. It saves the data to a file located in the data folder. It contains an action server using type `custom_msgs/Saleae.action`.

### Guessing Node

The guessing node contains code to make a guess for which octant the pinger is located in, which provides the processing node the necessary information to do its computations. The code is separated into `guess_server.py` and `cheap_cross_cor.py` to separate the ROS interface from the underlying acoustics code, to allow for the guessing code to execute without ROS. The ROS node contains an action server using type `custom_msgs/AcousticsGuess.action`.

### Processing Node

The processing node contains code to actually compute the horizontal angle using cross correlation. The code is separated into `processing_server.py` and `cross_corr_fft.py` to separate the ROS interface from the underlying acoustics code, to allow for the processing code to execute without ROS. The ROS node contains an action server using type `custom_msgs/AcousticsProcessing.action`.

### Data Simulation Node

The data simulation node contains code to simulate the saleae and generate data that represents the hydrophones at a specific point. This is used for testing the guessing and processing algorithms. The code is separated into `data_server.py` and `data_sim.py` to separate the ROS interface from the underlying acoustics code, to allow for the processing code to execute without ROS. The ROS node contains an action server using type `custom_msgs/AcousticsData.action`.

3 changes: 3 additions & 0 deletions onboard/catkin_ws/src/acoustics/data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Data Folder

Please place data that you want to process in this folder.
8 changes: 8 additions & 0 deletions onboard/catkin_ws/src/acoustics/launch/acoustics.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<launch>

<node pkg="acoustics" name="acoustics_wrapper" type="acoustics_wrapper.py" output="screen"/>
<node pkg="acoustics" name="saleae" type="saleae.py" output="screen"/>
<node pkg="acoustics" name="acoustics_guesser" type="guess_server.py" output="screen"/>
<node pkg="acoustics" name="acoustics_processor" type="processing_server.py" output="screen"/>

</launch>
18 changes: 18 additions & 0 deletions onboard/catkin_ws/src/acoustics/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<package format="2">
<name>acoustics</name>
<version>0.0.0</version>
<description>
This package performs the processing on acoustics signals.
</description>

<maintainer email="hello@duke-robotics.com">Duke Robotics Club</maintainer>

<license>MIT</license>

<buildtool_depend>catkin</buildtool_depend>
<depend>rospy</depend>
<depend>custom_msgs</depend>
<depend>actionlib</depend>

</package>
Loading

0 comments on commit f78cb02

Please sign in to comment.