Setup the Raspberry Pi Raspbian OS to be compatible with MATLAB and Simulink support package for Raspberry Pi
Introduction
MATLAB Support package for Raspberry Pi
With MATLAB® Support Package for Raspberry Pi™ Hardware , you can remotely communicate with a Raspberry Pi computer and use it to control peripheral devices. This support allows you to acquire data from sensors and imaging devices connected to the Raspberry Pi.
Simulink Support package for Raspberry Pi
Simulink® Support Package for Raspberry Pi™ Hardware lets you develop algorithms that run standalone on your Raspberry Pi. The support package extends Simulink with blocks to drive Raspberry Pi digital I/O and read and write data from them. After creating your Simulink model, you can simulate it and download the completed algorithm for standalone execution on the device. One particularly useful (and unique) capability offered by Simulink is the ability to tune parameters live from your Simulink model while the algorithm runs on the hardware.
Linux Image for Raspberry Pi
For your Raspberry Pi hardware to be compatible with MATLAB and Simulink support package, the Linux operating system running on the hardware should have all the required software packages and libraries installed. MathWorks ships a custom Linux image for Raspberry Pi. This image comprises of the default Raspbian jessie image with all the required software packages and libraries installed.
MATLAB and Simulink support package for Raspberry Pi also support running Robot Operating System (ROS) on Raspberry Pi. The custom image shipped by MathWorks comes with all the required ROS packages and libraries pre-installed.
Customization of Raspbian image for MATLAB and Simulink compatibility
If you would like to create a Linux image for Raspberry Pi which is compatible with MATLAB and Simulink, you must install required software packages and libraries.
Following is the list of required software packages and libraries
Software Packages
- libsdl1.2-dev
- alsa-utils
- Espeak
- i2c-tools
- libi2c-dev
- Ssmtp
- Ntpdate
- git-core
- v4l-utils
- Cmake
- sense-hat
- Sox
- libsox-fmt-all
- libsox-dev
- libcurl4-openssl-dev
Libraries
- Userland
- WiringPi
- PiGPIO
You can use the shell script to install the required packages and libraries along with the ROS specific packages and libraries. Depending on the version of the Raspbian OS running on your Raspberry Pi, use the following shell scripts.
- For Raspbian Jessie - RaspbianOSSetup_Jessie.sh
- For Raspbian Stretch - RaspbianOSSetup_Stretch.sh
Instructions for Use
- Follow the instructions provided in the Raspberry Pi official documentation page to download and setup Raspbian OS on your Raspberry Pi.
- Copy the Shell script corresponding to your Raspbian version to the Raspberry Pi hardware.
- On the Raspberry Pi terminal, run the shell script. For example
- chmod u+x RaspbianOSSetup_Jessie.sh
- ./RaspbianOSSetup_Jessie.sh
- On completion of the Shell script, restart your Raspberry Pi to complete the setup
Testing
-
Install the MATLAB and Simulink support package for Raspberry Pi in your MATLAB installation.
Use the link to Get Support Packages.
More Information can be found here
-
After successful installation of the support package, connect the hardware to the same network as the host machine running MATLAB.
-
On the MATLAB command prompt, execute the following
myrpi = raspi('Device IP address','Username','password')
-
Device IP address - IP address of your Raspberry Pi
-
Username - Username associated with the login on Raspberry Pi
-
Password - Corresponding password
- After execution, if the command returns a valid Raspi object, the setup for Raspberry Pi is successful.