---
# System prepended metadata

title: pin-inspector.introction
tags: [introduction, transformer-pipeline, pin-inspector]

---

###### tags: `transformer-pipeline` `pin-inspector` `introduction`

# pin-inspector.introction

**整脚后引脚检测**

用于检测整脚后的变压器是否仍存在引脚不良

[TOC]

## temp

about k: 电压的一个单位对应物理的一，一丝=0.01mm，`丝/1个读数单位`

about x offset: 以内侧激光测距仪为基准，外测的相对偏移量（光栅尺方向、电机方向）

```
k:-6.32496744e-04

```

可能会有这种情况，圆会拟合到上半部分，考虑用判定一下是否圆心小于平均值

![](https://i.imgur.com/4cMcixu.png)

**实验结果缓存**

整个激光测距仪的数据非常的依赖与针脚的距离是否合适，调整时保证变压器在正中位置时能够稳定即可

## codes

### [pin-analyzer.test_vt3](http://gitlab.sho.hypereal.com/robotic/pin-analyzer/tree/test_vt3)

```c 
//record data
test_client.py

//for calibration
pin_inspector_get_k.py 
pin_inspector_get_x_offset.py
pin_inspector_get_y_offset.py
```

### [transformer-pipeline.test_pin_inspector_online](http://gitlab.sho.hypereal.com/robotic/transformer-pipeline/tree/pin_inspector_test_machine)

## calibration

> [origin version](https://docs.google.com/document/d/1EyHpowRUUNk0ByNS8flumy6wC0IqT6TcH2gvWeCUfpk/edit#) [name=陈易平]

### calibrate k value

step 1, in pin_analyzer, retrieve realtime adc value by using

```
python3 pin_analyzer/test_client.py
```

step 2, write down the ADC value and the total thickness of sliders, put them to a text file

step 3, redo to get more ADC value using different totalthickness of sliders, then we get the all record into a file, something like

```
2935.3446896459764 15
2938.887459163944 15
6134.095006333756 13
6134.096939795986 13
9268.84698979932 11
9268.829188612573 11
12431.636109073937 9
12432.950996733116 9
... // 5..10
```

step 4, calibrate with these record using:

```
python3 pin_inspector_get_k.py
```

step 5, check k, about 6 * 10^-4

### calibrate x offset


step 1, place a cylinder on the pin inspector platform

step 2, make sure that this cylinder can be detected by lasers lie both sides

step 3, record data

```
cd build
mkdir sample
/bin/sample_pin_inspector
```

step 4, check data, channels & circles, ensure that you can write down a range which only contains the two circles, asume that rangea is $[8000, 15000]$，and chanels are $5$ and $7$

```
python3 tools/visualize_pin_inspector.py
```

![](https://i.imgur.com/DcjmNbS.png)


step 5, write config

```
lower_limit
uppder_limit
chanels //from outter side to the inner side
```


step 6, calibrate & sample output

```
python3 pin_inspector_get_x_offset.py

32.47104626852157 //in mm
```

![](https://i.imgur.com/mMe9kfj.png)


### calibrate y offset
config


step1, use the phneumatic claw to seize a standard slider, then

```
cd build
mkdir sample
/bin/sample_pin_inspector
```

step 2, check data, channels & 2 target lines, ensure that you can write down a range which only contains the two lines

```
python3 tools/visualize_pin_inspector.py
```

chanels are $5$ and $7$, rangea is $[10000, 15500]$

![](https://i.imgur.com/8kzXMjw.png)


step 3, write config

```
kThicknessOfMiddleSlider
kThicknessOfSideSlider
lower_limit
uppder_limit
chanels //from outter side to the inner side
```

step 4, calibrate

```
python3 pin_inspector_get_y_offsert.py

-13.59174925040592 //mm
```

## test ( python version )

the number in following picture shows 10 pins of A451
```
6_7 __ _ _8_9   inner side
###########
####A451###
###########
0_1_2_3_4_5   outter side
```

step 1, do "二次元" calibration，get the position and picture of pins

```
圆1
内容             测量值            名义值            超差值            上公差            下公差            状态             
圆心X            38.8593        38.8593        0.0000         
圆心Y            45.8104        45.8104        0.0000    ....
...
```

![](https://i.imgur.com/WaMRWCG.jpg)


step 2, use sliders to adjust the Y-position of laser devices, make sure that pins of both sides of the transformer can be detected by laser devices

step 3, record data

```
sample_pin_inspector.cpp
```

step 4, test 

:::warning
there are more than one entrance inside the main function of script, make sure that you are runing the script using the entrance you wanted
:::

```python
# python3 pin_visualizer.py
if __name__ == '__main__':
    show_extract_round_pins(folder, kSpeed, kObjId, kPosId, kFrontAdcId, kBackAdcId, True)
    # show_extract_flat_pins(folder, kSpeed, kObjId, kPosId, kFrontAdcId, kBackAdcId, True)
    # show(folder, kSpeed, kObjId)
```

![](https://i.imgur.com/hS9ReX2.png)

step 5, compare ( python version )

将二次元的数据和上一个步骤的数据放在一起（最好记录成实验文档，备查

![](https://i.imgur.com/dbKr45O.png)

拷贝出来到一个文件里准备运行对比程序

![](https://i.imgur.com/NAHRAr9.png)

配置好后运行运行代码：

```
python3 minimize_compare.py
```

效果较差：

![](https://i.imgur.com/rciEQ9m.png)

效果较好：

![](https://i.imgur.com/9e3fQE8.png)

## compare ( cpp version )



## 项目主要问题

激光测距仪+算法拟合出的针脚足够精确：
- 多次实验存在的误差？（之前初步测试过标准差约在 0.几 丝）
- 和二次元结果的误差？
- 可容忍的误差范围？

- 激光测距仪（高速模式）在要求速度下的稳定性？

算法可优化？
- 比如之前计算 loss 时选择的标准（avg 或 max）
- 优化范围过滤，过滤掉无关区间

如何保证

**硬件问题**

**软件问题**

