Using LSTM To Navigate Robots

Khushboo Gehi
2 min readJan 2, 2022

Long Short-Term Memory networks or LSTMs are a type of Recurrent Neural Networks that reuse the output of a previous step as an input for the next. They are useful making predictions based on sequences. In writing, for example, the context in which sentences are written is formed based on sequences of words. Another use of LSTMs is in forecasting based on past sequences of events in time-series. Like Convolutional Neural Networks, LSTMs are even used in processing images. This article describes the use of an LSTM network in helping a robot navigate based on data acquired from its front and back sensors. The robot moves clockwise in four directions, along side a wall — forward, slightly left, slightly right and sharp right, using ultrasound sensors. The directions form the classification labels for training, as well as, the output variable for the LSTM network.

The measurements of the distance between two sensors, located on the front and side of the waist of the robot and the wall are used to decide the direction. For example, incase the front sensor measures a larger distance against the wall in front of it, the robot would move forward, meaning that there is more space between the robot and the wall.

The data is preprocessed such that the two columns with measurements from each sensor are organized in timesteps to form the input variable and the labels are transposed such that each time step has a label. Split into train and test, the data is trained using an LSTM using input layer of size 2 (the 2 columns), a Bi-LSTM layer with 100 hidden units, 4 fully connected layer, softmax and the classification output layer.

network_architecture = [
sequenceInputLayer(2)
bilstmLayer(100,"OutputMode","sequence")
fullyConnectedLayer(4)
softmaxLayer()
classificationLayer()]

The network is trained using 3 different options and the best performance at 96.30% accuracy obtained using the following -

training_option=trainingOptions("adam","MaxEpochs",300,"InitialLearnRate",0.05,"Plots","training-progress")

Here is what the performance looks like -

--

--