NRP integration with MATLAB


Has anyone integrated Matlab with NRP platform? Since Matlab can be integrated with ROS and Gazebo, I am wondering if Matlab can be used to directly build Control Systems for ROBOTS in NRP.
Any ideas?



I am not aware of someone having used Matlab before in the NRP, but writing an external controller which actuates the robot via ROS sounds plausible.



Hi amdahai!
Since Matlab also offerrs a nice python interface, you could also execute all matlab scripts/simlink models from within a Transfer Function. Check out the Matlab Python site for further details on how to install:

After installation, in your experiment initialize the matlab engine in a TF only for once:

@nrp.MapVariable(“matlab_engine”, initial_value= None, scope=nrp.GLOBAL)
def initMatlab2 (t, matlab_engine):
# initialize matlab if variable is not set
if matlab_engine.value is None:
import matlab.engine
eng = matlab.engine.start_matlab()’/home/user/Desktop/inverseKinematicsDemo’) # add your matlab script path to the matlab search space
matlab_engine.value = eng

Then in another TF you can run your script:
from std_msgs.msg import Float64
import numpy
@nrp.MapVariable(“matlab_engine”, initial_value=None, scope=nrp.GLOBAL)
@nrp.MapRobotPublisher(“m1”, Topic("/robot/hollie_000_joint/cmd_pos", std_msgs.msg.Float64))
def inverseKinematic (t, m1, matlab_engine):
if not(matlab_engine is None) and t > 3:
# call matlab script called “main_static” with some parameters
x = matlab_engine.value.main_static(0.5,0.2,0.01)
# use output to actuate robot: