Note: Goby version 1 (shown here) is now considered obsolete. Please use version 2 for new projects, and consider upgrading old projects.

Goby Underwater Autonomy Project  Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
libdccl/plusnet/plusnet.cpp

nafcon_command.xml

<?xml version="1.0" encoding="UTF8"?>
<message_set>
  <message>
    <name>SENSOR_DEPLOY</name>
    <destination_var key="DestinationPlatformId">PLUSNET_MESSAGES</destination_var>
    <trigger>publish</trigger>
    <trigger_var mandatory_content="MessageType=SENSOR_DEPLOY">
      PLUSNET_MESSAGES
    </trigger_var>
    <size>32</size>
    <header>
      <id>10</id>
      <time>
        <name>Timestamp</name>
      </time>
      <src_id>
        <name>SourcePlatformId</name>  
      </src_id>
      <dest_id>
        <name>DestinationPlatformId</name>
      </dest_id>
    </header> 
    <layout>
      <static>
        <name>MessageType</name>
        <value>SENSOR_DEPLOY</value>
      </static>
      <static>
        <name>SensorCommandType</name>
        <value>0</value>
      </static>
      <float>
        <name>DeployLatitude</name>
        <precision>5</precision>
        <max>90</max>
        <min>-90</min>
      </float>
      <float>
        <name>DeployLongitude</name>
        <precision>5</precision>
        <max>180</max>
        <min>-180</min>
      </float>
      <int>
        <name>DeployDepth</name>
        <max>254</max>
        <min>0</min>
      </int>
      <int>
        <name>DeployDuration</name>
        <max>62</max>
        <min>1</min>
      </int>
      <float>
        <name>AbortLatitude</name>
        <precision>4</precision>
        <max>90</max>
        <min>-90</min>
      </float>
      <float>
        <name>AbortLongitude</name>
        <precision>4</precision>
        <max>180</max>
        <min>-180</min>
      </float>
      <int>
        <name>AbortDepth</name>
        <max>510</max>
        <min>0</min>
      </int>
      <int>
        <name>MissionType</name>
        <max>6</max>
        <min>0</min>
      </int>
      <int>
        <name>OperatingRadius</name>
        <max>1022</max>
        <min>0</min>
      </int>
      <float algorithm="angle_0_360">
        <name>DCLFOVStartHeading</name>
        <max>360</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float algorithm="angle_0_360">
        <name>DCLFOVEndHeading</name>
        <max>360</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float>
        <name>DCLSearchRate</name>
        <max>254</max>
        <min>0</min>
        <precision>1</precision>
      </float>
    </layout>
    <on_receipt>        
      <publish>
        <publish_var>NAFCON_MESSAGES</publish_var>
        <all />
      </publish>
    </on_receipt>
  </message>
  <message>
    <name>SENSOR_PROSECUTE</name>
    <destination_var key="DestinationPlatformId">PLUSNET_MESSAGES</destination_var>
    <trigger>publish</trigger>
    <trigger_var mandatory_content="MessageType=SENSOR_PROSECUTE">
      PLUSNET_MESSAGES
    </trigger_var>
    <size>32</size>
    <header>
      <id>11</id>   
      <time>
        <name>TargetTimestamp</name>
      </time>
      <src_id>
        <name>SourcePlatformId</name>  
      </src_id>
      <dest_id>
        <name>DestinationPlatformId</name>
      </dest_id>
    </header> 
    <layout>
      <static>
        <name>MessageType</name>
        <value>SENSOR_PROSECUTE</value>
      </static>
      <int>
        <name>SensorCommandType</name>
        <min>1</min>
        <max>4</max>
      </int>
      <int>
        <name>PlatformID</name>
        <max>30</max>
        <min>0</min>
      </int>
      <int>
        <name>TrackNumber</name>
        <max>254</max>
        <min>0</min>
      </int>
      <float>
        <name>TargetLatitude</name>
        <precision>5</precision>
        <max>90</max>
        <min>-90</min>
      </float>
      <float>
        <name>TargetLongitude</name>
        <precision>5</precision>
        <max>180</max>
        <min>-180</min>
      </float>
      <int>
        <name>TargetDepth</name>
        <max>1022</max>
        <min>0</min>
      </int>
      <float algorithm="angle_0_360">
        <name>TargetHeading</name>
        <max>360</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float>
        <name>TargetSpeed</name>
        <max>12.6</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <int>
        <name>TargetSpectralLevel1</name>
        <max>126</max>
        <min>0</min>
      </int>
      <int>
        <name>TargetFrequency1</name>
        <max>4094</max>
        <min>0</min>
      </int>
      <int>
        <name>TargetBandwidth1</name>
        <max>20</max>
        <min>0</min>
      </int>
      <int>
        <name>TargetSpectralLevel2</name>
        <max>126</max>
        <min>0</min>
      </int>
      <int>
        <name>TargetFrequency2</name>
        <max>4094</max>
        <min>0</min>
      </int>
      <int>
        <name>TargetBandwidth2</name>
        <max>20</max>
        <min>0</min>
      </int>
      <int>
        <name>ProsecuteDuration</name>
        <max>62</max>
        <min>1</min>
      </int>
      <float>
        <name>AbortLatitude</name>
        <precision>4</precision>
        <max>90</max>
        <min>-90</min>
      </float>
      <float>
        <name>AbortLongitude</name>
        <precision>4</precision>
        <max>180</max>
        <min>-180</min>
      </float>
      <int>
        <name>AbortDepth</name>
        <max>126</max>
        <min>0</min>
      </int>
    </layout>
    <on_receipt>        
      <publish>
        <publish_var>NAFCON_MESSAGES</publish_var>
        <all />
      </publish>
    </on_receipt>
  </message>
</message_set>

nafcon_report.xml

<?xml version="1.0" encoding="UTF8" ?>
<message_set>
  <message>
    <name>SENSOR_STATUS</name>
    <trigger>publish</trigger> <!-- package upon publish to some moos var -->
    <trigger_moos_var mandatory_content="MessageType=SENSOR_STATUS">
      PLUSNET_MESSAGES
    </trigger_moos_var>
    <size>32</size>
    <header>
      <id>12</id>   
      <time>
        <name>Timestamp</name>
      </time>
      <src_id>
        <name>SourcePlatformId</name>  
      </src_id>
      <dest_id>
        <name>DestinationPlatformId</name>
      </dest_id>
    </header>
    <layout>
      <static>
        <name>MessageType</name>
        <value>SENSOR_STATUS</value>
      </static>
      <static>
        <name>SensorReportType</name>
        <value>0</value>
      </static>
      <float>
        <name>NodeLatitude</name>
        <precision>5</precision>
        <max>90</max>
        <min>-90</min>
      </float>
      <float>
        <name>NodeLongitude</name>
        <precision>5</precision>
        <max>180</max>
        <min>-180</min>
      </float>
      <int>
        <name>NodeDepth</name>
        <max>1022</max>
        <min>0</min>
      </int>
      <int>
        <name>NodeCEP</name>
        <max>1022</max>
        <min>0</min>
      </int>
      <float algorithm="angle_0_360">
        <name>NodeHeading</name>
        <max>360</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float>
        <name>NodeSpeed</name>
        <max>12.6</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <int>
        <name>MissionState</name>
        <max>6</max>
        <min>0</min>
      </int>
      <int>
        <name>MissionType</name>
        <max>6</max>
        <min>0</min>
      </int>
      <int>
        <name>LastGPSTimestamp</name>
        <max>2000000000</max>
        <min>1000000000</min>
      </int>
      <int>
        <name>PowerLife</name>
        <max>1022</max>
        <min>1</min>
      </int>
      <int>
        <name>SensorHealth</name>
        <max>14</max>
        <min>0</min>
      </int>
      <int>
        <name>RecorderState</name>
        <max>1</max>
        <min>0</min>
      </int>
      <int>
        <name>RecorderLife</name>
        <max>30</max>
        <min>0</min>
      </int>
      <int>
        <name>NodeSpecificInfo0</name>
        <max>254</max>
        <min>0</min>
      </int>
      <int>
        <name>NodeSpecificInfo1</name>
        <max>254</max>
        <min>0</min>
      </int>
      <int>
        <name>NodeSpecificInfo2</name>
        <max>254</max>
        <min>0</min>
      </int>
      <int>
        <name>NodeSpecificInfo3</name>
        <max>254</max>
        <min>0</min>
      </int>
      <int>
        <name>NodeSpecificInfo4</name>
        <max>254</max>
        <min>0</min>
      </int>
      <int>
        <name>NodeSpecificInfo5</name>
        <max>254</max>
        <min>0</min>
      </int>
    </layout>
    <on_receipt>
      <publish>
        <moos_var>NAFCON_MESSAGES</moos_var>
        <all />
      </publish>
    </on_receipt>
  </message>
  <message>
    <name>SENSOR_CONTACT</name>
    <trigger>publish</trigger> 
    <trigger_moos_var mandatory_content="MessageType=SENSOR_CONTACT">
      PLUSNET_MESSAGES
    </trigger_moos_var>
    <size>32</size>  
    <header>
      <id>13</id>   
      <time>
        <name>ContactTimestamp</name>
      </time>
      <src_id>
        <name>SourcePlatformId</name>  
      </src_id>
      <dest_id>
        <name>DestinationPlatformId</name>
      </dest_id>
    </header> 
    <layout>
      <static>
        <name>MessageType</name>
        <value>SENSOR_CONTACT</value>
      </static>
      <static>
        <name>SensorReportType</name>
        <value>1</value>
      </static>
      <float algorithm="angle_0_360">
        <name>SensorHeading</name>
        <max>360</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float>
        <name>SensorPitch</name>
        <max>90</max>
        <min>-90</min>
        <precision>0</precision>
      </float>
      <float>
        <name>SensorRoll</name>
        <max>180</max>
        <min>-180</min>
        <precision>0</precision>
      </float>
      <float>
        <name>SensorLatitude</name>
        <precision>5</precision>
        <max>90</max>
        <min>-90</min>
      </float>
      <float>
        <name>SensorLongitude</name>
        <precision>5</precision>
        <max>180</max>
        <min>-180</min>
      </float>
      <int>
        <name>SensorDepth</name>
        <max>1022</max>
        <min>0</min>
      </int>
      <int>
        <name>SensorCEP</name>
        <max>1022</max>
        <min>0</min>
      </int>
      <float>
        <name>ContactBearing</name>
        <max>360</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float>
        <name>ContactBearingUncertainty</name>
        <max>10</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float>
        <name>ContactBearingRate</name>
        <max>10</max>
        <min>-10</min>
        <precision>1</precision>
      </float>
      <float>
        <name>ContactBearingRateUncertainty</name>
        <max>3.0</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float>
        <name>ContactElevation</name>
        <max>90</max>
        <min>-90</min>
        <precision>1</precision>
      </float>
      <float>
        <name>ContactElevationUncertainty</name>
        <max>10</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <int>
        <name>ContactSpectralLevel1</name>
        <max>126</max>
        <min>0</min>
      </int>
      <int>
        <name>ContactFrequency1</name>
        <max>4094</max>
        <min>0</min>
      </int>
      <int>
        <name>ContactBandwidth1</name>
        <max>20</max>
        <min>0</min>
      </int>
      <int>
        <name>ContactSpectralLevel2</name>
        <max>126</max>
        <min>0</min>
      </int>
      <int>
        <name>ContactFrequency2</name>
        <max>4094</max>
        <min>0</min>
      </int>
      <int>
        <name>ContactBandwidth2</name>
        <max>20</max>
        <min>0</min>
      </int>
    </layout>
    <on_receipt>    
      <publish>
        <moos_var>NAFCON_MESSAGES</moos_var>
        <all />
      </publish>
    </on_receipt>
  </message>
  <message>
    <name>SENSOR_TRACK</name>
    <trigger>publish</trigger> 
    <trigger_moos_var mandatory_content="MessageType=SENSOR_TRACK">
      PLUSNET_MESSAGES
    </trigger_moos_var>
    <size>32</size>

    <header>
      <id>14</id>
      <time>
        <name>TrackTimestamp</name>
      </time>
      <src_id>
        <name>SourcePlatformId</name>  
      </src_id>
      <dest_id>
        <name>DestinationPlatformId</name>
      </dest_id>
    </header>

    <layout>
      <static>
        <name>MessageType</name>
        <value>SENSOR_TRACK</value>
      </static>
      <static>
        <name>SensorReportType</name>
        <value>2</value>
      </static>
      <int>
        <name>PlatformID</name>
        <max>30</max>
        <min>0</min>
      </int>
      <int>
        <name>TrackNumber</name>
        <max>254</max>
        <min>0</min>
      </int>
      <float>
        <name>TrackLatitude</name>
        <precision>5</precision>
        <max>90</max>
        <min>-90</min>
      </float>
      <float>
        <name>TrackLongitude</name>
        <precision>5</precision>
        <max>180</max>
        <min>-180</min>
      </float>
      <int>
        <name>TrackCEP</name>
        <max>1022</max>
        <min>0</min>
      </int>
      <int>
        <name>TrackDepth</name>
        <max>1022</max>
        <min>0</min>
      </int>
      <int>
        <name>TrackDepthUncertainty</name>
        <max>62</max>
        <min>0</min>
      </int>
      <float algorithm="angle_0_360">
        <name>TrackHeading</name>
        <max>360</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float>
        <name>TrackHeadingUncertainty</name>
        <max>10</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float>
        <name>TrackSpeed</name>
        <max>12.6</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <float>
        <name>TrackSpeedUncertainty</name>
        <max>3</max>
        <min>0</min>
        <precision>1</precision>
      </float>
      <int>
        <name>DepthClassification</name>
        <max>6</max>
        <min>0</min>  
      </int>
      <int>
        <name>TrackClassification</name>
        <max>6</max>
        <min>0</min>  
      </int>
      <int>
        <name>TrackSpectralLevel1</name>
        <max>126</max>
        <min>0</min>
      </int>
      <int>
        <name>TrackFrequency1</name>
        <max>4094</max>
        <min>0</min>
      </int>
      <int>
        <name>TrackBandwidth1</name>
        <max>20</max>
        <min>0</min>
      </int>
      <int>
        <name>TrackSpectralLevel2</name>
        <max>126</max>
        <min>0</min>
      </int>
      <int>
        <name>TrackFrequency2</name>
        <max>4094</max>
        <min>0</min>
      </int>
      <int>
        <name>TrackBandwidth2</name>
        <max>20</max>
        <min>0</min>
      </int>
    </layout>
    <on_receipt>        
      <publish>
        <moos_var>NAFCON_MESSAGES</moos_var>
        <all />
      </publish>
    </on_receipt>
  </message>
</message_set>

plusnet.cpp

// t. schneider tes@mit.edu 3.31.09
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this software.  If not, see <http://www.gnu.org/licenses/>.


// encodes/decodes the message given in the pGeneralCodec documentation
// also includes the simple.xml file to show example of DCCLCodec instantiation
// with multiple files

// this is an example showing some of the "MOOS" related features of libdccl that can be used (if desired) in the absence of MOOS

#include "goby/acomms/dccl.h"

#include <exception>
#include <iostream>

using namespace goby;
using goby::acomms::operator<<;

int main()
{
    std::cout << "loading nafcon xml files" << std::endl;

    acomms::DCCLCodec dccl;

    goby::acomms::protobuf::DCCLConfig cfg;
    cfg.add_message_file()->set_path(DCCL_EXAMPLES_DIR "/plusnet/nafcon_command.xml");
    cfg.add_message_file()->set_path(DCCL_EXAMPLES_DIR "/plusnet/nafcon_report.xml");
    
    dccl.set_cfg(cfg);
    
    std::cout << std::string(30, '#') << std::endl
              << "detailed message summary:" << std::endl
              << std::string(30, '#') << std::endl
              << dccl;

    std::cout << std::string(30, '#') << std::endl
              << "ENCODE / DECODE example:" << std::endl
              << std::string(30, '#') << std::endl;

    // initialize input contents to encoder
    std::map<std::string, acomms::DCCLMessageVal> in_vals;

    // initialize output message
    acomms::protobuf::ModemDataTransmission msg;

    in_vals["PLUSNET_MESSAGES"] = "MessageType=SENSOR_STATUS,SensorReportType=0,SourcePlatformId=1,DestinationPlatformId=3,Timestamp=1191947446.91117,NodeLatitude=47.7448,NodeLongitude=-122.845,NodeDepth=0.26,NodeCEP=0,NodeHeading=169.06,NodeSpeed=0,MissionState=2,MissionType=2,LastGPSTimestamp=1191947440,PowerLife=6,SensorHealth=0,RecorderState=1,RecorderLife=0,NodeSpecificInfo0=0,NodeSpecificInfo1=0,NodeSpecificInfo2=23,NodeSpecificInfo3=0,NodeSpecificInfo4=3,NodeSpecificInfo5=0";

    std::cout << "passing values to encoder:" << std::endl  
              << in_vals;
    
    dccl.pubsub_encode("SENSOR_STATUS", &msg, in_vals);
    
    std::cout << "received: "
              << msg
              << std::endl;

    
    std::multimap<std::string, acomms::DCCLMessageVal> out_vals;

    
    std::cout << "passed to decoder: " 
              << msg
              << std::endl;

    dccl.pubsub_decode(msg, &out_vals);
    
    std::cout << "received values:" << std::endl 
              << out_vals;
    
    
    return 0;
}

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends