Home‎ > ‎Documentation and Examples‎ > ‎

Examples


Reading The Tutorial


Your first port of call for full example code should be the MOOS V10 Tutorial this has a goodly number of full source code examples. The links below may also be useful but the ones in the tutorial will be the ones that are updated most often



Getting, Building and Using Example Code

Preparing :

To build the code you will need to have download and install core-moos. Instructions on how to do that are here

Downloading :

You can download the tutorial and all the examples programs in it from github by doing the following

mkdir ~/tmp/MOOSV10Examples
cd ~/tmp/MOOSV10Examples
git clone https://github.com/themoos/examples-docs-moos.git src

Building

In-place builds are filthy things so we won't do it. Instead make a sibling directory called "build" and move into it

mkdir build; cd build

Then run ccmake pointing to CommsExamples (if that is the set of examples that interest us) sub-directory of the examples-docs-moos you created when you cloned the documentation and examples project: 

ccmake ../src/docs/examples/CommsExamples

Then actually build the code. 

make

you should see an output like this:

Scanning dependencies of target ex10
[ 16%] Building CXX object EX10/CMakeFiles/ex10.dir/ex10.cpp.o
Linking CXX executable ../bin/ex10
[ 16%] Built target ex10
[ 33%] Building CXX object EX20/CMakeFiles/ex20.dir/ex20.cpp.o
Linking CXX executable ../bin/ex20
[ 33%] Built target ex20
[ 50%] Building CXX object EX30/CMakeFiles/ex30.dir/ex30.cpp.o
Linking CXX executable ../bin/ex30
[ 50%] Built target ex30
[ 66%] Building CXX object EX40/CMakeFiles/ex40.dir/ex40.cpp.o
Linking CXX executable ../bin/ex40
[ 66%] Built target ex40
[ 83%] Building CXX object EX50/CMakeFiles/ex50.dir/ex50.cpp.o
Linking CXX executable ../bin/ex50
[ 83%] Built target ex50
[100%] Building CXX object EX60/CMakeFiles/ex60.dir/ex60.cpp.o
Linking CXX executable ../bin/ex60
[100%] Built target ex60

which means all the examples are now built and living in the "bin" directory. Happy.










Example Codes


 Example Name Contents
  
 CommsClients 
 Example 10The simplest possible example using a CommsClient - setting up a client, connecting and picking up mail
 Example 20Using a message callback instead of a loop to pick up an process mail.
 Example 30Parsing the command line 
 Example 40Installing active message queue
 Example 50Installing default message queues
 Example 60Using Wildcard registrations
  
  
 MOOSApps 
 Example 1010 Using a MOOSApp to "ping-pong" a burst of messages (demonstrating low latency)