anchor.diff:  While there aren't many, there are at least a few companies that offer MATLAB interfaces for some of their products. These libraries are typically only useful to customers who bought a particular product.
   ////
   
  +// Add section on "Comparison" and how we used a typical low-level feedback loop as example?
  +
   == Distributed Systems
   
  +// Add some info here related to distributed systems and interface evolution / common pain points? Using several MATLAB instances that work together wth C++ processes?
   
   === Lightweight Communication and Marshalling (LCM)
   
  -https://lcm-proj.github.io/tut_matlab.html[LCM] is a message passing framework that was developed at http://www.mit.edu/[MIT] in 2006 for their entry to DARPA's Urban Challenge. In the robotics community it became a popular alternative to ROS and was as far as we know the first messaging framework that supported MATLAB as a core language. Its MATLAB bindings were implemented in Java and did not contain any actual MATLAB code.
  -
  -The interface exposed two Java classes as well as generated message types.
  -
  -* The https://github.com/lcm-proj/lcm/blob/master/lcm-java/lcm/lcm/LCM.java[LCM] class provided a way to publish messages and subscribe to channels
  -* The https://github.com/lcm-proj/lcm/blob/master/lcm-java/lcm/lcm/MessageAggregator.java[MessageAggregator] class received messages from a background thread and queued them for MATLAB
  -* The generated Java messages handled the binary encoding and exposed fields that MATLAB can access
  -
  -By receiving messages on a background thread and by moving the encoding and decoding steps to the Java language, the main thread was able to spend most of its time on actually working with the data. Publishing a message could look as follows.
  +https://lcm-proj.github.io/tut_matlab.html[LCM] is a message passing framework that was developed at http://www.mit.edu/[MIT] in 2006 for their entry to DARPA's Urban Challenge. In the robotics community it became a popular alternative to ROS and was as far as we know the first messaging framework that supported MATLAB as a core language. We found its implementation to be comparatively simple and would recommend it as a starting point when developing new interfaces.
  +
  +The snippet below shows how the MATLAB code for sending a command message could look like. The code creates a struct-like _message_, sets some values, and publishes it on a selected channel. The encoding and transmission steps are hidden.
   
   [source,matlab]
   ----
  
positive.code: 
  This poses a problem for real-time control because all communication with hardware is forced to happen synchronously in the main thread. For example, if we were to run a loop at 100Hz and it took a message ~8ms for a round-trip, the main thread would spend 80% of the available time budget waiting for a response without doing any actual work.
  
  A second hurdle is that while MATLAB is very efficient in the execution of math operations, it is not particularly well suited for byte manipulation. This makes it difficult to develop code that can efficiently create and parse binary message formats that the target hardware can understand.
  
  [.text-center]
  .Single-Threaded Communications
  image::matlab/comms-single-threaded.png[link="{imagesdir}/matlab/comms-single-threaded.png", width="100%"]
  
  After having the main thread spend its time on waiting for and parsing the incoming data, there may not be any time left for performing interesting math operations. Pure MATLAB implementations do work for simple applications, such as interfacing with an Arduino to gather temperature data or blink an LED, but it is not feasible control complex robotic systems at reasonable rates.
  
  Fortunately, MATLAB does have the ability to interface with other programming languages that allow users to create background threads in order to offload the communications aspect from the main thread. This frees MATLAB to focus on the calculations that it has been optimized for.
  
  [.text-center]
  .Multi-Threaded Communications
  image::matlab/comms-multi-threaded.png[link="{imagesdir}/matlab/comms-multi-threaded.png", width="100%"]
  
  Out of the box MATLAB provides two interfaces to other languages:  https://www.mathworks.com/help/matlab/matlab_external/introducing-mex-files.html[MEX] for calling C++ code, and the https://www.mathworks.com/help/matlab/matlab_external/product-overview.html[Java Interface] for calling Java code. There are some differences between the two, but at the end of the day the choice mostly comes down to personal preference. Both provide enough capabilities for developing sophisticated interfaces and have orders of magnitude better performance than required.  There are additional interfaces to https://www.mathworks.com/help/matlab/calling-external-functions.html[other languages], but those require additional setup steps.
  
  There are two general approaches to integrate MATLAB with hardware. The most common way is to setup a distributed system in which the actual hardware communication is done in a separate process, and data is exchanged with MATLAB through a messaging framework such as ROS-messaging. This is often easier to develop and typically results in a relatively hardware agnostic interface. However, it does burden the users with setting up the rest of the system. The alternative approach is to create a standalone implementation that runs entirely within MATLAB.
  
  ////
  == Message Passing Frameworks
  
negative.code: lc = lcm.lcm.LCM.getSingleton();
  
  % Fill message
  cmd = types.command();
  cmd.position = [1 2 3];
  cmd.velocity = [1 2 3];
  
  % Publish
  lc.publish('COMMAND_CHANNEL', cmd);
  ----
  
  Receiving messages is done by subscribing an _aggregator_ to one or more channels. The aggregator receives messages from a background thread and stores them in a queue that MATLAB can access in a synchronous manner using _aggregator.getNextMessage()_. Each message contains the raw bytes as well as some meta data for selecting the appropriate type for decoding.
  
  [source,matlab]
  ----
  