How to Use DDS Middleware with Simulink - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 11:33
Loaded: 0.21%
Stream Type LIVE
Remaining Time 11:33
 
1x
  • Chapters
  • descriptions off, selected
  • captions off, selected
      Video length is 11:32

      How to Use DDS Middleware with Simulink

      See a workflow for integrating DDS communication into your model and generating a deployable application.

      Published: 1 Feb 2022

      Today, I want to talk to you about using DDS Middleware with Simulink. DDS Blockset it was introduced in release 2021a. It is part of the Simulink product family. And yes, you can see you can access more information about this product from our main page in mathworks.com.

      What is DDS? DDS is a middleware that was introduced by Object Management Group. It uses a service oriented architecture. And uses a public subscribed communication mechanism. This is a very flexible communication system that has been widely adopted in many of the applications ranging from aerospace, defense, automotive, robotics, et cetera.

      DDS uses a layered architecture. It runs on many operating systems ranging from Windows, to Linux, and Mac. Also to many of the embedded systems. It is built on a layer of protocol, presentation layer, and some C++ APIs. The application generated from the Simulink model uses these third party libraries that implement the DDS protocol. And you can actually generate the code directly from Simulink using the DDS Blockset.

      There are many vendors providing the DDS interface-- the DDS libraries. Notably the two ones are RTI and eProsima. The two platforms that are supported out of the box in DDS Blockset. The DDS Blockset provides apps and blocks that you can use to simulate the application. And then, finally, generate the code. It uses a dictionary. Simulink dictionary built on top of this Simulink dictionary called the DDS dictionary that helps you manage all the DDS definitions.

      You can import and export many of the definitions. And of course with embedded coder, you can emit the C++ code. It fully integrates with all the APIs provided by RTI Connect and eProsima.

      Now let's talk about DDS Blockset features. Before I talk about it, here's a typical workflow that one would use. You would have some definitions that you would have in XML. Mainly in format. Or any of the formats created through third party vendors like RTI system designer, et cetera. You would input those definitions into the Simulink dictionary. And then we also have a UI that shows you the definitions that you have imported.

      Once you have imported, you can then use it in your application as an imported data type on the inputs and outputs. And then you can map onto what the topics you are using. And then finally once you're happy with the design, you can generate code using embedded coder. And along with it, will also create the IDL XML file required for the third party vendors.

      Couple of key features. There is a quickstart application accessible from the Simulink tool strip. And you can use that to get your model quickly set up. There is also an readily available take and right DDS Blocks that will enable you to convert the messages coming in into signals and vise versa. You can also simulate all the QoS. A couple of QoS policies when using the built in queue blocks.

      Furthermore, there is the app DDS UI, which enables you to view all the definitions that you have produced. The C++ code will be generated. And it includes all the creation of the participants, readers, and writers. As I said before, the DDS Blockset supports two vendors out of the box RTI Connect 6.0 and eProsima.

      through a system example that is built using DDS. To get started, let's go to MATLAB. One can do a help DDS. And that will actually bring you all the useful links for you. Here, if you click View Examples, it is going to bring you the example browser. I'm going to walk you through the DDS positioning system, which I have already opened up here.

      So let's go ahead and open the position estimator model. And this position estimator model is a typical application where it is subscribing to two top-- gets two pieces of data. Calculates some information. And then publishes the calculator information on a third topic. So to get started, one would use the DDS application. Here, I have it in my favorites. But you could find this DDS application in the code generation tab in the Simulink tool strip. So let's go ahead and start that.

      And then if this is a first time the quick start will come since the model has already been set up, you can bring up the quick start. And here, to get started, you would just set the name of the application here. And I'm using the position estimator. You can use one of the two third party vendors that have been supported out of the box. eProsima RTI Connect.

      Next, you would either use an existing dictionary or import XML where you have system definitions. Or you can use a default dictionary that the product just provides out of the box. Since I already have a dictionary, I'm going to use that dictionary. And then once I click, Finish, the model is now set up for DDS. If you are wondering what are the definitions that are important, you can use the DDS dictionary view. In the DDS dictionary view you have the types, which are all the XO meter and position type.

      Apart from it you can also have the domains, which actually has all the different topics. The accelerometer, the GPS, the estimated position. And the QoS definition. Some built in QoS definitions, which can be used for any event, real time event, or a streaming event. And you can also use the types to actually add or edit any of these definitions. So as with the domains and QoS.

      Apart from the types, we also have constant Enum that you can use. All kinds of manipulations are available. Copy, delete, and duplications. OK. You have your types definition. Next, you would associate the types to any of the inputs. And then you would also configure the topics. To use the topics here I have the inputs. The accelerometer is reading the accel meter topic. And the GPSReader is using the GPS topic. And similarly in the output, you have the estimated position.

      Once you are done, you can now build. And then you can view the code where it actually has all the definitions for your RTI APIs being already generated for you. Now once they have generated the code you can actually deploy the application. Here I have already built. You can run this. And now once it comes up, it'll all connect to your DDS system.

      You can also create a system model, and use the capabilities of the DDS Blockset to simulate and see the behavior of your algorithm. And fine tune your QoS settings so that you would go ahead and create a positioning system model. Here is the same position estimator that you saw earlier. And you would have an accelerometer or some standing that is actually taking your accelerometer data. And then sending it as a message. And you will have a GPS, which is also from here in this example, if u is using an already pre-recorded data.

      And you would use this simulation and see. Now this accelerometer is publishing at a higher speed, which is very typical of accelerometers. And GPS are typically slower, but more accurate. And you can use the GPS data to correct any accumulating errors in your accelerometer.

      So when you simulate the model-- let's go ahead and simulate the model-- you will see a smooth estimation of the data that you have. And you have a very smooth curve that you have. Let me just zoom in time. You can see the zoom in. It is very smooth data.

      Now you are wondering, OK, this is to accommodate the faster rate. So we are going to keep a queue so that when the actual position estimator comes it is actually using some 10 samples so that it will pull up. Now I'm going to go and show you what happens to go into the extreme. Let me just comment through the queue, and let's simulate what happens.

      And you will see there will be a lot of breakages of-- the estimation will not be a smooth curve. Let's zoom in time. And you would see it is all like all broken in there. So this way you can fine tune how much is your queue depth that you need. And this is a very powerful way of fine tuning your QoS using the DDS Blockset features and of core Simulink features to estimate your queue.

      So what I have shown you is creating a simple estimator example, estimator model. And then configuring, and building, and deploying it. And also using a system model to create and simulate your entire system. So what you can do to get more information, you can go through the other example, which is a Getting Started example. And of course I showed you the positioning system. And you can also visit our product page to get more information on the DDS Blockset. Thank you so much for taking your time to get more information on DDS Blockset.

      Related Products