How can we Interface between Matlab and ROS - matlab

I have a face recognition program developed in matlab , I want to get results or output in robot operating system (ROS) also installed on my computer both matlab and ROS are on Ubuntu.
How can I interface both matlab and ROS?

There is ROS io matlab package, have a look here
http://www.brendanandrade.com/2014/02/12/ros-i0-getting-started-with-mathworks-new-ros-package-for-matlab-p1/
Matlab 2015 is supporting ROS as well.

You can connect matlab with ROS with the Matlab-ROS toolbox.
There are plenty of matlab-ros guides available, such as:
https://nl.mathworks.com/help/ros/ug/work-with-basic-ros-messages.html
The approach of such guides is commonly:
Set up connection (e.g. set ROS_IP / ROS_MASTER_URI, create a ros-1 core if you have none running yet)
Create a matlab publisher object that streams your data (messagetype of your choice, depending on the results you want to output) on a topic.
Connect other components by setting up subscribers (on matlab or in other frameworks) that listen to updates on the specified topics.
Matlab-ROS-toolbox allows interfacing with ros on both Windows and Linux, which does not require you to install ROS on your device.
Having ROS installed allows various features such as interaction through terminal (e.g. rostopic list).

Related

run a matlab script on a remote server

I have ssh access to a remote linux server and no admin rights. The server does not have matlab installed and I need to run a few matlab scripts. Are there any ways by which I can run these scripts on the server ? I read a few links saying to download the matlab compiler or runtime but they do not have detailed instructions on how to proceed and even less so pertaining to remote servers.
Generally there are three options
install MATLAB (it is available for Linux but you need to have admin rights..)
box your scripts as distributables with the Application Compiler (as #UnbearableLigthness already mentioned). You will need to install the MATLAB Runtime on your Linux server to run those applications. However, you can package the runtime in the application (bulletpoint 3).
create C code with the MATLAB Coder and compile it on your Linux server. This requires no installation but does not support all functions (e.g. most constrained optimization algorithms are not supported)

Using qemu-system-gnuarmeclipse command-line for nrf52840

I want to run unit-tests for a firmware code written for nrf52840 using QEMU. I came across the GNU MCU Eclipse project which has forked the main QEMU project to provide better support for Cortex-M SoCs by allowing the creation of cortex-m devices through data definitions provided in CMSIS SVD files (as noted here). Even though the project primarily supports the STM32 based boards and MCUs, their eclipse plugin does support adding new device packs for development and debugging. But I am not able to figure out how to use their command-line tool qemu-system-gnuarmeclipse to run an ELF file created for nrf52840. I have the following questions:
How does eclipse plugin allow debugging for nrf52840 using custom SVD file even though their command-line tool doesn't have any option to provide a custom SVD file?
How can I add support for nrf52840? Can I reuse board and MCU definitions for STM32 and just provide a JSON variant for SVD file here?
See the discussion here for response to this question

How to do Simulink model run in Raspberry Pi after power on (booting) as standalone?

I build a Simulink model to control Dc motor, load into the board, stop Simulink model and plug out the power and Ethernet cable.
Does the Simulink model that has been loaded in the Raspberry Pi board work alone after Raspberry Pi power on (booting / startup) without running Simulink model again on the computer via Ethernet connection?
I assume you are using the official support package.
You will find a binary application built for your system in your home directory. The name of the folder is identical to the name of your simulink model.
You can use ssh to connect to your raspberry and start the application manually each time you boot the system. If you wish to start it automatically, check this question.
Make sure to stop the application before you use the support package to load a new application, for example when you update your model and built it again.
You can download the latest supportpackage for Raspberry Pi - 18a
They introduced "Run on Boot" feature at the Simulink config set.
You can directly add a model to startup during deployment.
Refer the supportpackage page for more information.

Can I run matlab on raspberry pi?

I have developed a system using signal processing technique in matlab. I want to use raspberry pi to this system.
In this link, they say Octave, Scilab ,FreeMat tools can be used to replace pc with raspberry pi.
Can i use this tools to run signal processing algorithms?
Matlab/Simulink can not run m code directly on raspberries, but you can run Simulink models using the raspberry support package for simulink. This includes Matlab S-Functions, which contain m Code.
The typical workflow is:
Create a simulink model which implements the functionality. Try to generate code and test it if possible on your Pc.
Put in the blocks from the support package to get access to the io of the raspberry. Change the target to the raspberry and built it again.
Download the binary to the raspberry and start it. The application now runs on the raspberry, the pc is not needed.
No it is not possible. MATLAB can only run on Intel x86 architectures, and the Raspberry Pi uses an ARM processor. See here for which platforms MATLAB supports: http://www.mathworks.com/support/sysreq/current_release/.
However, you can use MATLAB to interface with the Raspberry Pi in order to get sensor and image data: http://www.mathworks.com/hardware-support/raspberry-pi-matlab.html
If you want to run signal processing algorithms, if you can, stick with Octave's signal package - http://octave.sourceforge.net/signal/ - and yes it is possible to run Octave on a Raspberry Pi: http://wiki.octave.org/Rasperry_Pi.
Alternatively, try installing NumPy and SciPy together with Python - http://wyolum.com/numpyscipymatplotlib-on-raspberry-pi/ - and use the signal package from that platform: http://docs.scipy.org/doc/scipy/reference/signal.html. NumPy has very similar syntax to MATLAB and it'll take you no time at all to learn it. http://cs231n.github.io/python-numpy-tutorial/
You have lots of alternatives... but unfortunately you can't use MATLAB. Besides which, MATLAB uses Java as the backbone, and running Java on a Raspberry Pi is very slow. Not only that, but MATLAB is several GB large, and to have this program occupy a good chunk of your SD card is very counter productive.
Another option is to use the MATLAB coder or the MATLAB Embedded Coder to generate C code from the MATLAB code. Note that only a sub-set of the MATLAB language supports code generation. That code can then be compiled and run natively on Raspberry Pi.
With the R2018b release of MATLAB, you can deploy your MATLAB code on Raspberry Pi as a standalone executable.
Refer the Deploying MATLAB functions on Raspberry Pi for more information.

How to set up parallell computing in matlab in a local network with 2 computers?

I have the Matlab Parallel Computing Toolbox installed on two computers running Matlab (Macbook Pro i5 and Macbook Pro i7). For a thesis project, we have to shooting simulations, for which I need a lot of computer power. I know about the matlabpool option with parfor to use both cores on my local computer. Is there a way to connect the two macbooks via an ethernet cable or hub directly and configure a small local network so I can use four cores at the same time? How to set this up?
You can only do this if you also acquire the Matlab Distributed Computing Server software. On its own the Parallel Computing Toolbox only provides parallel computation on a single multi-CPU/multi-core computer.
On Mathworks' file exchange there is a package by Markus Buehren called Multicore - Parallel processing on multiple cores which
... provides parallel processing on multiple cores on a single machine or on multiple machines that have access to a common directory.
To run this package, no Matlab toolboxes are needed.
The package is discussed at http://tech.groups.yahoo.com/group/multicore_for_matlab/ (Markus provides user support there too, I guess).