Skip to content

Commit 1bc7c88

Browse files
authored
Merge pull request #4 from SwarmUS/broken
Readme and parser merge
2 parents fbeb05a + 0c1604c commit 1bc7c88

25 files changed

Lines changed: 753 additions & 5142 deletions

README.md

Lines changed: 137 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,150 @@
1-
# Python Test Bench for the SwarmUS Platform
1+
# TestBench-Python
2+
This repo is the accumulation of many scripts needed in order to calibrate and validate a new set of Beeboard and Hiveboard.
3+
The python scripts are :
4+
- [ExtractRawData](#extractRawData)
5+
- [Parser](#parser)
6+
- [Send_angle_params](#send_angle_params)
7+
- [Visualization](#visualization)
8+
- [Validate](#validate)
29

10+
## Installation
11+
Prerequisites:
312

4-
## Using the graphical tool
13+
- [Python 3.x](https://www.python.org/downloads/)
14+
- [Pip](https://pypi.org/project/pip/)
15+
16+
Each script has its own requirements.txt which permits the installation of the required packages
17+
## Normal order of operation
18+
Follow this flow chart in order to find which script to run depending on your need:
19+
![](img/calibration_flow.png)<br />
20+
## ExtractRawData
21+
This script enables the user to extract the raw DW1000 data from the HiveBoard/BeeBoards assembly. The test-bench will turn by a chosen stepping angle and acquire the desired amount of raw data per step.
22+
#### Hardware setup
23+
- Place a BeeBoards assembly in the middle of the test-bench. The 0deg axis of the assembly needs to point in a parallel fashion to the mounted laser pointer.
24+
- The BeeBoards have to be connected to a HiveBoard mounted to the test-bench using the same cable and ports as labeled on the assembly. If the cables and assembly are not indicated be sure to note which BeeBoards are used, plugged with which cables and in which channel on which HiveBoard. **The calibration will only be valid for this configuration and has to be completly re-performed if any of this component is changed or plugged differently.**
25+
- Connect power and communication interface to the HiveBoard.
26+
- Connect a usb cable to the Arduino.
27+
- Connect power to the drive submodule (red = 12&nbsp;V, white = ground)
28+
- To align the receiver with the emmiter, use the laser pointer. Each laser should point to the alignment target of the other laser assembly. This position ensures a 0 degree relative orientation between the two radio setup.
29+
- The laser mount should be calibrated periodicly to ensure its position and accuracy,
30+
#### Runnning the script
31+
The script can be run from `/src/extractRawData`.<br />
32+
Requires the [TestBench-Arduino](https://swarmus.github.io/SwarmUS-doc/) code to be installed on the test-bench's Arduino in order to be interfaced.
33+
34+
#### Adjustable parameters
35+
`USE_ETHERNET` : If `True`, the communication with the Hiveboard will be done from the Ethernet port. If `False`, the UART interface will be used, and the following line must be edited to match the port on which the Hiveboard is connected.
36+
```python
37+
hb_stream = UsbStream('COM16')
38+
```
39+
The Arduino communicates through UART and the following line must be edited:
40+
```python
41+
testbench = TurningStation('COM15', 115200)
42+
```
43+
`name` : suffix given to the produced CSV with the raw data.<br />
44+
`stepSize` : number of encoder ticks between each acquisition position.<br />
45+
`num_frames` : number of raw data frames to be acquisitioned at each position.<br />
46+
`destination` : ending position of the acquisition. The used encoder has 2048 tick per turn, 2050 should represent a single complete turn.<br />
47+
The data extracted will be saved upon completion of the acquisition once the destination has been reached. The saved data is found in the `/src/data` folder. Each CSV is timestamped and named using the `name` variable.
48+
49+
Once these parameters have been adjusted, the file can be run. The *TurningStation* should turn the amount entered in `step` and then stop for 3-5 seconds for the acquisition period before starting to turn again, repeting this cycle until `destination` has been reached. A complete turn takes usually around 15 minutes.
50+
51+
#### Note
52+
Communication with the HiveBoard is done using the [Pheromones submodule](https://github.com/SwarmUS/Pheromones). If communication problems occur, ensure that the version used by the script is the same as on the HiveBoard.
53+
## Parser
54+
Parses and presents the PDOA values from the previously acquired raw data (from [ExtractRawData](#pxtractRawData)). The user will be prompted 2 clickable interfaces to firstly offset the data to a common reference and secondly to extract the slopes of each antenna pair.
55+
#### Runnning the script
56+
The script can be run from `src/parser`.
57+
#### Adjustable parameters
58+
`dataFolderPath` : folder path where the extracted raw data CSV produced by [ExtractRawData](#pxtractRawData) has been saved.<br />
59+
`dataName` : name of the file to parse the data from.<br />
60+
`usedPairs` : the antenna pairs to be used. Encoded as follow :<br />
61+
<pre><code> pair 0 = antenna 0 - antenna 1<br />
62+
pair 1 = antenna 0 - antenna 2<br />
63+
pair 2 = antenna 1 - antenna 0<br />
64+
....<br />
65+
pair 5 = antenna 2 - antenna 1<br /></code></pre>
66+
`EXPORT_PDOA` : `True` will prompt the second set of plots (slopes extraction) and save the calibration result in a **pickle** format.
67+
#### Behavioral descriptionand user interaction
68+
Upon runnning the script, the first plot to appear will ask the user to select points from which to offset the whole dataset. Theoretically, the plot should represent a **sin** wave, the offset in this section will prevent the signal from wrapping over 2&pi;and under 0. If the **sin** is not wrapping, no points need to be selected, as no offset needs to be applied, simply close the plot.The points selected should then be the very bottom of a **sin** *parabola* section. Also, to obtain a better estimation of the offset needed, it is possible to select the very bottom of the *parabola*, and a top of this *parabola* that has wrapped over. Many points can be selected, the mean of the *y axis* will be used as the offset. This process has to be repeted for the number of `usedPairs` selected. Here is an exemple of the process.<br />
69+
![](img/ex_offset.png)<br />
70+
A plot of the result will then appear. If all curves are not wrapping, the first step is succesful. Otherwise, the script must be re-run and better points must be selected until all curves do not wrap. <br />
71+
72+
The second set of plots is the extraction of the slopes caracteristics. This set will appear only if the `EXPORT_PDOA` has beed set to `True`. A minimum of two lines, and a maximum of three, must be drawn in order to represent the slopes of the data. To draw a line, clic on two points, preferably the farthest appart. Draw at least one line for the rising part and one line for the falling part. This process has to be repeted for the number of `usedPairs` selected. Here is an exemple of the process.<br />
73+
![](img/ex_lines.png)<br />
74+
The saved data will appear in the `dataFolderPath/angleParameters`. Each antenna pair has its own pickle file. These files will also be refered as the **calibration**.
75+
A validation of these files can be done using the `testRead` function from the `Exporter` class.<br />
76+
77+
## Send_angle_params
78+
Communicates to the Hiveboard the slope and caracteristics of the antenna pairs. Uses the pickle files created by [Parser](#parser). These files need to be placed in the calibration folder using the `hb_{HIVEBOARD_ID}` notation.<br />
79+
#### Runnning the script
80+
The script can be run from `/src/send_angle_params`.
81+
#### Adjustable parameters
82+
`HIVEBOARD_ID` : the identification number of the Hiveboard. Can be found either in the flash memory or written on the RJ45 connector. <br />
83+
`MOUNT_ORIENTATION_OFFSET` : the rotation offest, in degrees, applied to the Beeboard assembly between the Test-bench setup at which the calibration was made, and the orientation on the robot or final installation.<br />
84+
`USE_ETHERNET` : If true, the communication with the Hiveboard will be done from the Ethernet port. If false, the UART interface will be used, and the following line must be adjusted to match the port on which the Hiveboard is connected.
85+
```python
86+
hb_stream = UsbStream('COM16')
87+
```
88+
#### Behavioral description
89+
When the script is ran, the parameters in the calibration folder will be sent to the connected Hiveboard and saved in the flash memory. Thus, there is no need to re-send the parameters on every boot cycle. **The calibration should be performed occasionally to ensure the system reliability.**
90+
91+
#### Note
92+
Communication with the HiveBoard is done using the [Pheromones submodule](https://github.com/SwarmUS/Pheromones). If communication problems occur, ensure that the version used by the script is the same as on the HiveBoard.
93+
## Visualization
94+
When a calibration has been completly transfered to the correspondant Hiveboard, this tool can be used to manually and visually confirm the effectiveness of the calibration. Using a emmiter, the user can move around the calibrated Hiveboard/BeeBoards assembly and see a marker representing the emmiter move around.
595

6-
This code repository boasts a graphical tool to visualise the interlocalisation feature.
796
To use the tool, you will need one stationary HiveBoard with its BeeBoards and at least one mobile
897
HiveBoard/BeeBoard assembly.
998

10-
The stationary BeeBoard must be powered by the barrel connector (**not** by USB). Plug the Micro-USB cable to your
99+
The stationary HiveBoard must be powered by the barrel connector (**not** by USB). Plug the Micro-USB cable to your
11100
computer for the serial connection.
12101

13-
Next, start the mobile HiveBoard/BeeBoard assemblies.
102+
Next, start the mobile HiveBoard/BeeBoards assembly.
14103

15-
To start the tool, start the `main.py` file under `src/visualisation_tool`. By default, the visualisation tool will
104+
To start the tool, start `src/visualisation_tool`. By default, the visualization tool will
16105
use the com port `/dev/ttyACM0`. To edit this value, edit the `COM_PORT` variable in `DataUpdater.py`.
17106

18-
The visualisation tool will open a window with an orange dot at the center, representing the stationary HiveBoard. The
19-
mobile HiveBoards will show as coloured circles and their position will be updated at regular intervals. Specific
107+
The visualization tool will open a window with an orange dot at the center, representing the stationary HiveBoard. The
108+
mobile HiveBoard assemblies will show as coloured circles and their position will be updated at regular intervals. Specific
20109
neighbors can be hidden by unchecking the 'visible' check box in the table underneath the graph.
21110

22-
![](img/visualisation_tool.png)
111+
![](img/visualisation_tool.png)
112+
113+
#### Note
114+
Communication with the HiveBoard is done using the [Pheromones submodule](https://github.com/SwarmUS/Pheromones). If communication problems occur, ensure that the version used by the script is the same as on the HiveBoard.
115+
## Validate
116+
This is a method to test the whole angles system of the interlocalisation. Using the exact same hardware setup as the calibration it is possible to extract the angle value result from the whole acquisition, linearisation and certitude algorithm. Using the test-bench assembly will automate this procedure.
117+
#### Runnning the script
118+
The script can be run from `src/validate_interloc`.<br />
119+
Requires the [TestBench-Arduino](https://swarmus.github.io/SwarmUS-doc/) code to be installed on the test-bench's Arduino in order to be interfaced.
120+
#### Hardware setup
121+
Refer to the [ExtractRawData](#extractRawData) hardware setup section for the protocol to ensure precise data acquisition.
122+
#### Adjustable parameters
123+
`REMOTE_HB_ID`: ID of the emmiter used for the validation. As many HiveBoard can be detected, the scripts filters only the one needed by the user.<br />
124+
`NUM_DATA_POINTS_PER_ANGLE`:number of cycles to do at each angle position. Each cycles output a single angle value.<br />
125+
`USE_ETHERNET` : If `True`, the communication with the Hiveboard will be done from the Ethernet port. If `False`, the UART interface will be used, and the following line must be edited to match the port on which the Hiveboard is connected.
126+
```python
127+
hb_stream = UsbStream('/dev/ttyACM0')
128+
```
129+
The Arduino communicates through UART and the following line must be edited:
130+
```python
131+
testbench = TurningStation('/dev/ttyACM1', 115200)
132+
```
133+
`stepSize` : number of encoder ticks between each acquisition position.<br />
134+
`destination` : ending position of the acquisition. The used encoder has 2048 tick per turn, 2050 should represent a single complete turn.<br />
135+
The data extracted will be saved upon completion of the acquisition once the destination has been reached.
136+
137+
#### Behavioral description
138+
Similarly to [ExtractRawData](#extractRawData), the *TurningStation* will turn by the `stepSize` incrementation until it reaches the `destination` encoder tick. At each increment, the interlocalisation is enabled and produces `NUM_DATA_POINTS_PER_ANGLE` angles. These values are the one that would be propagated in the system in a typical use case. For a complete description of the process behind these values, please refer to Swarmus official [interlocalisation documentation]( https://swarmus.github.io/SwarmUS-doc/sections/reference/Interloc/how_it_works/intro/).
139+
140+
#### Results
141+
The saved data is found in the `/src/data` folder. Each CSV is timestamped and named using the "validation_" prefix. For a visual analysis of the data, 3 plots have already been created. Running `src/analysis/analyze_interloc_validation` will produce:
142+
- A representation of the acquired angles for each position.
143+
- The error between the calculated angle and the actual orientation of the emmiter.
144+
- The standard deviation of the angles calculated at each position.<br />
145+
To select which file to analyze, edit :
146+
```python
147+
analyze_validation("../data/validation_hb6.csv")
148+
```
149+
#### Note
150+
Communication with the HiveBoard is done using the [Pheromones submodule](https://github.com/SwarmUS/Pheromones). If communication problems occur, ensure that the version used by the script is the same as on the HiveBoard.

contrib/pheromones

img/calibration.drawio.png

8.34 KB
Loading

img/calibration_flow.png

78 KB
Loading

img/ex_lines.png

54.1 KB
Loading

img/ex_offset.png

52.2 KB
Loading

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ PyQt5 == 5.15.6
66
pyqtgraph == 0.12.3
77
PyQt5-stubs == 5.15.2.0
88
matplotlib == 3.5.0
9-
numpy
9+
numpy
10+
scipy

src/main.py renamed to src/extractRawData.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# To use ethernet, you must have a static IP of 192.168.1.101 on submask 255.255.255.0
1414
USE_ETHERNET = True
15-
distance = "0p024_2mOfficial"
15+
name = "0p024_2mOfficial"
1616
if not USE_ETHERNET:
1717
hb_stream = UsbStream('COM16')
1818
else:
@@ -37,7 +37,8 @@
3737

3838
stepSize = 20
3939
num_frames = 100
40-
for ticks in tqdm(range(0, 2060, stepSize)):
40+
destination = 2060
41+
for ticks in tqdm(range(0, destination, stepSize)):
4142
hb.set_num_angle_frames(num_frames)
4243
data = hb.read_angle_data()
4344

@@ -55,7 +56,7 @@
5556
testbench.resetPosition()
5657

5758
dataframe = pandas.DataFrame(accumulated_data)
58-
dataframe.to_csv('data/' + datetime.now().strftime("%Y%m%d_%H%M%S") +distance+ '.csv')
59+
dataframe.to_csv('data/' + datetime.now().strftime("%Y%m%d_%H%M%S") +name+ '.csv')
5960

6061
hb.kill_receiver()
6162
hb_stream.kill_stream()

0 commit comments

Comments
 (0)