MATLAB Utilities

 

In addition to our official APIs we also maintain several open source projects to help simplify the prototyping of robotics applications in MATLAB. These are free utilities that function completely independently of our actuators and other APIs.  Enjoy! 

Current projects include:


HebiCam

HebiCam allows users to efficiently access streaming video from a variety of sources. The functionality is similar to MATLAB's IP Camera support package, but with additional support for common formats including h264 and rtsp streaming. 

The code below shows the live video display in Teleop Taxi which used HebiCam in combination with the IP Webcam app running on an Android phone. 

% Connect to camera
cam = HebiCam('http://192.168.0.10:8080/video');

% Continuously gather and display video
I = imshow(cam.getsnapshot);
while true
    I.CData = getsnapshot(cam);
    drawnow;
end

As an example, this project can be used to get live video data from two or more cameras simultaneously for stereo vision.


SharedTransform

SharedTransform and SharedData allow the sharing of data between two MATLAB instances using memory mapped files. This is often useful for cases where two tasks run at different frequencies and need to share data.

% MATLAB instance (writer) 
blob = SharedTransform('blob'); 
blob.setTransform(eye(4));

% MATLAB instance (reader) 
blob = SharedTransform('blob'); 
T = blob.getTransform();

As an example, one instance of MATLAB can control a robot at >100 Hz and react to computer vision input being processed in a separate instance of MATLAB at ~30 Hz.


HebiKeyboard

HebiKeyboard is part of MatlabInput and provides a way to react to keyboard input inside a continuously running control loop. Unlike MATLAB's built-in solutions, the calls are non-blocking and don't require a particular window or figure to be selected.

% Display 'X' button state whenever shift is not down
kb = HebiKeyboard();
while true
    state = read(kb);
    if ~state.SHIFT
        disp(state.keys('x'))
    end
    pause(0.01);
end

HebiJoystick

HebiJoystick is also part of MatlabInput and serves as a drop-in replacement for vrjoystick for users who don't have access to the 3D Animation Toolbox.

% Display pressed buttons
joy = HebiJoystick();
while true
    [axes, buttons, povs] = read(joy);
    if any(buttons)
        disp(find(buttons));
    end
    pause(0.01);
end