Collision detection algorithm in a linear motion for electrical height adjustable tables
MAIN SUBJECT AREA: Computer Engineering AUTHOR: Jimmi Åhnström, Ramsen Nissan SUPERVISOR: Adam Lagerberg JÖNKÖPING 2021 August
1
This final thesis has been carried out at the School of Engineering at Jönköping
University within Computer Engineering. The authors are responsible for the presented
opinions, conclusions and results.
Examiner: Rachid Oucheikh
Supervisor: Adam Lagerberg
Scope: 15 hp (first-cycle education)
Date: 2021-08-15
2
Abstract
The current collision detection system (CDS) that ROL Ergo AB is using for their
height adjustable tables can be improved. The manufacturing process of the legs makes
today's CDS not accurate enough to detect collisions, because the metal that is used in
manufacturing has slight variations between them. This causes frictions across the leg,
which leads to current surges and that could trigger a false positives collision.
This study proposes different methods to solve this problem and methods that could be
used as a new CDS for a height adjustable table, or any other linear moving object. The
proposed methods are: one traditional algorithm with two different thresholds, and two
different AIs.
The two thresholds for the traditional algorithm where one based on a calibration phase
that is static, and one based on shifting all values and comparing against itself. The
algorithm that used the static threshold could not find light collisions in the middle of
the table, but could find all heavy collisions across the table. The algorithm that used
the shifted threshold could find all collisions across the table, both light collisions and
heavy collisions.
The second method based on AI was decision tree and random forest. For this binary
classification problem, the random forest performed better. Both AI algorithms could
find all collisions, however, it had a few false positives that might result in the table
stopping when there is not a collision. While both the traditional algorithm and AI
manage to find all simulated collisions, more testing is required to determine which of
the solutions performs best.
3
Table of content
1 Introduction 7
1.1 PROBLEM STATEMENT 7
1.2 PURPOSE AND RESEARCH QUESTIONS 8
1.3 SCOPE AND LIMITATIONS 9
1.4 DISPOSITION 9
2 Theoretical framework 10
2.1 LINK BETWEEN RESEARCH QUESTIONS AND THEORY 10
2.2 RELATED RESEARCH 10
2.3 Current measurement with shunt resistor 10
2.4 HALL EFFECT SENSOR 11
2.5 SIGNAL PROCESSING AND FILTERS 11
2.6 ALGORITHM FOR RQ1 12
2.6.1 Static Threshold 13
2.6.2 Shifted Threshold 13
2.7 DATA MINING 13
2.7.1 Binary classification with Decision trees 14
2.7.2 Binary classification with Random forest 15
3 Method and implementation 16
3.1 LITERATURE STUDIES 16
3.2 EQUIPMENT 16
3.3 DATA COLLECTION 17
3.3.1 Dataset 18
3.3.2 Collision Simulation data 19
3.4 DATA ANALYSIS 20
4
3.4.1 Analysis RQ1 20
3.4.2 Analysis RQ2 20
3.5 VALIDITY AND RELIABILITY 21
4 Results 22
4.1 RQ1 – SINGLE POLE 22
4.1.1 Data Collection 1 22
4.1.2 Data Collection 2 23
4.1.3 Data Collection 3 24
4.1.4 Data Collection 4 25
4.1.5 Data Collection 5 26
4.1.6 Data Collection 6 27
4.2 RQ1 – SMA 28
4.2.1 Data Collection 7 28
4.2.2 Data Collection 8 29
4.2.3 Data Collection 9 30
4.2.4 Data Collection 10 31
4.3 RQ2 32
4.3.1 Decision tree data collection 33
4.3.2 Random forest data collection 34
5 Discussion 36
5.1 RESULT DISCUSSION 36
5.1.1 Research question 1 36
5.1.2 Research question 2 37
5.2 METHOD DISCUSSION 38
6 Conclusions and further research 39
6.1 CONCLUSIONS 39
6.1.1 Scientific implication 39
5
6.2 FURTHER RESEARCH 40
7 References 41
8 Appendixes 44
6
Abbreviations
CDS Collision detection system
𝑈e Electrical energy in Joule
Up Potential energy in Joule
M Mass in kg
t Time in seconds
g Gravity constant
P Power
L Length in meter
U Voltage
I Ampere
I2C Bus communication
CSV Comma separated values file
AI Artificial Intelligence
SMA Simple moving average
RQ1 Research question one
RQ2 Research question two
7
1 Introduction
ROL Ergo AB has since 1985 developed and produced office equipment and store
interiors to offices and stores across the world. ROL Ergo AB mainly manufactures
height adjustable tables which have a lift capability of 120kg. That force alone is
enough to injure a human or an object if it is in the way when the table is moving.
Figure 1: ROL Ergo AB, Height adjustable table
To prevent an accident, a collision detection system (CDS) is used to stop the table from
injuring or damaging a human or an object. When a collision is detected, the table stops
moving and moves a couple of centimeters in the opposite direction from where the
collision was detected.
The CDS has two different methods to detect a collision. First method is by measuring
the current that is drawn by the motor. If there is a current surge, the table will detect it
as a collision and move in the opposite direction from where it detected the collision.
The second method is by using a piezo sensor that is mounted in the middle of the table
under the tabletop. The data from the piezo sensor are the movement in the tabletop
with a reference to the table stand. This makes the collision easier to detect than the
current sensing, as no disturbance from moving the table or friction is generated.
1.1 Problem statement
The table legs are made of metal tubes. These metal tubes could have slight variations
between them and could be slightly curved at different locations. This could cause
different variations in friction over the length of the metal tube due to small changes in
dimensions between the inner and outer tubes. In the process of manufacturing a leg,
there is a welding process that could contribute to making the tubes more tight, which
leads to more power usage to drive the legs due to that metal can shrink in the welding
process. All of these friction points could trigger the collision detection because of the
rapid power changes between different points in the leg.
8
The CDS that is used today can be improved so it takes the manufacturing process into
consideration. When the CDS is active it could trigger false positive collisions. This is
because every leg that is manufactured is unique, and friction varies between every leg.
When a collision occurs in the center of the table, the force of the collision is divided
over both legs which makes it more difficult to detect a collision. That is why the system
needs to be improved so that a collision can be detected even if there is variation of
friction in the legs.
This study aims to develop a system for collision detection in a linear moving object.
The proposed CDS purpose is to find anomalies in the sampled data and make a binary
decision. This method is used across various other systems and not just for a CDS in a
table. According to Oucheikh et al., (2020) anomaly detection is used in several fields,
for example transport, healthcare, banking fraud and in industrial anomalies detection.
However, when creating the CDS it is difficult to look at other collision-avoidance
algorithms since the CDS for a linear moving object is not similar to the CDS created
for automobiles and robotics (Duy et al., 2020).
1.2 Purpose and research questions
Drawing on the problem statement, it is evident that the collision detection system that
is currently used is not accurate enough to find collisions at different heights. Further,
it is evident that the algorithm that is used today does not consider the manufacturing
process of the legs and the deviations on the raw material. Consequently, the purpose
of this study is:
To find a solution to improve the sensitivity and accuracy of the collision detection
system in a linear motion of an electric height adjustable table.
The collision detection algorithm that is used today is insufficient to find true collisions
in a linear motion, therefore the first research question is:
[1] What kind of algorithm could be used to improve the detection of collisions
in a linear motion?
The raw material that is used in manufacturing could have different variations, therefore
the power usage could vary in the linear motion of the leg. An AI could be used to learn
how the power usage varies across the electrical height adjustable, therefore the second
research question is:
[2] Is there any difference between a binary classification AI and the selected
algorithm from question [1] when used to detect collisions in a linear motion?
9
1.3 Scope and limitations
This study will focus on improving and finding true collisions in a linear motion through
software development and by using existing sensors in the leg by measuring power
usage from the motors.
The study will not use any other type of sensors in order to find collisions in a linear
motion. This is because using more sensors will make the end product more expensive.
Using less parts makes it easier for the end customer to set up the table. The table is
capable of loading 120kg but in our test we will only put a realistic load.
This thesis will not take friction into account in the CDS, since the table is constructed
to have a dynamic load. Therefore, it is hard to determine the friction of the table when
changing the load on the table. There are also several points of friction to take into
consideration which is outside scope for this thesis to calculate. The formula will work
by measuring the power usage from the motor which correlates to the friction.
1.4 Disposition
This study has six additional chapters that will describe the thesis in more detail.
Chapter two is about theoretical framework and gives basic knowledge for the relevant
theories for understanding the technical aspects. Chapter three goes into detail on the
method and implementation, here the studies work process, software, equipment, data
gathering, data analysis and trust ability is described. Chapter four is the results, and
the collected data is presented in the chapter. Chapter five discusses the results and
implications of the study and limitations. Chapter six describes the Conclusions of the
study is presented and suggestions for further research.
10
2 Theoretical framework
2.1 Link between research questions and theory
The following theories were described to get a theoretical foundation for the research
questions and are about DC motors, hall effect sensors, data filtering, data mining
techniques, current measurement, and related research. All chapters up to 2.5 are more
specific for the first research question but could also be applied for the second. Chapter
2.7 is more specific for the second research question and describes data mining and the
chosen binary classification method.
2.2 Related research
The related research papers describe the same problem to improve the CDS without
adding external sensors to keep the costs low. They describe how their model will work
for robotic arms and the collision detection is based on the friction model on the joints
(Lee et al., 2016; Xiao,.al, 2018; Gylling, 2019). This research paper will utilize the
same concept, but the problem statement is that a power usage model is needed for a
linear motion instead of a robotic arm joint.
The related research papers compared a sensorless solution with an external sensor to
get a high validity on their solution (Lee et al., 2016; Xiao,.al, 2018; Gylling, 2019).
Their conclusion was that a sensorless algorithm performs just as good as a solution
with an external sensor. But none of them tried an AI solution for the CDS. In the
conducted research for related work for an AI CDS, no related research was found for
the specific problem.
For the AI solution there are several research papers that utilize different binary
classification methods to solve other kinds of problems. But no papers regarding
something similar to a CDS in a linear motion. Allberg (2018) compares different
frequently used algorithms, and it suggests that the performance is similar when used
for binary classification. It also mentions that large datasets improve the accuracy and
precision of the AI used for classification.
2.3 Current measurement with shunt resistor
A shunt is an electrical device that creates a low-resistance path for electrical current
and is commonly used to measure electrical current (A Guide to Shunt Resistors, n.d.).
When current passes through the shunt resistor, it creates a voltage drop over the shunt
resistor which can be measured, and with ohm’s law U=I*R calculates the current
passing through the shunt resistor (Teschler, 2018). This thesis will utilize a module
with an INA260 current measurement IC (INA, n.d). The IC has an integrated shunt
11
resistor. The current and voltage measurement was used to calculate the power used by
the motor with the following formula: 𝑃 = 𝑈 ∗ 𝐼
2.4 Hall effect sensor
The hall effect sensor is the most common sensor for measuring magnetic fields (Lenz.,
2006). The hall effect sensor is an integrated circuit that varies its output by measuring
the magnetic field passing through the sensor and outputs a logic level signal. The paper
from Forsberg (2016) explains that the hall effect is a manifestation of the Lorentz
force, where the charge carriers in a conductor are sensitive to an external magnetic
field. The Lorentz force is an integration of electric and magnetic force on a point
charge because of electromagnetic fields according to the equation (Britannica, 2020).
F = qE + qv × B
Figure 2: Illustration of the hall effect in a conductor
From the figure 2, you can see a rough scheme of a Hall sensor and its working
principle. As it states in Forsberg (2016) “Negative charge carriers accumulate on one
side of the conductor, and the absence of such on the opposite side results in
accumulation of positive charges. This gives rise to a measurable voltage drop across
the conductor.”. The hall sensor is used in the motors of the table to count pulses. The
pulses are used as a measurement to know at which height the table is at.
2.5 Signal processing and Filters
Before gathering data from electrical components, the data is often required to be
processed in some ways before it can be of any use (Ivanic, 2008). This is called signal
processing and is used in the field of electronics to analyze, modify, or synthesize a
12
signal to improve transmission or subjective quality. Typical devices that help with this
are samplers, signal compressors, digital signal processors and filters.
This study will utilize a first order filter to reduce noise after the data has been collected.
The filter algorithm used is a low pass single pole filter to smooth out the data and is
computationally efficient (Roelandts, 2016). The low pass singe pole algorithm works
by using the following formula:
𝑦[𝑛] = (1 − 𝑑) ∗ 𝑥[𝑛] + 𝑑 ∗ 𝑦[𝑛 − 1]
Where the decay value is d, x[n] is the input, and y[n] is the output of the filter.
The second filter that this study will utilize is a simple moving average (SMA) filter
that calculates the mean of average values (Fernando, 2021). The moving average
formula works by using the following formula, A is measured value in period n, n is
number of periods:
𝑆𝑀𝐴 =𝐴1 + 𝐴2+. . . +𝐴n
𝑛
2.6 Algorithm for RQ1
The algorithm was utilized to detect if there is a collision or not. All values above a
threshold will count as a collision. To set a value suitable as a threshold, the table will
have to collect data (see Appendix 1) while moving up and down without load or
collisions. It can be compared to a calibration phase the first time the table is used.
From the conducted literature research, there was an algorithm from this related study
(Lee et al., 2016). But in this study it is difficult to calculate the friction on the table
because the load can vary which makes it more difficult to determine the friction of the
table. Therefore, this study will use this formula based on potential energy without
taking the friction into account compared to the related study (Lee et al., 2016).
The algorithm for the first research question is modelled by calculating the mass by
using the potential energy and the energy required to move the motor. This was done
using the parameters from the data table described in chapter 3.3.1. The calculation was
based on the following potential energy formula: 𝑈p = 𝑀 ∗ g ∗ 𝐿
Formula to calculate how much energy is needed to move the motor in Joule:
𝑈e = 𝑃 ∗ 𝑡
With these formulas it is possible to calculate the mass that the motors are lifting:
𝑃 ∗ 𝑡 = 𝑀 ∗ 𝐿 ∗ g
13
The algorithm uses this formula to calculate the mass with the collected data. Only
absolute values from the formula, since moving down will result into negative energy:
𝑀 = |𝑃 ∗ Δ𝑡
g ∗ ΔL|
2.6.1 Static Threshold
In chapter 3.3.1 it is described what kind of data that will be collected for the analysis,
and that the datasets with no collisions is used to set a threshold value. The algorithm
implemented uses the threshold value as a reference and if the newly collected data is
greater that the threshold value, it will count that data as a collision.
2.6.2 Shifted Threshold
The shifted threshold is a dynamic threshold based on previous values. It first stores 10
incoming values, and every value after that will be compared against the value that was
stored 10 points behind.
Example of 12 values in an array:
In this case, value 11 will compare its value against value 1, and value 12 will compare
its value against value 2 etc. It works similarly to how a shift graph is implemented
(Erdös et al., 1968). To not let small spikes count as a collision, the threshold is also
increased by 5%.
2.7 Data mining
Data mining should not be confused with the term mining, since it does not have
anything to do with the extraction of data, but rather how you handle data that has been
extracted, and gain new knowledge from it (Han., 2012). Similarly to signal processing,
the goal of data mining is to extract useful information from data sets, but while using
intelligent methods (Clifton, 2019).
The simplified process of extracting useful information are as follows:
1 Pre-processing
2 Data mining
3 Results Validation
14
The pre-processing of raw data includes filtering out noise, merging different data
together and removing duplicates or missing values. The purpose of this is to make it
into an appropriate format for the selected data mining (Tan et al., 2019).
In this report the data mining techniques that will be included are predictive tasks with
classification as its main focus.
2.7.1 Binary classification with Decision trees
A decision tree can be used for both regression and classification problems. The
classification can be divided into binary classification and multi-class classification, but
in this report, only binary classification is used.
The decision tree algorithm can be described as a hierarchical collection of decisions.
It ranks all observations based on relevance and then divides it into successively smaller
groups of observations. The idea is that with each division, the observations in the
groups become increasingly homogeneous (Gordon et al., 2000). The observations in
our case are all different signals or parameters collected, see chapter 3.3.1 for
explanation.
The process of dividing can be compared to a series of questions. The first node or
question is the most relevant, and after each true or false answer, a follow-up question
is asked. This keeps occurring until the tree reaches one conclusion about which class
the observation in question belongs to (Tan et al., 2019).
Figure 3: Overview of how a decision tree could look like and its data set.
15
2.7.2 Binary classification with Random forest
Random forest can also be used for classification. It is an ensemble of decision trees,
therefore the name forest. Meaning the same principle from decision trees applies here.
But to get a slight difference for each decision tree in the forest, some variables or
true/false statements will be slightly modified (randomized). A large part of the
algorithm's accuracy lies in the fact that the randomly generated trees analyze how
common the different labels are (Breiman 2001).
16
3 Method and implementation
Initially a pre study with literature research of previous research is done to get a
comprehensive theoretical foundation. The literature research is used to find and
compare different existing CDS using algorithms and AI/Machine learning techniques,
and it will also make future software development iterations more effective.
The method used in this research is design science. The design science method
describes that an artifact is created first. The artifact in this case is an algorithm for an
electrical height adjustable table, that should be able to detect true collisions in a linear
motion. To succeed with this, an algorithm will be implemented in a Raspberry Pi, that
will collect data at different heights of the leg. The software development will be
implemented iteratively. The different algorithms will later be compared with each
other to check which of them has highest accuracy in finding most true collisions.
3.1 Literature Studies
The information was collected from various sources as below:
• Literature from the university's library database and DIVA database
• Google Scholar for related articles and reports.
• Datasheets for components, articles and explanations from the manufacturer.
Although most of the sources were articles or application notes taken directly from
manufacturers, they were compared with other sources to confirm that the information
was reliable.
3.2 Equipment
An electric height adjustable table was used in this study and is provided by ROL Ergo
AB see figure 4. The height adjustable table used in this study has a main unit that is
used to control the height of the table. It controls the motors in the legs and has a port
to connect a device to move the table up and down. handset is used to control the table
up and down.
17
Figure 4: ROL height adjustable table
The software within the Raspberry pi system is implemented using Python. The
software was used to collect data. The raw data were saved for further analysis on a PC.
The I2C bus described in figure 5 is used to communicate with the current sensing
modules that are connected inside the ECS+ control unit. The current sensing module
utilizes a INA260 IC with integrated shunt resistor (INA, n.d).
Figure 5: Overview of the system
3.3 Data collection
The following data collecting method were used in both research questions, but the data
is analyzed differently. The main function of the raspberry pi is to collect data from
ECS+ box and current sensing modules.
18
The Raspberry pi uses UART communication to interface with the ECS+. The data
collected from the ECS+ are the following:
• Leg one pulses.
• Leg two pulses.
• Moving direction.
To measure the voltage and current drawn, an INA260 module is used for each leg. The
information is then sent by an I2C bus to the raspberry pi. The INA260 is connected in
series to ground for the motor controller and measures the current drawn on the low
side see figure 6. The INA260 is connected inside the ECS+ that has all the logic to
control the legs.
Figure 6: Overview of how the INA260 is connected.
A button is connected to a GPIO of the raspberry pi. The button is used as a control
variable for the algorithms to know if there was a collision there or not.
3.3.1 Dataset
The collected dataset is in CVS format. Each row in the dataset were from the following
attributes: Epoch time, current leg 1, current leg 2, voltage leg 1, voltage leg 2, pulse
leg 1, pulse leg 2, direction and the collision button; that will serve as a control variable
(see Appendix 1).
19
Parameter Explanation
Epoch time Time stamp
Current Leg 1,
Current Leg 2
The current measured from the table's motors. Is an integer
datatype.
Voltage Leg 1,
Voltage Leg 2
Voltage measured across the motor. Is an integer datatype.
Pulse Leg 1,
Pulse Leg 2
The height the leg is currently on.
Direction Moving direction of legs
Collision button A control variable for the algorithms to know if there was a
collision there or not.
Several datasets will be collected, and each dataset will be within the following
categories:
• No collisions moving up.
• No collisions moving down.
• Collisions when moving down.
• Collisions when moving up.
3.3.2 Collision Simulation data
To simulate collisions in the datasets that will be used to test the different algorithms,
obstacles and physical pushes from humans was performed on the table. Both when it
moves upwards and downwards. The weights are placed on different predefined spots
see figure 7 below. When the table is moving upwards, weights are placed of 5 kg and
10 kg. When moving down, a newton meter measuring tool is used to measure
accurately how much force is pressed upwards against the table when it is moving
down.
20
Figure 7: Drawing where obstacles were placed when collecting data, top
view of table
3.4 Data analysis
3.4.1 Analysis RQ1
The data is parsed by reading in the CSV file and processing the data with the algorithm
from 2.6. The output from the algorithm is then filtered through the low pass single pole
filter or SMA filter. It is then compared against the static threshold or shifted threshold.
All the values above the set threshold will count as a collision.
The different filter methods have some parameters that need to be set before they can
be used to filter the raw data. Both the decay parameter and average parameter to the
SMA filter was selected through an iterative process. The chosen values that worked
best to smooth out the data on the graph were selected.
Last step is to present the output on a graph to help with the analysis and show on the
graph where collision occurred. The values shown represents how the algorithm would
behave if implemented practically. For every “X” on the graph the CDS would have
decided that it was a collision, see figure 8 for an example.
The data analysis for RQ1 is implemented in Python programming language.
3.4.2 Analysis RQ2
This method will use the collected data tables and train a decision tree and random
forest algorithm described in chapter 2.7.1 and 2.7.2. The algorithms will decide if it is
a collision or not. The method represented was written in Python programming
language. Using the Jupyter environment (Jupyter, 2021), with libraries from scikit
(scikit, 2021).
The AI will use a large dataset consisting of multiple smaller datasets from the different
experiments mentioned in dataset and collision simulation chapters. The large dataset
will hence contain both collision and non-collision data.
21
The method for training and testing were done using the “train_test_split” function from
scikit. It works by randomly taking different rows from the big dataset and putting it in
four smaller datasets that are used for training and testing. Two datasets are used for
training and two datasets are used for testing.
One dataset for each category will contain all parameters mentioned in chapter 3.3.1
except the collision button parameter. Another dataset for each category will only
contain the collision button parameter. The datasets with the collision button were used
as a correcting sheet, to validate how well the AI performed.
The AI was first tested with standard scaling on, meaning all values from the data table
was converted to a value between 0 and 1. Then tested with standard scaling off. Since
it had better accuracy without standard scaling. All tests and results are from non-
standard scaled values only.
3.5 Validity and reliability
To ensure that the sensors are measuring according to their specification from its
datasheet, they were tested in a lab environment before the data collection started. This
was done to get a higher validity of the data.
The method that was used to collect the data is well documented and the sensors used
in this thesis are accessible. The data processing that is used in this thesis is documented
and choice of data processing is documented for a higher reliability.
By following the methods documented, together with the information from the
theoretical framework. An outsider should be able to reproduce the algorithms and tests,
while also get the same results that is shown in this report.
The algorithm used in this study for RQ1 does not take friction into account. This
makes the output to not be accurate (the absolute value translation of a true event).
Having a friction variable in the calculation would give the accurate result. But for
this problem statement, having an absolute true value would not make the collision
detection perform much different.
22
4 Results
4.1 RQ1 – Single Pole
The following figures for RQ1, chapter 4.1 and 4.2 are displayed as following
Graph Threshold Value Line Color
First graph Threshold Value for leg 1
Collected data for leg1
Threshold leg 1 – Black line
Value leg 1 – Green line
Second graph Threshold Value for leg 2
Collected data for leg2
Threshold leg 2 – Black line
Value leg 2 – Blue line
Third graph Collected data for leg 1
Collected data for leg 2
Collision button
Value leg 1 – Green line
Value leg 2 – Blue line
Button – Black line
The threshold value on the static thresholds, is from a data set without any collisions,
similarly to the ones shown in figure 12. The different values (Value leg 1 and Value
leg 2) shown on the y-axis of the graphs, are the filtered output value from the algorithm
explained in chapter 2.6. All graphs in chapter 4.1 are presented using the single pole
filter, and all graphs in chapter 4.2 are presented using the SMA filter. On the x-axis of
all graphs is the pulses, which represents the height the table is currently on. Using a
time comparison, it takes about 2.5 to 3 seconds to move 100 pulses.
4.1.1 Data Collection 1
The principle from chapter 3.3.2 was used here, and a 5kg weight was placed for a short
period of time from left to right in a slight diagonal. At the same time, the collision
button would be pressed as shown in the last graph of figure 8.
As seen in Figure 8 the x-axis starts at pulse 200 and ends at pulse 1600, meaning the
table is going upwards (higher pulse is higher height). The y-axis starts at 110 KG and
ends at 200 KG. The KG is the output from the algorithm for RQ1, and it was used to
calculate all values from both “Value leg X” and both “Threshold LX”.
The first graph shows the values from leg one, in this case, that is the left leg. The
second graph shows values for leg 2 (right leg), and the third graph is values from both
the legs, but without the threshold.
the threshold value starts around 150 KG and ends at around 140 KG.
As seen the second graphs threshold is slightly higher, meaning that the right leg in the
table that was used, had slightly higher friction across its leg.
23
Figure 8: +5% increase on the threshold value and 5kg collision when table is moving
up, single pole filter
4.1.2 Data Collection 2
This time, a 10kg weight was put on the table for a short period of time from right to
left in a slight diagonal. With the same collision threshold as in the chapter 4.1.1 dataset.
Here all three collisions would have been detected by the algorithm.
24
Figure 9: Threshold +5% increase, and 10kg collision when table is moving up, single
pole filter
4.1.3 Data Collection 3
This data collection is collected according to chapter 3.3.2 where a 5kg weight was used
as collision. Instead of using a static threshold like the previous data collection this time
a shifted threshold was used described in 2.6.2.
As seen in Figure 10 the x-axis starts at pulse 200 and ends at pulse 1600, meaning the
table is going upwards (higher pulse is higher height). The y-axis starts at 110 KG and
ends at 200 KG. The KG is the output from the algorithm for RQ1, and it was used to
calculate all values from both “Value leg X” and both “Threshold LX”.
25
The first graph shows the values from leg one, in this case, that is the left leg. The
second graph shows values for leg 2 (right leg), and the third graph is values from both
the legs, but without the threshold.
Figure 10: Shifted +5% increase, and 5kg collision when table is moving up, single
pole filter
4.1.4 Data Collection 4
This data collection is collected according to chapter 3.3.2 where a 10kg weight was
used as collision. Instead of using a static threshold like the previous data collection
this time a shifted threshold was used described in 2.6.2.
As seen in Figure 11 the x-axis starts at pulse 200 and ends at pulse 1600, meaning the
table is going upwards (higher pulse is higher height). The y-axis starts at 110 KG and
26
ends at 200 KG. The KG is the output from the algorithm for RQ1, and it was used to
calculate all values from both “Value leg X” and both “Threshold LX”.
The first graph shows the values from leg one, in this case, that is the left leg. The
second graph shows values for leg 2 (right leg), and the third graph is values from both
the legs, but without the threshold.
Figure 11: Shifted +5% increase, and 10kg collision when table is moving up, single
pole filter
4.1.5 Data Collection 5
The no collision data was used as a threshold value to detect collision. In figure 12 there
are two datasets with no collision when moving up. Test 1 was one of the first tests
done in the day and the data shows that the threshold is around 140-150 kg. Test 2 was
27
done later in the day, after many other tests made for data collection and the data shows
that the threshold is around 130-140kg. As seen in Figure 12 the x-axis starts at pulse
200 and ends at pulse 1600, meaning the table is going upwards (higher pulse is higher
height).
Figure 12: Overview results of test 1 and test 2 when the table is moving up, single
pole filter
4.1.6 Data Collection 6
Example table with collisions on a table moving downwards (from pulse 1600 to pulse
200). This was made with 4 simulated collisions with a push force of around 200N from
underneath. A digital Newton meter was used to measure the push force.
28
Figure 13: Simulated 200N collisions during downward movement, single pole filter
4.2 RQ1 – SMA
The following graphs are made with the same algorithm, threshold, and datasets as in
chapter 4.1. The only difference is that the SMA filter is used instead as described in
chapter 2.5.
4.2.1 Data Collection 7
The principle from chapter 3.3.2 was used here, and a 5kg weight was placed for a short
period of time from left to right in a slight diagonal. At the same time, the collision
button would be pressed as shown in the last graph of figure 8.
As seen in Figure 14 the x-axis starts at pulse 200 and ends at pulse 1600, meaning the
table is going upwards (higher pulse is higher height). The y-axis starts at 110 KG and
ends at 200 KG. The KG is the output from the algorithm for RQ1, and it was used to
calculate all values from both “Value leg X” and both “Threshold LX”.
The first graph shows the values from leg one, in this case, that is the left leg. The
second graph shows values for leg 2 (right leg), and the third graph is values from both
the legs, but without the threshold. The threshold value starts around 150 KG and ends
at around 140 KG. As seen the second graphs threshold is slightly higher, meaning that
the right leg in the table that was used, had slightly higher friction across its leg.
29
Figure 14: Static threshold +5% increase, and 5kg collision when table is moving up,
SMA
4.2.2 Data Collection 8
This time, a 10kg weight was put on the table for a short period of time from right to
left in a slight diagonal. With the same collision threshold as in the chapter 4.2.1 dataset.
Here all three collisions would have been detected by the algorithm.
30
Figure 15: Static threshold +5% increase, and 10kg collision when table is moving up,
SMA
4.2.3 Data Collection 9
This data collection is collected according to chapter 3.3.2 where a 5kg weight was used
as collision. Instead of using a static threshold like the previous data collection this time
a shifted threshold was used described in 2.6.2.
As seen in Figure 16 the x-axis starts at pulse 200 and ends at pulse 1600, meaning the
table is going upwards (higher pulse is higher height). The y-axis starts at 110 KG and
31
ends at 200 KG. The KG is the output from the algorithm for RQ1, and it was used to
calculate all values from both “Value leg X” and both “Threshold LX”.
The first graph shows the values from leg one, in this case, that is the left leg. The
second graph shows values for leg 2 (right leg), and the third graph is values from both
the legs, but without the threshold.
Figure 16: Shifted threshold +5% increase, and 5kg collision when table is moving
up, SMA
4.2.4 Data Collection 10
This time, a 10kg weight was put on the table for a short period of time from right to
left in a slight diagonal. With the same collision threshold as in the chapter 4.2.3 dataset.
Here all three collisions would have been detected by the algorithm.
32
Figure 17: Shifted threshold +5% increase, and 10kg collision when table is moving
up, SMA
4.3 RQ2
The datasets used in RQ2 is the same data used for RQ1 for collisions when the table
is moving up. The following chapters displays the result for RQ2, and they are presented
using a confusion matrix.
The confusion matrix shows the total values used on the right side. The value here
represents one row from the dataset, as explained in chapter 3.4.2. The row with all its
parameters was either a collision or not. The actual collisions are presented on the
horizontal while the predicted collisions are presented on the vertical.
33
4.3.1 Decision tree data collection
The figure below (figure 18) has 1051 rows with no collisions, and 61 rows with
collisions. The AI then predicted 1039 of the no collisions as no collisions, and 50 true
collisions as collisions. Meaning 12 of the not collisions was wrongly guessed, and 11
of the collision was wrongly guessed.
Figure 18: Overview of the results from decision tree
Figure 19 is the console output when running the AI algorithms from the scikit library.
F1-score is a measurement of the test’s accuracy, and its value is a combination of the
precision and recall values combined. The precision is calculated by having all true
positive results and divided it by the number of all positive results (it also includes the
wrongly identified positives). The recall is calculated by having all number of true
positive results and divided it by the number of all samples that should have been
identified as positive. The support only states how many values of each type there is, in
this case, 1051 no collisions, and 61 collisions. However, this thesis will only discuss
the tests accuracy, and in this particular test it had an accuracy of 98%.
34
Figure 19: Statistics for figure 14.
4.3.2 Random forest data collection
Since the random forest used the same dataset as decision tree, the total number of
collisions and no collisions was the same, meaning 1051 rows with no collisions, and
61 rows with collisions. This time the AI predicted 1047 of the no collisions as no
collisions, and 53 true collisions as collisions. That means that 4 of the not collisions
were wrongly guessed, and 8 of the collision was wrongly guessed.
Figure 20: Overview of the results from random forest
This is the same console output when running the AI algorithms from the scikit library,
but for the random forest test. As explained for figure 19, this thesis will focus on the
test’s accuracy. For the random forest test, its overall accuracy was 99%.
35
Figure 21: Statistics for figure 16.
36
5 Discussion
5.1 Result discussion
The purpose of this study was to find a solution to improve the sensitivity and accuracy
of the collision detection system in a linear motion of an electric height adjustable table.
5.1.1 Research question 1
Analysis of research question 1: What kind of algorithm could be used to improve the
detection of collisions in a linear motion?
The implemented algorithm is inspired from the formulas that was used in the related
research (Lee et al., 2016; Xiao,.al, 2018; Gylling, 2019) for robot arms. However, their
algorithm measures motor torque, but the proposed algorithm for a linear motion
measures mass instead. The reason for measuring mass is because a table or other linear
moving objects is usually made for loading with different weights. Compared to a robot
arm that will not be loaded, and therefore have a similar weight all the time.
By using a similar collision detection using a friction model, as described in related
research (Lee et al., 2016; Xiao,.al, 2018; Gylling, 2019) is difficult to implement. This
is because the friction in table legs were much more varied compared to the friction in
a robot arm. Another thing is that a robot arm has a set weight, but a table is meant to
be loaded with different weights, which also impacts friction.
The reason the related studies (Lee et al., 2016; Xiao,.al, 2018; Gylling, 2019) wanted
to take friction into account is to be able to put a static threshold very close to the signal
values. However, the used motors power varies greatly. This could be due to the
efficiency of the leg, and that the leg heating up makes the efficiency higher. This
happens when moving the table up and down several times without letting the legs cool
down. For this reason, a static threshold is a poor solution. The first test in the figure 12
was collected at the beginning of the day, and the second test was done at the end of the
day. Both, without any weights on them. This shows that the efficiency increases as the
legs heats up and that the data is not consistent.
With about 20-25% motor efficiency, a 5kg will require power to lift 20-25kg. And
with a 10kg, it will require power to lift 40-50kg, like seen in the graphs. If the motor
efficiency was 100%, then adding 5 kg load would result +5kg in graph.
From the results when moving down, see chapter 4.1.6. The algorithm could not detect
a collision when moving down and simulating an obstacle of 200N. Simulating a higher
force would result in the table legs lifting from the floor, meaning no higher power
usage could be achieved and there would be no changes in the output.
As described in the problem statement, the current CDS had troubles detecting
collisions in the center of the table because the load splits up equally between each leg.
But finding collisions at the edges was easier. In figure 8 the light collision was not
37
detected in the center, but the collisions on the side was. If a collision test was done
right after the threshold would have been set, then all collisions would have been
detected.
The shifted threshold was made with the varying efficiency in consideration. What
makes this alternative better is that it does not matter how high or low efficiency the
motors have. Since it compares with itself, rather something pre-defined like the static
threshold. It also has no problem finding collisions in the middle of the table. The
counterpart of this alternative however, is that it will have a slight delay of collision
detection. The finetuning of the increased value and amount shifted must be tested more
thoroughly. But in the example above, it is a delay of 2.0 mm of height. In practice, this
means that the collision occurs, and the table will keep moving 2.0 mm before the
collision is detected.
Comparing the two threshold methods, the shifted threshold has a set delay of 2.0 mm
where the static threshold has a varying delay. This depends on how hard the collision
was. Looking at figure 8 and 14 (5kg collision), the first collision happened around
pulse 380, but it took to pulse 400 before the value got above the threshold, and was
counted as a collision.
Comparing the output from the two different filter algorithms SMA and single pole,
showed no big difference. Both could detect the same collisions. But single pole would
technically be better in practice since it only needs to save a single point in memory.
This is due to how that filter works. The SMA however, needs as many points in
memory as used as “N” value (see chapter 2.5). This will result in a more memory heavy
computation and the first outputs will not be reliable since it does not have enough
points to make a smooth averaging yet.
The proposed solutions that this study has conducted will improve the current solution
used today for detecting collisions in a linear moving object. The solution that is used
only looks at the current draw of the motor without using any type of filtering or
combing it with how fast the table moves. By using filtering and combing how fast the
table moves, the proposed algorithm to detect collisions is more reliable to detect
collisions in a linear moving object compared to the old solution.
5.1.2 Research question 2
Analysis of research question 2: Is there any difference between a binary classification
AI and the selected algorithm from question [1] when used to detect collisions in a
linear motion?
In the confusion matrix (figure 18 and 20) there were a few falsely predicted collisions
and falsely predicted non-collisions. However, if the AI was used practically in a linear
moving object. It would be enough to find one collision point, for each collision. With
an accuracy of 98 and 99 percent, it is safe to say that the AI would find the collision.
38
In the literature studies that were conducted, Allberg (2018) mentioned that an AI
performs similarly when used for binary classification. From the figures 18 to 21 the
results shown in the matrix and statistics align with Allberg’s results. That their
performance is similar. But for this specific classification problem, the random forest
performed slightly better than the decision tree algorithm.
Something to consider is that the AIs train data and test data was based on the collision
button that was human clicked. In the last graph from figure 8 to 17 the collision button
is not precise on where the collision actually occurred. A better reference or answer
sheet for the AI to train on, would likely lead to even better results.
5.2 Method discussion
The conducted research used design science as a research method, design science
describes that an artifact is created. In this case an algorithm that combines the collected
data to set a threshold, which every value above it would count as a collision. The
created artifact was developed iteratively.
Data collected was used to test the algorithm, and the data analysis helped to see how
well the collision detection algorithm worked. Thus, the methods that were chosen
provided the necessary tools to answer the research questions.
The collision button data was both used as a control variable to test how well the
developed algorithm worked and to train the AI to determine if the data correlated with
a collision. Meaning, if the button is not pressed precisely when a collision starts and
ends, could lead to making the AI learn wrong if there is a collision or not. A better way
to train the AI would be to use additional sensors. This could improve the AI to detect
collisions more accurately.
39
6 Conclusions and further research
6.1 Conclusions
In the problem statement it was mentioned that the current solution that exists has
troubles finding collisions in the middle of the table. The created algorithm also had a
hard time to find collisions in the middle during lighter collisions. However, when
implementing the shift threshold version, it could find collisions across all places on
the table.
Since both the created algorithm and the AI could find all collisions, it might not be
necessary to use an advanced AI for problems with few variables and less uncertain
elements.
It is hard to tell if there are any performance differences of the algorithms since the data
was not accurate enough to make a fair judgement. Both algorithms performed good,
and all collisions would be detected from both the created algorithm and the AI.
The AI did classify a small amount of data wrong. However, in a practical scenario, it
would be enough to find one collision point, for each collision. With an accuracy of 98
and 99 percent, it is safe to say that the AI would find the collision. Before testing it in
a practical environment, there is not enough data to judge if it would make any “false
positives” judgements during table usage. The AI would likely be 100% accurate if the
button data were pressed precisely when a collision occurred and ended.
From the results the proposed CDS from this study could only detect collisions when
the table moved up. This is because when placing an obstacle under the table during
downwards movement, the results would be that the table legs would lift. Either the
table would be balancing on the obstacle, or it would cause the table to topple.
Therefore, additional sensors are needed to detect collisions when the table is moving
down.
6.1.1 Scientific implication
The implication of the conducted research shows that it is possible to improve the
collision detection in an electric linear moving object. Both with a regular algorithm
and an AI, without adding any extra sensors that can make the end product more
expensive. This could improve other types of equipment that moves linearly to prevent
collisions or other accidents. Example of a linear moving object could be an elevator or
a scissor lift.
40
6.2 Further research
Both the created algorithm and the AI should be implemented in a linear moving object.
Then tried in an experimental study with practical tests and more precisely made
collisions.
Another thing could be to collect more data at different loads and heights and use it for
testing. Then compare that results to conclude if the algorithms perform better or worse
at specific loads.
This study's goal was to create a CDS without adding more sensors. But further research
could include more sensors and compare its results with the results from this study. Or
use the proposed algorithms from this study together with other sensors to see if it is
possible to improve the collision detection in a linear moving object. By adding other
types of sensors, the CDS could be improved to find collisions when the table is moving
down.
41
7 References
A Guide to Shunt Resistors. (n.d.). RS Components. Retrieved April 11, 2021, from
https://uk.rs-online.com/web/generalDisplay.html?id=ideas-and-advice/shunt-
resistors-guide
Allberg, P. (2018). Applied machine learning in the logistics sector : A comparative
analysis of supervised learning algorithms (Dissertation). Retrieved from
http://urn.kb.se/resolve?urn=urn:nbn:se:bth-16656
Britannica, T. Editors of Encyclopaedia (2020, May 27). Lorentz force. Encyclopedia
Britannica. Retrieved from https://www.britannica.com/science/Lorentz-force
Breiman, L. Random Forests. Machine Learning 45, 5–32 (2001). Retrieved April 12,
2021, https://doi.org/10.1023/A:1010933404324
Boris Ivanic, Användning av accelerometrar för detektering av rörelse i Husqvarna ABs
gräsklippare Automower (2008), Retrived 11 april 2021 from
https://www.diva-portal.org/smash/get/diva2:25523/FULLTEXT01.pdf
Clifton, C. (2019). Data mining. Encyclopedia Britannica. Retrieved April 14, 2021,
from https://www.britannica.com/technology/data-mining
Duy, T. N., Jung, K. H., Ki-Youn Kwon, Ku, N., & Lee, J. (2020). A kinematic collision
box algorithm applied for the anti-collision system of offshore drilling vessels. Journal
of Marine Science and Engineering, 8(6), 420. doi:
http://dx.doi.org.proxy.library.ju.se/10.3390/jmse8060420
Erdős, P. Hajnal, A. (1968), "On chromatic number of infinite graphs", Theory of
Graphs (Proc. Colloq., Tihany, 1966) (PDF), New York: Academic Press, pp. 83–98,
MR 0263693 Retrived from https://www.renyi.hu/~p_erdos/1968-04.pdf
Fernando, J. (2021, April 29). Moving Average (MA) Definition. Retrieved 20 May
2021 from https://www.investopedia.com/terms/m/movingaverage.asp
42
GYLLING, M. (2019). Sensorless collision detection with safe reaction for a robot
manipulator. (Dissertation). Retrieved April 18, 2021, from
http://urn.kb.se/resolve?urn=urn:nbn:se:kth:diva-263829
INA, Retrieved May 10, 2021, from www.ti.com/product/INA260
James Lenz and Alan S. Edelstein, Magnetic Sensors and Their Applications (2006).
Retrieved from
https://www.researchgate.net/publication/3431560_Magnetic_Sensors_and_Their_Ap
plications
Jiawei Han, Micheline Kamber, & Jian Pei. (2012). 1 - Introduction. In Data Mining:
Concepts and Techniques (Third Edition, pp. 1–38). Elsevier Inc.
https://doi.org/10.1016/B978-0-12-381479-1.00001-0
Jupyter, (2021). Retrieved May 10, 2021, from https://jupyter.org/
Lee, SD., Song, JB. Sensorless collision detection based on friction model for a robot
manipulator. Int. J. Precis. Eng. Manuf. 17, 11–17 (2016). Retrieved April 18, 2021,
from https://doi.org/10.1007/s12541-016-0002-3
Oscar Forsberg, Evaluation of Hall-sensors for motor control in high precision
applications for aircraft (2016). Retrived from https://www.diva-
portal.org/smash/get/diva2:940345/FULLTEXT02.pdf
Rachid Oucheikh, Mouhsene Fri, Fayçal Fedouaki, Mustapha Hain, Deep Real-Time
Anomaly Detection for Connected Autonomous Vehicles, Procedia Computer Science,
Volume 177, 2020, Pages 456-461, ISSN 1877-0509,
https://doi.org/10.1016/j.procs.2020.10.062.
scikit, (2021). Retrieved May 10, 2021, from www.scikit-learn.org
Tom Roelandts, Low-Pass Single-Pole IIR Filter, Retrieved May 23, 2021 from
https://tomroelandts.com/articles/low-pass-single-pole-iir-filter
43
Teschler, L. (2018, February 26). Measuring current with shunt resistors. Power
Electronic Tips. Retrieved April 11, 2021, from
https://www.powerelectronictips.com/measuring-current-shunt-resistors/
Tan, P. N., Steinbach, M., Karpatne, A., & Kumar, V. (2019). Introduction to Data
Mining. Pearson Education. ISBN13 9780273769224
Xiao, J., Zhang, Q., Hong, Y., Wang, G., & Zeng, F. (2018). Collision detection
algorithm for collaborative robots considering joint friction. International Journal of
Advanced Robotic Systems. Retrieved April 18, 2021, from
https://doi.org/10.1177/1729881418788992
44
8 Appendixes
Appendix 1 Example of collected data in CSV format