Radar data acquisition, analysis and visualization using - - PowerPoint PPT Presentation

radar data acquisition analysis and visualization using
SMART_READER_LITE
LIVE PREVIEW

Radar data acquisition, analysis and visualization using - - PowerPoint PPT Presentation

. Radar data acquisition, analysis and visualization using reproducible research with Sweave Keun Myoung Lee 1 1 CEWIT Korea The R User Conference 2013, July 10-12 2013 University of Castilla-La Mancha, Albacete, Spain v.02f7 of 2013-07-11


slide-1
SLIDE 1

.

Radar data acquisition, analysis and visualization using reproducible research with Sweave

Vladimir Skvortsov1,2 Keun Myoung Lee1

1CEWIT Korea 2Department of Computer Science, SUNY Korea

The R User Conference 2013, July 10-12 2013 University of Castilla-La Mancha, Albacete, Spain

v.02f7 of 2013-07-11
slide-2
SLIDE 2

Outline

. .

1

Outline

. .

2

Introduction

. .

3

Sweave Introduction Features

. .

4

Radar project Problem Statement Concept Benefits and Goals Hardware

. .

5

Data Acquisition Principles Measurement flow Measurement timings Measurement Setup using C++ Qt software Data acquisition module

. .

6

Data Analysis and Visualization Workflow Data Analysis Examples

useR!2013: Radar DAQ, A&V using Sweave Outline 2 / 63
slide-3
SLIDE 3

Outline

. .

1

Outline

. .

2

Introduction

. .

3

Sweave Introduction Features

. .

4

Radar project Problem Statement Concept Benefits and Goals Hardware

. .

5

Data Acquisition Principles Measurement flow Measurement timings Measurement Setup using C++ Qt software Data acquisition module

. .

6

Data Analysis and Visualization Workflow Data Analysis Examples

useR!2013: Radar DAQ, A&V using Sweave Introduction 3 / 63
slide-4
SLIDE 4

Introduction

. . Reproducible Research (RR) or reproducible data analysis is an approach aiming at complementing classical printed scientific articles with everything required to independently reproduce the results they present. Everything includes data, codes and description of how the code is applied to the data. The idea of RR is popular. The tools for RR implementation are important. R + L

AT

EX= Sweave is the most well-known tool.

useR!2013: Radar DAQ, A&V using Sweave Introduction 4 / 63
slide-5
SLIDE 5

Outline

. .

1

Outline

. .

2

Introduction

. .

3

Sweave Introduction Features

. .

4

Radar project Problem Statement Concept Benefits and Goals Hardware

. .

5

Data Acquisition Principles Measurement flow Measurement timings Measurement Setup using C++ Qt software Data acquisition module

. .

6

Data Analysis and Visualization Workflow Data Analysis Examples

useR!2013: Radar DAQ, A&V using Sweave Sweave 5 / 63
slide-6
SLIDE 6

Sweave

slide-7
SLIDE 7

R + LaTeX= Sweave

. . ”Sweave provides a flexible framework for mixing text and S code for automatic document generation. A single source file contains both documentation text and S code, which are then woven into a final document containing the documentation text together with the S code and/or the

  • utput of the code (text, graphs)” – Freidrich Leisch

Created in 2002. It is called ‘S-weave’ not ‘R-weave’ because R is an implementation of the S language.

useR!2013: Radar DAQ, A&V using Sweave Sweave 7 / 63
slide-8
SLIDE 8

R + LaTeX= Sweave

⋆ Sweave is based on literate programming (LP) approach and has syntax that is similar to the noweb ⋆ A function in R ⋆ Allows mixing a code (R) with text written in (LaTeX) ⋆ Takes advantage of both LaTeX typesetting capabilities and R’s computational strengths ⋆ Sweave is simple if you know both R and L

AT

EX ⋆ A file is simple text one consisting of a sequence of code segments (called chunks) and documentation segments ⋆ Enables the generation of dynamic documents ⋆ R code is executed first and the output embedded when the document is generated ⋆ Enables a modularity of code using \SweaveInput{module.Rnw} command and code chunks reuse ⋆ Reproducible research tool

useR!2013: Radar DAQ, A&V using Sweave Sweave 8 / 63
slide-9
SLIDE 9

Sweave Workflow

  • 1. A Sweave file has the extension Rnw. This is a plain text file which has both L

AT

EX code and R code all in one (also called a noweb file). For instance we start with example.Rnw

  • 2. Compile the Sweave file with R in order to produce a tex file:

example.Rnw

R (using Sweave function)

− − − − − − − − − − − − − − − − − − − → example.tex

  • 3. Compile the tex file with one of the most popular engines like pdfL

AT

EX , XeL

AT

EX or LuaL

AT

EX in order to obtain your final document: example.tex

pdflatex

− − − − − − − → example.pdf

  • 4. Display the example.pdf file.

. All the workflow is usually done with one command, e.g. in TeXmaker (Ubuntu/Linux) software: . .

R CMD Sweave %.Rnw|pdflatex -synctex=1 -interaction=nonstopmode -shell-escape %|pdflatex -synctex=1

  • interaction=nonstopmode -shell-escape %|evince %.pdf

Make sure Sweave.sty is in your texmf path (or in your working directory)

useR!2013: Radar DAQ, A&V using Sweave Sweave 9 / 63
slide-10
SLIDE 10

Our Development Workflow

  • 1. Add code to R script for data analysis using

RStudio, Rgedit or other IDE

  • 2. Test the code
  • 3. When the code debugging is complete, add the

tested code to Sweave document

useR!2013: Radar DAQ, A&V using Sweave Sweave 10 / 63
slide-11
SLIDE 11

Sweave Tools Comparison

Features Software Tools Notes TeXmaker (v3.4.1) RStudio (v0.96.316) Sweave support yes yes LaTeX syntax high- lighting yes yes LaTeX custom build yes (full) yes (very limited) R syntax highlighting no, partial[1] yes (R chunk has different background)

1R

code chunk has the same FG color LaTeX navigation yes no R code navigation yes, partial yes Own PDF viewer yes yes Dockable internal PDF viewer yes no (opens a separated window) synctex support yes yes not all view- ers Total score: yes (8), no (1) yes (7), no (2)

useR!2013: Radar DAQ, A&V using Sweave Sweave 11 / 63
slide-12
SLIDE 12

R + LaTeX= Sweave

Sweave document is .Rnw text file which includes both R and L

AT

EX code. \documentclass[a4paper]{article} \title{Sweave Example 1} \author{Vladimir Skvortsov} \begin{document} \maketitle Here is a linear regression example: <<>>= set.seed(123) # reproducibility x <- rnorm(50); y <- 5*x + rnorm(50) model <- lm(y~x); summary(model) @ R code chunk Sweave embeds all the results! \end{document}

useR!2013: Radar DAQ, A&V using Sweave Sweave 12 / 63
slide-13
SLIDE 13

Sweave Options for R code chunks «...»=

⋆ name: user-specified – Specify name of chunk ⋆ eval: TRUE, FALSE – Evaluate chunk? ⋆ echo: TRUE, FALSE – If it is TRUE, in addition to output, R input is incorporated into the typeset document ⋆ term: TRUE, FALSE – Emulates R session? ⋆ results: verbatim, tex, hide – Output? Chunks with ’tex’ will be treated as LaTeX code ⋆ fig: TRUE, FALSE – Chunk produces figure/graphics? ⋆ include: TRUE, FALSE – Automatically generate \includegraphics statement . . example: .

<<results, echo=FALSE, term=TRUE, results=tex>>= # empty @

useR!2013: Radar DAQ, A&V using Sweave Sweave 13 / 63
slide-14
SLIDE 14

Sweave: Including Figures

⋆ One can generate one figure per chunk of code if fig=TRUE and include=TRUE a includegraphics LaTeX command is generated. ⋆ Sweave dump the figures into current document directory during the run. ⋆ To have more control over the figure including, we can create a figure environment after the chunk to put figures in. ⋆ To have a full control over inclusion of graphics, we have to create and include pdf or png files manually.

useR!2013: Radar DAQ, A&V using Sweave Sweave 14 / 63
slide-15
SLIDE 15

Sweave: Including Figures - The Simplest Way

<<fig1plot,echo=TRUE,fig=TRUE,include=TRUE>>= library("graphics") x <- rnorm(50) y <- 5*x+rnorm(50) plot(x, y) @

useR!2013: Radar DAQ, A&V using Sweave Sweave 15 / 63
slide-16
SLIDE 16

Sweave: Including Figures - More Control

<<fig1plot2,echo=TRUE,fig=TRUE,include=FALSE>>= library("graphics") x <- rnorm(50) y <- 5*x+rnorm(50) plot(x, y) @ with some LaTeX include parameters ... \begin{figure} \begin{center} \includegraphics[height=5cm,width=5cm] {filename-fig1plot2} \caption{Scatter plot} \label{fig:scatter2} \end{center} \end{figure}

useR!2013: Radar DAQ, A&V using Sweave Sweave 16 / 63
slide-17
SLIDE 17

Sweave: Including Figures - Full Control

<<fig1plot3,echo=FALSE,results=hide>>= require("grDevices") # pdf size (width and height) in inches! pdf(file="fig1plot3.pdf", width=6, height=5) x <- rnorm(50) y <- 5*x+rnorm(50) plot(x, y) dev.off() @ with some LaTeX include parameters ... \begin{figure} \centering % width and height have to be in inches here too! \includegraphics[width=6in, height=5in]{fig1plot3} \caption{Scatter plot} \label{fig:scatter3} \end{figure}

useR!2013: Radar DAQ, A&V using Sweave Sweave 17 / 63
slide-18
SLIDE 18

Sweave: Including Figures - Extreme Embedding

Embedding images with an encoding algorithm ⋆ Encode your image (e.g. myfigure.png) using Base64 encoding algorithm ⋆ Put the text based Base64 code in an filecontents environment (filecontents package) which writes it to a file ⋆ Add to preamble (-shell-escape is active and use an external script) \newcommand{\generateimage}[2]{% \immediate\write18{convert.cmd #1 > #2}} ⋆ Add to document \generateimage{myfigure.txt}{myfigure.png} \includegraphics{myfigure.png} source: http://tex.stackexchange.com/questions/21541/ embedding-images-with-an-encoding-algorithm

useR!2013: Radar DAQ, A&V using Sweave Sweave 18 / 63
slide-19
SLIDE 19

Sweave: Including Figures - Full Control w. Font Embed.

<<fig1plot4,echo=FALSE,results=hide>>= require("grDevices") # pdf size (width and height) in inches, check if the "NimbusRom" font family exists! pdf(file="fig1plot4.pdf", width=6, height=5, family="NimbusRom", useDingbats=FALSE) x <- rnorm(50) y <- 5*x+rnorm(50) plot(x, y) dev.off() embedFonts("fig1plot4.pdf", outfile = "fig1plot4-ef.pdf") # outfile is the name of the new file (with fonts embedded) @ with some LaTeX include parameters ... \begin{figure} \centering % width and height have to be in inches here too! \includegraphics[width=6in, height=5in]{fig1plot4-ef} \caption{Scatter plot} \label{fig:scatter3} \end{figure}

useR!2013: Radar DAQ, A&V using Sweave Sweave 19 / 63
slide-20
SLIDE 20

R - checking for available fonts

Check a list of installed fonts in R (Ubuntu 12.04):

> require("grDevices") > names(pdfFonts()) [1] "serif" "sans" "mono" [4] "AvantGarde" "Bookman" "Courier" [7] "Helvetica" "Helvetica-Narrow" "NewCenturySchoolbook" [10] "Palatino" "Times" "URWGothic" [13] "URWBookman" "NimbusMon" "NimbusSan" [16] "URWHelvetica" "NimbusSanCond" "CenturySch" [19] "URWPalladio" "NimbusRom" "URWTimes" [22] "Japan1" "Japan1HeiMin" "Japan1GothicBBB" [25] "Japan1Ryumin" "Korea1" "Korea1deb" [28] "CNS1" "GB1"

useR!2013: Radar DAQ, A&V using Sweave Sweave 20 / 63
slide-21
SLIDE 21

R - access to all system fonts

A way to have access to all system fonts is to install and use extrafont package:

install.packages("extrafont") library(extrafont) font_import() Check a list of fonts: fonts() ... ## [11] "Courier New" "Georgia" ... Create a pdf file with embedded font: require("extrafont") loadfonts() # In Windows, in each R session where you embed fonts, # you will need to tell R where Ghostscript is installed. if (.Platform$OS.type == "windows") { Sys.setenv(R_GSCMD="C:/gs/gs9.06/bin/gswin64c.exe") } pdf(file="fig1plot4.pdf", width=6, height=5, family="Georgia", useDingbats=FALSE) x <- rnorm(50) y <- 5*x+rnorm(50) plot(x, y) dev.off() embed_fonts("fig1plot4.pdf", outfile = "fig1plot4-ef.pdf")

source: http://blog.revolutionanalytics.com/2012/09/how-to-use-your-favorite-fonts-in-r-charts.html useR!2013: Radar DAQ, A&V using Sweave Sweave 21 / 63
slide-22
SLIDE 22

Outline

. .

1

Outline

. .

2

Introduction

. .

3

Sweave Introduction Features

. .

4

Radar project Problem Statement Concept Benefits and Goals Hardware

. .

5

Data Acquisition Principles Measurement flow Measurement timings Measurement Setup using C++ Qt software Data acquisition module

. .

6

Data Analysis and Visualization Workflow Data Analysis Examples

useR!2013: Radar DAQ, A&V using Sweave Radar project 22 / 63
slide-23
SLIDE 23

“Virtual Fence” radar project

slide-24
SLIDE 24

Problem Statement

⋆ To date, the art of protecting areas has been via the installation of perimeter fencing, multiple perimeter cameras, and security personnel watching monitors and walking the perimeter fencing ⋆ Relying on human beings and visible weather conditions are not sufficient solutions to fully protect property from vandalism, theft in today’s environment ⋆ Environment conditions may vary a lot, as day-night time, making any

  • nly-one-detector not practical so that without additional sensors and

sensor fusion (e.g. infrared or radar ones) the system is not reliable ⋆ Wired solutions require a building of more serious infrastructure ⋆ Some sensors can only detect motion - not stationary objects

useR!2013: Radar DAQ, A&V using Sweave Radar project 24 / 63
slide-25
SLIDE 25

Concept

useR!2013: Radar DAQ, A&V using Sweave Radar project 25 / 63
slide-26
SLIDE 26

Benefits and Goals

Benefits Goals ⋆ The system replaces the need for building a fence, multiple perimeter cameras and security guards watching monitors or walking perimeters ⋆ Radar technologies have made a big progress and it is continued, a cost and size are day-by-day reduced (silicon microwave radars, due to a mass production) ⋆ Radars work in various environments ⋆ Various radar post-processing and imaging algorithms can help in system tuning and improvement ⋆ The system will have a compact size ⋆ Application area is wide ⋆ Creation of virtual fence concept to reduce investments into building infrastructure ⋆ Development of system node prototype with continuous working cycle, making it easy configurable ⋆ Use a mass-product (automotive) radar to reduce a system cost and simplify a system implementation; use a standard gain horn antenna ⋆ Evaluation of radar performance (e.g. range measurement and its resolution) ⋆ Investigation of post-processing algorithms ⋆ Evaluation of processing times of various measurement procedures ⋆ Experimental studies

useR!2013: Radar DAQ, A&V using Sweave Radar project 26 / 63
slide-27
SLIDE 27

Hardware (FMCW radar)

useR!2013: Radar DAQ, A&V using Sweave Radar project 27 / 63
slide-28
SLIDE 28

Target Ranging Experiment Setup

useR!2013: Radar DAQ, A&V using Sweave Radar project 28 / 63
slide-29
SLIDE 29

FMCW measurement principle

⋆ FMCW (frequency modulated continuous wave) radar generates an RF signal (using linear frequency sweep). ⋆ The received signal is then mixed with the emitted signal and due to the delay there will be a frequency difference that can be detected as a signal in the low frequency range.

⋆ Due to the delay ∆t caused by the distance traveled by the emitted signal to the reflector and back to the receiver, there will be a small difference in signal frequency between the two RF signals that is an IF(Intermediate Frequency)-signal with frequency ∆f or fIF.

useR!2013: Radar DAQ, A&V using Sweave Radar project 29 / 63
slide-30
SLIDE 30

Basic Measurement Setup

useR!2013: Radar DAQ, A&V using Sweave Radar project 30 / 63
slide-31
SLIDE 31

Intermediate frequency fIF

For linear (in time) output RF signal, a simplified expression of the IF signal with the frequency fIF is: fIF = BW T · 2d c , where ⋆ d is the distance between the radar antenna and the reflector and ⋆ c is the speed of light.

Typical values for the RS3400 radar would be a frequency sweep of BW = 1500 MHz in T = 75 ms corresponding to a sweep rate of kf = BW/T = 20000 MHz/s. A distance between the radar and a reflector of d = 15 m gives a delay of ∆t = 0.1 µs and then the IF signal frequency is fIF = 2001 Hz.

⋆ If several reflectors are appearing in the measurement, the resulting IF signal will contain a superposition of the individual IF-signals from the echoes. ⋆ The different echoes are distinguished by their unique IF signal frequency. ⋆ Fourier Transform (FT) of the sampled signal can be used to extract the distances to the different echoes.

useR!2013: Radar DAQ, A&V using Sweave Radar project 31 / 63
slide-32
SLIDE 32

Actual range measurement resolution

The actual range resolution (∆da) is dependent on sampling frequency, a number of points and bandwidth, finally it gives the expression ∆da = fs L · c 2 · µ, where µ = BW/Tmod is the modulation coefficient, Tmod - the modulation time; fs - the sampling frequency, L - the number of points (signal length).

⋆ If we consider that L = 1501, fs = 20000 Hz, BW = 1.5 × 109 Hz and Tmod = 7.5 × 10−4 s, then ∆da ≈ 0.1 m (frequency resolution ∆f = 13.3 Hz) and ⋆ if L = 301 ⇒ ∆da ≈ 0.5 m (∆f = 66.4 Hz).

useR!2013: Radar DAQ, A&V using Sweave Radar project 32 / 63
slide-33
SLIDE 33

Signal processing in time domain

A signal h(t) in the time domain may be represented by its spectrum H(f) in the frequency domain. The relations between h(t) and H(f) are given by the Fourier transform analysis and synthesis (inverse transform) equations: H(f) = ∫ ∞

−∞

h(t)e2πift dt, h(t) = ∫ ∞

−∞

H(f)e−2πift dt. If the signal h(t) is sampled at evenly spaced intervals, there is an equivalent transform for sampled signals called the discrete time Fourier transform (DTFT), then the transform is given by: Hn =

N−1

k=0

h(k)e2πift/Ndt, hk = 1 N

N−1

n=0

H(f)e−2πift/Ndt.

useR!2013: Radar DAQ, A&V using Sweave Radar project 33 / 63
slide-34
SLIDE 34

Post-processing algorithm

. Algorithm . .

Require: Select x array size of radar data using power-of-two rule, e.g. 29 = 512 points (fs = 20 kHz gives a maximum detectable frequency fIF = 10 kHz and 75 m range) procedure PerceptualHash(x)

  • 1. Apply low-pass filter to reduce high frequency noise.
  • 2. Compute the FFT (or high resolution FT). The FFT separates the mixer output into a

collection of frequencies and scalars.

  • 3. Take all x values or divide frequencies into bands (a number of the bands depends on

the required sensitivity) then compute the mean FFT value for all values or separately within the bands (excluding the first DC term)

  • 4. Set the hash bits to 0 or 1 depending on whether each of the FFT values is above or

below the average value. The result will not vary as long as the overall structure of the radar data remains the same.

  • 5. Construct the hash ph(x)* (e.g. set the n bits into a n-bit integer.

return ph(x) end procedure

(*) The perceptual hash values can be compared using the Hamming distance algorithm (comparing each bit position and counting the number of differences).

useR!2013: Radar DAQ, A&V using Sweave Radar project 34 / 63
slide-35
SLIDE 35

Outline

. .

1

Outline

. .

2

Introduction

. .

3

Sweave Introduction Features

. .

4

Radar project Problem Statement Concept Benefits and Goals Hardware

. .

5

Data Acquisition Principles Measurement flow Measurement timings Measurement Setup using C++ Qt software Data acquisition module

. .

6

Data Analysis and Visualization Workflow Data Analysis Examples

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 35 / 63
slide-36
SLIDE 36

Data Acquisition

slide-37
SLIDE 37

Principles ⋆ The data acquisition is essential part of any experimental study ⋆ The software application for the radar is built around serial terminal application ⋆ The software has two versions: C++ with Qt library and R ⋆ The R version is used as a high level test lab for all algorithms which, in case of successful result, then are ported to C++ for higher execution speed on embedded hardware ⋆ There are several choices for serial data acquisition in R

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 37 / 63
slide-38
SLIDE 38

Measurement Flow with Continuous Mode

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 38 / 63
slide-39
SLIDE 39
  • Meas. Timings (desktop, C++

Qt, Ubuntu 11.04)

No. Procedure Duration (ms) Initialization (one time run only, it is not part

  • f measurement cycle), sum for 4 commands

105 1 Measurement start and OK confirmation 38 2 Data receiving and OK confirmation (for 301 points) 537 3 Data post-processing (FFT) and visualization 38 Sum (measurement cycle only): 613

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 39 / 63
slide-40
SLIDE 40

Measurement Setup using C++ Qt software

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 40 / 63
slide-41
SLIDE 41

Software (C++ Qt): Linux desktop and embedded

Qt Creator C++ IDE and QSerialPortTerminal (radar I/O SW)

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 41 / 63
slide-42
SLIDE 42

Software (C++ Qt): Demo app

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 42 / 63
slide-43
SLIDE 43

Measurement Setup with High Level Interface using R

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 43 / 63
slide-44
SLIDE 44

Data acquisition module 1

There are several choices for serial data acquisition in R: ⋆ The scan function is typically the first choice if we have only basic requirements however some external operation is still required to set serial port characteristics. ⋆ There is another way using a patch as described in [Shotwell2011] to add a tty connection to R within any POSIX compliant OS. However the patching is required. ⋆ In addition, there is an access to the serial port from within the Tcl interpreter which is integrated in R with package tcltk so that data can be read into R in real time. ⋆ In this work, due to some software/hardware requirements, we decided to proceed with more sophisticated method using low-level interface to Java VM with R package rJava and RXTX native library providing serial communication for the JDK as shown in [Jean-Robert2012]. The development was done using Eclipse/Java as IDE.

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 44 / 63
slide-45
SLIDE 45

Data acquisition module 2 ⋆ The Java interface class was built to write commands and read the data making use of the events to avoid polling the radar. ⋆ The Java class is exposed to R with help of rJava package ⋆ The R script has 2 modes of data import:

▶ file import (data saved earlier) ▶ radar data acquisition (new data)

⋆ The R version is used as a high level test lab for all algorithms which, in case of successful result, then are ported to C++ for higher execution speed on embedded hardware

RXTX library source: http://rxtx.qbang.org/wiki/index.php/Main_Page

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 45 / 63
slide-46
SLIDE 46

SerialRadar - RXTX based Java class

  • Fields
▶ OutputStream out; ▶ SerialReader input; ▶ SerialPort serialPort; ▶ private static String command; ▶ private static String radar_buffer; ▶ static int counter = 0; ▶ static String port_name;
  • Methods
▶ public SerialRadar() ▶ void connect ( String portName )

throws Exception

▶ public static void

setCommand(String s)

▶ public static String getCommand() ▶ public static void

setRadarBuffer(String s)

▶ public static String

getRadarBuffer()

▶ public synchronized void close() ▶ public float[] radarData() ▶ static void listPorts() ▶ static String getPortTypeName( int

portType )

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 46 / 63
slide-47
SLIDE 47

SerialReader - RXTX based Java class

  • Fields
▶ String buffer_string; ▶ String radar_buffer_string = ””; ▶ private BufferedReader

inStream;

  • Methods
▶ public

SerialReader(InputStream in)

▶ public void

serialEvent(SerialPortEvent arg0)

▶ public String

writeAndGet(String command)

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 47 / 63
slide-48
SLIDE 48

Radar commands to get data

INIT SWEEP:MEASURE ON SWEEP:NUMBERS 1 SWEEP:NUMBERS ? (0 is default; continuous) FREQUENCY:POINTS 301 FREQUENCY:POINTS 1501 (default) FREQUENCY:POINTS ? SWEEP:IDLE ? (default: 5.000000e-05) TRIG:ARM TRACE:DATA ?

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 48 / 63
slide-49
SLIDE 49

Sweave - rJava based Serial Interface

1 require(rJava) 2

# .jinit initializes the Java Virtual Machine (JVM).

3

# This function must be called before any rJava functions can be used.

4 .jinit(classpath= ’SerialRadar.jar’, parameters= ”−Xmx512m”) 5 radarJava <− .jnew(’SerialRadar’, check=TRUE) 6 .jmethods(radarJava, ”SerialRadar”) 7

# [Ubuntu] using USB−Serial converter port

8 .jcall(radarJava, returnSig=’V’, method=”connect”, ”/dev/ttyUSB0”) 9 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”INIT\r”) 10 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”SWEEP:MEASURE ON\r”) 11 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”SWEEP: NUMBERS 1\r”) 12

# * set a number of points (default: 1501)

13 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”FREQUENCY: POINTS 1501\r”) 14 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”TRIG:ARM\r”) 15 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”TRACE:DATA ?\r”) 16 rdata <− .jcall(radarJava, returnSig=”[F”,”radarData”)

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 49 / 63
slide-50
SLIDE 50

Sweave - rJava based Serial Interface

1 require(rJava) 2

# .jinit initializes the Java Virtual Machine (JVM).

3

# This function must be called before any rJava functions can be used.

4 .jinit(classpath= ’SerialRadar.jar’, parameters= ”−Xmx512m”) 5 radarJava <− .jnew(’SerialRadar’, check=TRUE) 6 .jmethods(radarJava, ”SerialRadar”) 7

# [Ubuntu] using USB−Serial converter port

8 .jcall(radarJava, returnSig=’V’, method=”connect”, ”/dev/ttyUSB0”) 9 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”INIT\r”) 10 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”SWEEP:MEASURE ON\r”) 11 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”SWEEP: NUMBERS 1\r”) 12

# * set a number of points (default: 1501)

13 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”FREQUENCY: POINTS 1501\r”) 14 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”TRIG:ARM\r”) 15 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”TRACE:DATA ?\r”) 16 rdata <− .jcall(radarJava, returnSig=”[F”,”radarData”)

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 49 / 63
slide-51
SLIDE 51

Sweave - rJava based Serial Interface

1 require(rJava) 2

# .jinit initializes the Java Virtual Machine (JVM).

3

# This function must be called before any rJava functions can be used.

4 .jinit(classpath= ’SerialRadar.jar’, parameters= ”−Xmx512m”) 5 radarJava <− .jnew(’SerialRadar’, check=TRUE) 6 .jmethods(radarJava, ”SerialRadar”) 7

# [Ubuntu] using USB−Serial converter port

8 .jcall(radarJava, returnSig=’V’, method=”connect”, ”/dev/ttyUSB0”) 9 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”INIT\r”) 10 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”SWEEP:MEASURE ON\r”) 11 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”SWEEP: NUMBERS 1\r”) 12

# * set a number of points (default: 1501)

13 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”FREQUENCY: POINTS 1501\r”) 14 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”TRIG:ARM\r”) 15 ret <− .jcall(radarJava, returnSig=’S’, method=”writeAndGet”, ”TRACE:DATA ?\r”) 16 rdata <− .jcall(radarJava, returnSig=”[F”,”radarData”)

useR!2013: Radar DAQ, A&V using Sweave Data Acquisition 49 / 63
slide-52
SLIDE 52

Outline

. .

1

Outline

. .

2

Introduction

. .

3

Sweave Introduction Features

. .

4

Radar project Problem Statement Concept Benefits and Goals Hardware

. .

5

Data Acquisition Principles Measurement flow Measurement timings Measurement Setup using C++ Qt software Data acquisition module

. .

6

Data Analysis and Visualization Workflow Data Analysis Examples

useR!2013: Radar DAQ, A&V using Sweave Data Analysis and Visualization 50 / 63
slide-53
SLIDE 53

Data Analysis and Visualization

slide-54
SLIDE 54

Data Processing Workflow

  • 1. Make a measurement
  • 2. Acquire data from radar (specify a number of

points to return from radar)

  • 3. Apply FFT analysis to the data using fft function
  • f stats package
  • 4. Calculate a distance to the target(s) (optional:

and/or speed of the target(s))

useR!2013: Radar DAQ, A&V using Sweave Data Analysis and Visualization 52 / 63
slide-55
SLIDE 55

Running R with gedit R plugin (Rgedit)

useR!2013: Radar DAQ, A&V using Sweave Data Analysis and Visualization 53 / 63
slide-56
SLIDE 56

Sweave Example: 3 distances to target

500 1000 1500 40000 45000 50000 55000 sample # Mixer output

1 (10 cm) 2 (100 cm) 3 (200 cm)

useR!2013: Radar DAQ, A&V using Sweave Data Analysis and Visualization 54 / 63
slide-57
SLIDE 57

Sweave FFT analysis for 3 distances to target

. .

FFT analysis of the experimental data using frequency and phase response with variation of distance to target:

  • 1, d = 10cm
  • 2, d = 100cm
  • 3, d = 200cm

d - distance to target

50 100 150 80 90 100 120 sample # Magnitude, dB

4, 130.26 15, 125.05 25, 123.12

1 (10 cm) 2 (100 cm) 3 (200 cm) 50 100 150 −2 −1 1 2 sample # Phase

useR!2013: Radar DAQ, A&V using Sweave Data Analysis and Visualization 55 / 63
slide-58
SLIDE 58

Sweave Example: radar, 3 Algorithms Signal Analysis

. .

Lab experiments with the target at 10 cm using 3 different algorithms for signal analysis:

  • FFT
  • CZT (Chirp Z

Transform, 4 times res. increase comp. to FFT)

  • HRFT (High

Resolution Fourier Transform), shown in frequency range of 13.3-186.4 Hz, 5 times res. increase comp. to FFT)

frequency, Hz Magnitude, dB 100 200 300 400 60 80 100 120 140 4, 39.947, 137.753

FFT CZT HRFT

100 200 300 400 −3 −2 −1 1 2 frequency, Hz Phase

useR!2013: Radar DAQ, A&V using Sweave Data Analysis and Visualization 56 / 63
slide-59
SLIDE 59

Sweave Example: radar, hash bits of 6 tests with 512 points

1 64 128 192 256 320 384 448 512 1 2 3 4 5 6 hash bits 1

(2nd bit map shows the biggest difference - the intruder is presented)

useR!2013: Radar DAQ, A&V using Sweave Data Analysis and Visualization 57 / 63
slide-60
SLIDE 60

Demo: Dynamic Report Generation - Radar Test

. . PDF source:figure-radar-test-20130329-144628-ef.pdf .

500 1000 1500 35000 50000

raw data

sample # Mixer output

50 100 150 60 100 140 [FFT] First target has been found at d = 0.17 m frequency, Hz Magnitude, dB

6, 6, 138.218

This report has been generated by Sweave on 2013−03−29 14:46:46

useR!2013: Radar DAQ, A&V using Sweave Data Analysis and Visualization 58 / 63
slide-61
SLIDE 61

Sweave Example: raw, FFT; target ranging (42.4 m)

500 1000 1500 44000 48000 52000

sample # Mixer output

[Analysis] First target has been found at d = 42.4 m

Magnitude, dB

60 80 100 120 140 1 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 sample # 426, 5659.1, 114.9 signal clutter SCR+100 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 f, Hz 2 4 6 8 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 d, m useR!2013: Radar DAQ, A&V using Sweave Data Analysis and Visualization 59 / 63
slide-62
SLIDE 62

Conclusions

⋆ Sweave tools are not perfect yet, so that still requires a lot

  • f manual coding (however there are good separate LaTeX

and R tools) ⋆ To take advantage of the Sweave (literate programming) approach, you have to know both R and LaTeX ⋆ Relating to rJava use, there is a problem, when each Java update overwrites the installed RXTX libraries; you have to set several paths to avoid ”[name] not found” message ⋆ You can keep track of results, output and codes in one place. ⋆ You can redirect your text and code to various forms of

  • utput and dynamically (automatically) generate or update

various documents: presentations, reports, and books. ⋆ You can reproduce your results. The chances are very high!

useR!2013: Radar DAQ, A&V using Sweave Conclusions 60 / 63
slide-63
SLIDE 63

Conclusions

⋆ Sweave tools are not perfect yet, so that still requires a lot

  • f manual coding (however there are good separate LaTeX

and R tools) ⋆ To take advantage of the Sweave (literate programming) approach, you have to know both R and LaTeX ⋆ Relating to rJava use, there is a problem, when each Java update overwrites the installed RXTX libraries; you have to set several paths to avoid ”[name] not found” message ⋆ You can keep track of results, output and codes in one place. ⋆ You can redirect your text and code to various forms of

  • utput and dynamically (automatically) generate or update

various documents: presentations, reports, and books. ⋆ You can reproduce your results. The chances are very high!

useR!2013: Radar DAQ, A&V using Sweave Conclusions 60 / 63
slide-64
SLIDE 64

Conclusions

⋆ Sweave tools are not perfect yet, so that still requires a lot

  • f manual coding (however there are good separate LaTeX

and R tools) ⋆ To take advantage of the Sweave (literate programming) approach, you have to know both R and LaTeX ⋆ Relating to rJava use, there is a problem, when each Java update overwrites the installed RXTX libraries; you have to set several paths to avoid ”[name] not found” message ⋆ You can keep track of results, output and codes in one place. ⋆ You can redirect your text and code to various forms of

  • utput and dynamically (automatically) generate or update

various documents: presentations, reports, and books. ⋆ You can reproduce your results. The chances are very high!

useR!2013: Radar DAQ, A&V using Sweave Conclusions 60 / 63
slide-65
SLIDE 65

Conclusions

⋆ Sweave tools are not perfect yet, so that still requires a lot

  • f manual coding (however there are good separate LaTeX

and R tools) ⋆ To take advantage of the Sweave (literate programming) approach, you have to know both R and LaTeX ⋆ Relating to rJava use, there is a problem, when each Java update overwrites the installed RXTX libraries; you have to set several paths to avoid ”[name] not found” message ⋆ You can keep track of results, output and codes in one place. ⋆ You can redirect your text and code to various forms of

  • utput and dynamically (automatically) generate or update

various documents: presentations, reports, and books. ⋆ You can reproduce your results. The chances are very high!

useR!2013: Radar DAQ, A&V using Sweave Conclusions 60 / 63
slide-66
SLIDE 66

Conclusions

⋆ Sweave tools are not perfect yet, so that still requires a lot

  • f manual coding (however there are good separate LaTeX

and R tools) ⋆ To take advantage of the Sweave (literate programming) approach, you have to know both R and LaTeX ⋆ Relating to rJava use, there is a problem, when each Java update overwrites the installed RXTX libraries; you have to set several paths to avoid ”[name] not found” message ⋆ You can keep track of results, output and codes in one place. ⋆ You can redirect your text and code to various forms of

  • utput and dynamically (automatically) generate or update

various documents: presentations, reports, and books. ⋆ You can reproduce your results. The chances are very high!

useR!2013: Radar DAQ, A&V using Sweave Conclusions 60 / 63
slide-67
SLIDE 67

Conclusions

⋆ Sweave tools are not perfect yet, so that still requires a lot

  • f manual coding (however there are good separate LaTeX

and R tools) ⋆ To take advantage of the Sweave (literate programming) approach, you have to know both R and LaTeX ⋆ Relating to rJava use, there is a problem, when each Java update overwrites the installed RXTX libraries; you have to set several paths to avoid ”[name] not found” message ⋆ You can keep track of results, output and codes in one place. ⋆ You can redirect your text and code to various forms of

  • utput and dynamically (automatically) generate or update

various documents: presentations, reports, and books. ⋆ You can reproduce your results. The chances are very high!

useR!2013: Radar DAQ, A&V using Sweave Conclusions 60 / 63
slide-68
SLIDE 68

For Further Reading

Zahn, I. Learning to Sweave in APA style. The PracTeX Journal, No. 1, 2008.

URL: http://tug.org/pracjourn/2008-1/zahn/

Shotwell, M. Experimenting with a tty connection for R. In useR! 2011 The R User Conference, Coventry, UK, 2011. Jean-Robert. A thermometer in R using Arduino and Java. Personal blog, 2012.

URL: http://jean-robert.github.com/2012/11/11/thermometer-R-using-Arduino-Java.html

Skvortsov, V., K. M. Lee, and S. E. Yang. Inexpensive Radar-Based Surveillance: Experimental Study. In 9th International Conference & Expo on Emerging Technologies for a Smarter World - CEWIT2012, Songdo, Incheon, Korea, 2012.

useR!2013: Radar DAQ, A&V using Sweave Bibliography 61 / 63
slide-69
SLIDE 69

Final

Thank you!

This presentation has been created using Sweave (XeL

A

T EX and R) and is based on Incheon LaTeX Beamer style template!

slide-70
SLIDE 70

Link

http://bit.ly/1dofwtn