rfbeam 0.4.9 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +57 -42
- data/lib/rfbeam/cli.rb +18 -16
- data/lib/rfbeam/kld7/cli_formatter.rb +36 -25
- data/lib/rfbeam/kld7/cli_output.rb +16 -7
- data/lib/rfbeam/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a612ea7d8038a09e50462eca0c5acaeb6358992df63d0929e26024dbff5004a9
|
4
|
+
data.tar.gz: e3bbc877194756cd958d3616623fb46bc384ae7e73430a3e096a950efe6ae3c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4663603c15bb5423ee29710e0a743f9f979b7fd57185495062972189533e3c72f07712abb45ba77ea84dff55a6c2bcf72ef4142833195ca6d68f55632249c4a4
|
7
|
+
data.tar.gz: 4af5abb75a3fe9475ab0a4afd988b8fecc2323afc95d3f64f530f359b08ab0f390012a97272545d69d46da9e8051887a24a345b59434afcf90bc18b0312de2de
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -26,75 +26,90 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
26
26
|
|
27
27
|
The RfBeam class will return the path of any connected modules
|
28
28
|
|
29
|
-
|
29
|
+
```ruby
|
30
|
+
RfBeam.connected
|
31
|
+
=> ["/dev/ttyUSB0"]
|
32
|
+
```
|
30
33
|
|
31
|
-
Simple pass the path and baude rate to initialise a new radar object
|
34
|
+
Simple pass the path and optional baude rate (default: 115200) to initialise a new radar object
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
```ruby
|
37
|
+
RfBeam::KLD7.new("/dev/ttyUSB0") do |radar|
|
38
|
+
puts radar.config
|
39
|
+
end
|
40
|
+
=>
|
41
|
+
Software Version: K-LD7_APP-RFB-0103
|
42
|
+
Base Frequency: Low
|
43
|
+
Maximum Speed: 100km/h
|
44
|
+
Maximum Range: 100m
|
45
|
+
Threshold Offset: 30db
|
46
|
+
Tracking Filter Type: Long Visibility
|
47
|
+
Vibration Suppression: 16
|
48
|
+
Minimum Detection Distance: 0%
|
49
|
+
Maximum Detection Distance: 100%
|
50
|
+
Minimum Detection Angle: -10°
|
51
|
+
Maximum Detection Angle: 90°
|
52
|
+
Minimum Detection Speed: 0%
|
53
|
+
Maximum Detection Speed: 100%
|
54
|
+
Detection Direction: Both
|
55
|
+
Range Threshold: 10%
|
56
|
+
Angle Threshold: 0°
|
57
|
+
Speed Threshold: 50%
|
58
|
+
Digital Output 1: Direction
|
59
|
+
Digital Output 2: Angle
|
60
|
+
Digital Output 3: Range
|
61
|
+
Hold Time: 1s
|
62
|
+
Micro Detection Trigger: Off
|
63
|
+
Micro Detection Sensativity: 4
|
64
|
+
```
|
36
65
|
|
37
|
-
## RfBeam::
|
66
|
+
## RfBeam::KLD7 API
|
38
67
|
|
39
68
|
### detection?
|
40
69
|
|
41
70
|
Returns true if the module has a valid detection.
|
42
71
|
|
43
|
-
|
44
|
-
|
72
|
+
```ruby
|
73
|
+
radar.detection?
|
74
|
+
=> true
|
75
|
+
```
|
45
76
|
|
46
77
|
### ddat
|
47
78
|
|
48
79
|
Returns an array with the current detection values
|
49
80
|
|
50
|
-
|
51
|
-
|
81
|
+
```ruby
|
82
|
+
radar.ddat
|
83
|
+
=> ["DDAT", 6, 0, 0, 0, 0, 0, 0]
|
84
|
+
```
|
52
85
|
|
53
86
|
### tdat
|
54
87
|
|
55
88
|
Returns a hash with the current tracked object values
|
56
89
|
|
57
|
-
|
58
|
-
|
90
|
+
```ruby
|
91
|
+
radar.tdat
|
92
|
+
=> ["TDAT", 4, 68, 196, 469, 6303]
|
93
|
+
```
|
59
94
|
|
60
95
|
### grps
|
61
96
|
|
62
97
|
Returns the Parameter settings, values map to setting as detailed in the device datasheet.
|
63
98
|
|
64
|
-
|
65
|
-
|
99
|
+
```ruby
|
100
|
+
radar.grps
|
101
|
+
=> ["RPST", 42, "K-LD7_APP-RFB-0103", 1, 1, 1, 30, 0, 2, 0, 50, -90, 90, 0, 100, 2, 10, 0, 50, 0, 1, 2, 1, 0, 4]
|
102
|
+
```
|
66
103
|
|
67
104
|
### config
|
68
105
|
|
69
106
|
Returns a formatted String of all parameter settings. The only way to read parameter settings is with config
|
70
107
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
Maximum Range: 100m
|
77
|
-
Threshold Offset: 30db
|
78
|
-
Tracking Filter Type: Long Visibility
|
79
|
-
Vibration Suppression: 16
|
80
|
-
Minimum Detection Distance: 0%
|
81
|
-
Maximum Detection Distance: 100%
|
82
|
-
Minimum Detection Angle: -10°
|
83
|
-
Maximum Detection Angle: 90°
|
84
|
-
Minimum Detection Speed: 0%
|
85
|
-
Maximum Detection Speed: 100%
|
86
|
-
Detection Direction: Both
|
87
|
-
Range Threshold: 10%
|
88
|
-
Angle Threshold: 0°
|
89
|
-
Speed Threshold: 50%
|
90
|
-
Digital Output 1: Direction
|
91
|
-
Digital Output 2: Angle
|
92
|
-
Digital Output 3: Range
|
93
|
-
Hold Time: 1s
|
94
|
-
Micro Detection Trigger: Off
|
95
|
-
Micro Detection Sensativity: 4
|
96
|
-
|
97
|
-
## Parameter API
|
108
|
+
```ruby
|
109
|
+
radar.config
|
110
|
+
```
|
111
|
+
|
112
|
+
## Radar Parameters
|
98
113
|
|
99
114
|
### Base Frequency
|
100
115
|
|
@@ -318,7 +333,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
318
333
|
|
319
334
|
## Contributing
|
320
335
|
|
321
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
336
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/robcarruthers/rfbeam.
|
322
337
|
|
323
338
|
## License
|
324
339
|
|
data/lib/rfbeam/cli.rb
CHANGED
@@ -24,39 +24,47 @@ module RfBeam
|
|
24
24
|
puts table.render(:ascii)
|
25
25
|
end
|
26
26
|
|
27
|
-
desc 'config
|
27
|
+
desc 'config [RADAR_ID]', 'Shows the parameter setting for the Radar module'
|
28
28
|
def config(radar_id)
|
29
29
|
puts radar(radar_id).config
|
30
30
|
end
|
31
31
|
|
32
|
-
desc 'reset
|
32
|
+
desc 'reset [RADAR_ID]', 'Shows the parameter setting for the Radar module'
|
33
33
|
def reset(radar_id)
|
34
34
|
@logger.success 'Radar reset to factory defaults' if radar(radar_id).reset
|
35
35
|
end
|
36
36
|
|
37
|
-
desc 'set_param
|
37
|
+
desc 'set_param [RADAR_ID] [KEY] [VALUE]', 'Set radar parameters, see readme for KEYS'
|
38
38
|
def set_param(radar_id, param, value)
|
39
|
-
return @logger.warn("Invalid param: '#{param}'") unless
|
39
|
+
return @logger.warn("Invalid param: '#{param}'") unless Kld7::RADAR_PARAMETERS.include?(param.to_sym)
|
40
40
|
|
41
41
|
r = radar(radar_id)
|
42
42
|
r.send("#{param}=", value.to_i)
|
43
43
|
@logger.success r.formatted_parameter(param.to_sym)
|
44
44
|
end
|
45
45
|
|
46
|
-
desc 'ddat
|
47
|
-
option :stream, type: :boolean, aliases: '-s', desc: 'Stream the data from the device'
|
46
|
+
desc 'ddat [RADAR_ID]', 'stream any valid detections, stop stream with q and enter'
|
47
|
+
option :stream, type: :boolean, aliases: '-s', desc: 'Stream the data from the device, press q to stop'
|
48
|
+
option :raw, type: :boolean, aliases: '-r', desc: 'Display raw data'
|
48
49
|
def ddat(radar_id)
|
49
50
|
cli = RfBeam::Kld7::CliOutput.new(radar_id)
|
50
|
-
cli.display(:ddat,
|
51
|
+
cli.display(:ddat, options)
|
51
52
|
end
|
52
53
|
|
53
|
-
desc '
|
54
|
+
desc 'tdat [RADAR_ID]', 'Display tracked target data'
|
55
|
+
option :raw, type: :boolean, aliases: '-r', desc: 'Display raw data'
|
56
|
+
def tdat(radar_id)
|
57
|
+
cli = RfBeam::Kld7::CliOutput.new(radar_id)
|
58
|
+
cli.display(:tdat, options)
|
59
|
+
end
|
60
|
+
|
61
|
+
desc 'pdat [RADAR_ID]', 'Display Tracked Targets'
|
54
62
|
def pdat(radar_id)
|
55
63
|
cli = RfBeam::Kld7::CliOutput.new(radar_id)
|
56
|
-
cli.display(:pdat,
|
64
|
+
cli.display(:pdat, options)
|
57
65
|
end
|
58
66
|
|
59
|
-
desc 'rfft
|
67
|
+
desc 'rfft [RADAR_ID]', 'Display the dopplar radar data as a plot'
|
60
68
|
option :stream, type: :boolean, aliases: '-s', desc: 'Stream the data from the device'
|
61
69
|
option :raw, type: :boolean, aliases: '-r', desc: 'Display raw data'
|
62
70
|
def rfft(radar_id)
|
@@ -68,12 +76,6 @@ module RfBeam
|
|
68
76
|
end
|
69
77
|
end
|
70
78
|
|
71
|
-
desc 'tdat <radar_id>', 'Display tracked target data'
|
72
|
-
def tdat(radar_id)
|
73
|
-
cli = RfBeam::Kld7::CliOutput.new(radar_id)
|
74
|
-
cli.display(:tdat, stream: options[:stream])
|
75
|
-
end
|
76
|
-
|
77
79
|
private
|
78
80
|
|
79
81
|
def radar(id)
|
@@ -5,46 +5,57 @@ require 'tty-table'
|
|
5
5
|
module RfBeam
|
6
6
|
module Kld7
|
7
7
|
class CliFormatter
|
8
|
+
def self.format(type, data)
|
9
|
+
new.format(type, data)
|
10
|
+
end
|
11
|
+
|
8
12
|
def format(type, data)
|
9
13
|
case type
|
10
14
|
when :tdat
|
11
15
|
tdat(data)
|
12
16
|
when :pdat
|
13
|
-
|
17
|
+
pdat(data)
|
14
18
|
when :ddat
|
15
19
|
ddat(data)
|
16
20
|
end
|
17
21
|
end
|
18
|
-
end
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
def pdat_table(data)
|
24
|
+
table = TTY::Table.new header: ['index', 'dist (M)', 'speed (Km/h)', 'angle (°)', 'mag (db)']
|
25
|
+
count = data[1] / 8
|
26
|
+
data.shift(2)
|
27
|
+
count.times do |index|
|
28
|
+
values = data.shift(4).map { |value| value.to_f / 100.0 }
|
29
|
+
table << [index, values].flatten
|
30
|
+
end
|
31
|
+
table
|
32
|
+
end
|
23
33
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
34
|
+
private
|
35
|
+
|
36
|
+
def ddat(data)
|
37
|
+
labels = ['Detection', 'Micro Detection', 'Angle', 'Direction', 'Range', 'Speed']
|
38
|
+
labels
|
39
|
+
.map
|
40
|
+
.with_index { |label, index| "#{label}: #{DETECTION_FLAGS[to_symbol(label)][data[index + 2]]}" }
|
41
|
+
.join("\n")
|
31
42
|
end
|
32
|
-
table
|
33
|
-
end
|
34
43
|
|
35
|
-
|
44
|
+
def tdat(data)
|
45
|
+
return 'No target detected' unless data[1].positive?
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
.join("\n")
|
43
|
-
|
47
|
+
[
|
48
|
+
"Distance: #{data[2].to_f / 100.0} m",
|
49
|
+
"Speed: #{data[3].to_f / 100.0} km/h",
|
50
|
+
"Angle: #{data[4].to_f / 100.0}°",
|
51
|
+
"Mag: #{data[5].to_f / 100.0} db"
|
52
|
+
].join("\n")
|
53
|
+
end
|
44
54
|
|
45
|
-
|
46
|
-
|
47
|
-
|
55
|
+
def to_symbol(string)
|
56
|
+
modified_string = string.gsub(' ', '_').downcase
|
57
|
+
modified_string.to_sym
|
58
|
+
end
|
48
59
|
end
|
49
60
|
end
|
50
61
|
end
|
@@ -20,8 +20,9 @@ module RfBeam
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def display(type,
|
24
|
-
stream ?
|
23
|
+
def display(type, options)
|
24
|
+
display_method = options[:stream].nil? ? 'display' : 'stream'
|
25
|
+
send("#{display_method}_#{type}", options)
|
25
26
|
end
|
26
27
|
|
27
28
|
def plot(type, stream: false)
|
@@ -79,8 +80,12 @@ module RfBeam
|
|
79
80
|
}
|
80
81
|
end
|
81
82
|
|
82
|
-
def display_ddat
|
83
|
-
|
83
|
+
def display_ddat(options)
|
84
|
+
if options[:raw].nil?
|
85
|
+
puts RfBeam::Kld7::CliFormatter.format(:ddat, @radar.ddat)
|
86
|
+
else
|
87
|
+
puts @radar.ddat.inspect
|
88
|
+
end
|
84
89
|
end
|
85
90
|
|
86
91
|
def stream_ddat
|
@@ -98,11 +103,15 @@ module RfBeam
|
|
98
103
|
end
|
99
104
|
end
|
100
105
|
|
101
|
-
def display_tdat
|
102
|
-
|
106
|
+
def display_tdat(options)
|
107
|
+
if options[:raw].nil?
|
108
|
+
puts RfBeam::Kld7::CliFormatter.format(:tdat, @radar.tdat)
|
109
|
+
else
|
110
|
+
puts @radar.tdat.inspect
|
111
|
+
end
|
103
112
|
end
|
104
113
|
|
105
|
-
def display_pdat
|
114
|
+
def display_pdat(options)
|
106
115
|
table = RfBeam::Kld7::CliFormatter.new.pdat_table(@radar.pdat)
|
107
116
|
puts "\n Detected Raw Targets"
|
108
117
|
puts table.render(:unicode, alignment: :center)
|
data/lib/rfbeam/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfbeam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Carruthers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|