Server-Client Setup

The server-client feature allows one to control MATMAV session remotely, either in a seperate MATLAB session on the same computer, or on a different computer that is connected to the same network. This helps to use more computational resources rather than putting all the burden on one MATLAB session.

This page explains how to setup server/client connection using MATMAV and MATMAVClient.

This feature is available in versions 2.5 and above.

Setup MATMAV Server

Set local port for MATMAV Server

prt=10000;% if not specified, it defaults to 25000
nclnts=2;% number of clients expected to be connected, default is 1
obj.startServer(prt,nclients)

Once the connection is established, you are ready to connect to MATMAV server. Next, you need to create a client object using the MATMAVClient class. Then, use it to connect to the server as follows.

Setup MATMAV Client

create MatMavCLient object

clid=1; % this the client ID, should be unique among clients connecting to the same server
lprt=12000; % the client local port which the server will send to
srvip='127.0.0.1';% should be the IP where the server is running
srvprt=10000;% port that the server is using to listen to clients
cl1=MatMavClient(clid,lprt,srvip,srvprt)

Connect to server

>> cl1.ConnectToServer()

MatMavClient allows you to subscribe to topics on the server (e.g. sensor data). Once a client is subscribed to a specific topic, it will keep receiving updated topic's data until it unsubscribes, or the connection to the server is stopped.

To subscribe to a topic (e.g. attitude):

vehicle=1; % which vehicle data you want
cl1.subscribe('ATT',vehicle);

To find topics you can get:

>> properties(cl1)

You can also send commands to MATMAV. For eaxmple, you can send an arming command to vehicle 1:

vid=1; % vehicle ID
flag=1; % Arm:1, disarm:0` 
cl1.Arm(vid,flag);

Check the available commands:

>> methods(cl1);

results matching ""

    No results matching ""