Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions c/include/libsbp/navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,24 @@ typedef struct SBP_ATTR_PACKED {
} msg_baseline_heading_dep_a_t;


/** Computed Position and Protection Level
*
* This message reports the local vertical and horizontal protection levels
* associated with a given LLH position solution. The full GPS time is given
* by the preceding MSG_GPS_TIME with the matching time-of-week (tow).
*/
#define SBP_MSG_PROTECTION_LEVEL 0x0216
typedef struct SBP_ATTR_PACKED {
u32 tow; /**< GPS Time of Week [ms] */
u16 vpl; /**< Vertical protection level [cm] */
u16 hpl; /**< Horizontal protection level [cm] */
double lat; /**< Latitude [deg] */
double lon; /**< Longitude [deg] */
double height; /**< Height [m] */
u8 flags; /**< Status flags */
} msg_protection_level_t;


/** \} */

SBP_PACK_END
Expand Down
6 changes: 6 additions & 0 deletions c/include/libsbp/sbp_handler.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef LIBSBP_SBP_HANDLER_HPP_
#define LIBSBP_SBP_HANDLER_HPP_

#include <libsbp/sbp.h>

#endif /* LIBSBP_SBP_HANDLER_HPP_ */
6 changes: 6 additions & 0 deletions haskell/src/SwiftNav/SBP/Msg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ data SBPMsg =
| SBPMsgPosLlhCov MsgPosLlhCov Msg
| SBPMsgPosLlhDepA MsgPosLlhDepA Msg
| SBPMsgPrintDep MsgPrintDep Msg
| SBPMsgProtectionLevel MsgProtectionLevel Msg
| SBPMsgReset MsgReset Msg
| SBPMsgResetDep MsgResetDep Msg
| SBPMsgResetFilters MsgResetFilters Msg
Expand Down Expand Up @@ -362,6 +363,7 @@ instance Binary SBPMsg where
| _msgSBPType == msgPosLlhCov = SBPMsgPosLlhCov (decode (fromStrict (unBytes _msgSBPPayload))) m
| _msgSBPType == msgPosLlhDepA = SBPMsgPosLlhDepA (decode (fromStrict (unBytes _msgSBPPayload))) m
| _msgSBPType == msgPrintDep = SBPMsgPrintDep (decode (fromStrict (unBytes _msgSBPPayload))) m
| _msgSBPType == msgProtectionLevel = SBPMsgProtectionLevel (decode (fromStrict (unBytes _msgSBPPayload))) m
| _msgSBPType == msgReset = SBPMsgReset (decode (fromStrict (unBytes _msgSBPPayload))) m
| _msgSBPType == msgResetDep = SBPMsgResetDep (decode (fromStrict (unBytes _msgSBPPayload))) m
| _msgSBPType == msgResetFilters = SBPMsgResetFilters (decode (fromStrict (unBytes _msgSBPPayload))) m
Expand Down Expand Up @@ -540,6 +542,7 @@ instance Binary SBPMsg where
encoder (SBPMsgPosLlhCov _ m) = put m
encoder (SBPMsgPosLlhDepA _ m) = put m
encoder (SBPMsgPrintDep _ m) = put m
encoder (SBPMsgProtectionLevel _ m) = put m
encoder (SBPMsgReset _ m) = put m
encoder (SBPMsgResetDep _ m) = put m
encoder (SBPMsgResetFilters _ m) = put m
Expand Down Expand Up @@ -722,6 +725,7 @@ instance FromJSON SBPMsg where
| msgType == msgPosLlhCov = SBPMsgPosLlhCov <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj
| msgType == msgPosLlhDepA = SBPMsgPosLlhDepA <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj
| msgType == msgPrintDep = SBPMsgPrintDep <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj
| msgType == msgProtectionLevel = SBPMsgProtectionLevel <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj
| msgType == msgReset = SBPMsgReset <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj
| msgType == msgResetDep = SBPMsgResetDep <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj
| msgType == msgResetFilters = SBPMsgResetFilters <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj
Expand Down Expand Up @@ -905,6 +909,7 @@ instance ToJSON SBPMsg where
toJSON (SBPMsgPosLlhCov n m) = toJSON n <<>> toJSON m
toJSON (SBPMsgPosLlhDepA n m) = toJSON n <<>> toJSON m
toJSON (SBPMsgPrintDep n m) = toJSON n <<>> toJSON m
toJSON (SBPMsgProtectionLevel n m) = toJSON n <<>> toJSON m
toJSON (SBPMsgReset n m) = toJSON n <<>> toJSON m
toJSON (SBPMsgResetDep _ m) = toJSON m
toJSON (SBPMsgResetFilters n m) = toJSON n <<>> toJSON m
Expand Down Expand Up @@ -1082,6 +1087,7 @@ instance HasMsg SBPMsg where
msg f (SBPMsgPosLlhCov n m) = SBPMsgPosLlhCov n <$> f m
msg f (SBPMsgPosLlhDepA n m) = SBPMsgPosLlhDepA n <$> f m
msg f (SBPMsgPrintDep n m) = SBPMsgPrintDep n <$> f m
msg f (SBPMsgProtectionLevel n m) = SBPMsgProtectionLevel n <$> f m
msg f (SBPMsgReset n m) = SBPMsgReset n <$> f m
msg f (SBPMsgResetDep n m) = SBPMsgResetDep n <$> f m
msg f (SBPMsgResetFilters n m) = SBPMsgResetFilters n <$> f m
Expand Down
49 changes: 49 additions & 0 deletions haskell/src/SwiftNav/SBP/Navigation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,3 +1354,52 @@ instance Binary MsgBaselineHeadingDepA where
$(makeSBP 'msgBaselineHeadingDepA ''MsgBaselineHeadingDepA)
$(makeJSON "_msgBaselineHeadingDepA_" ''MsgBaselineHeadingDepA)
$(makeLenses ''MsgBaselineHeadingDepA)

msgProtectionLevel :: Word16
msgProtectionLevel = 0x0216

-- | SBP class for message MSG_PROTECTION_LEVEL (0x0216).
--
-- This message reports the local vertical and horizontal protection levels
-- associated with a given LLH position solution. The full GPS time is given by
-- the preceding MSG_GPS_TIME with the matching time-of-week (tow).
data MsgProtectionLevel = MsgProtectionLevel
{ _msgProtectionLevel_tow :: !Word32
-- ^ GPS Time of Week
, _msgProtectionLevel_vpl :: !Word16
-- ^ Vertical protection level
, _msgProtectionLevel_hpl :: !Word16
-- ^ Horizontal protection level
, _msgProtectionLevel_lat :: !Double
-- ^ Latitude
, _msgProtectionLevel_lon :: !Double
-- ^ Longitude
, _msgProtectionLevel_height :: !Double
-- ^ Height
, _msgProtectionLevel_flags :: !Word8
-- ^ Status flags
} deriving ( Show, Read, Eq )

instance Binary MsgProtectionLevel where
get = do
_msgProtectionLevel_tow <- getWord32le
_msgProtectionLevel_vpl <- getWord16le
_msgProtectionLevel_hpl <- getWord16le
_msgProtectionLevel_lat <- getFloat64le
_msgProtectionLevel_lon <- getFloat64le
_msgProtectionLevel_height <- getFloat64le
_msgProtectionLevel_flags <- getWord8
pure MsgProtectionLevel {..}

put MsgProtectionLevel {..} = do
putWord32le _msgProtectionLevel_tow
putWord16le _msgProtectionLevel_vpl
putWord16le _msgProtectionLevel_hpl
putFloat64le _msgProtectionLevel_lat
putFloat64le _msgProtectionLevel_lon
putFloat64le _msgProtectionLevel_height
putWord8 _msgProtectionLevel_flags

$(makeSBP 'msgProtectionLevel ''MsgProtectionLevel)
$(makeJSON "_msgProtectionLevel_" ''MsgProtectionLevel)
$(makeLenses ''MsgProtectionLevel)
3 changes: 3 additions & 0 deletions java/src/com/swiftnav/sbp/client/MessageTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import com.swiftnav.sbp.navigation.MsgVelECEFDepA;
import com.swiftnav.sbp.navigation.MsgVelNEDDepA;
import com.swiftnav.sbp.navigation.MsgBaselineHeadingDepA;
import com.swiftnav.sbp.navigation.MsgProtectionLevel;
import com.swiftnav.sbp.ndb.MsgNdbEvent;
import com.swiftnav.sbp.observation.MsgObs;
import com.swiftnav.sbp.observation.MsgBasePosLLH;
Expand Down Expand Up @@ -332,6 +333,8 @@ static SBPMessage dispatch(SBPMessage msg) throws SBPBinaryException {
return new MsgVelNEDDepA(msg);
case MsgBaselineHeadingDepA.TYPE:
return new MsgBaselineHeadingDepA(msg);
case MsgProtectionLevel.TYPE:
return new MsgProtectionLevel(msg);
case MsgNdbEvent.TYPE:
return new MsgNdbEvent(msg);
case MsgObs.TYPE:
Expand Down
103 changes: 103 additions & 0 deletions java/src/com/swiftnav/sbp/navigation/MsgProtectionLevel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright (C) 2015-2018 Swift Navigation Inc.
* Contact: Swift Navigation <dev@swiftnav.com>
*
* This source is subject to the license found in the file 'LICENSE' which must
* be be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

package com.swiftnav.sbp.navigation;

import java.math.BigInteger;

import com.swiftnav.sbp.SBPMessage;
import com.swiftnav.sbp.SBPBinaryException;
import com.swiftnav.sbp.SBPStruct;

import org.json.JSONObject;
import org.json.JSONArray;


/** SBP class for message MSG_PROTECTION_LEVEL (0x0216).
*
* You can have MSG_PROTECTION_LEVEL inherent its fields directly from
* an inherited SBP object, or construct it inline using a dict of its
* fields.
*
* This message reports the local vertical and horizontal protection levels
* associated with a given LLH position solution. The full GPS time is given
* by the preceding MSG_GPS_TIME with the matching time-of-week (tow). */

public class MsgProtectionLevel extends SBPMessage {
public static final int TYPE = 0x0216;


/** GPS Time of Week */
public long tow;

/** Vertical protection level */
public int vpl;

/** Horizontal protection level */
public int hpl;

/** Latitude */
public double lat;

/** Longitude */
public double lon;

/** Height */
public double height;

/** Status flags */
public int flags;


public MsgProtectionLevel (int sender) { super(sender, TYPE); }
public MsgProtectionLevel () { super(TYPE); }
public MsgProtectionLevel (SBPMessage msg) throws SBPBinaryException {
super(msg);
assert msg.type != TYPE;
}

@Override
protected void parse(Parser parser) throws SBPBinaryException {
/* Parse fields from binary */
tow = parser.getU32();
vpl = parser.getU16();
hpl = parser.getU16();
lat = parser.getDouble();
lon = parser.getDouble();
height = parser.getDouble();
flags = parser.getU8();
}

@Override
protected void build(Builder builder) {
builder.putU32(tow);
builder.putU16(vpl);
builder.putU16(hpl);
builder.putDouble(lat);
builder.putDouble(lon);
builder.putDouble(height);
builder.putU8(flags);
}

@Override
public JSONObject toJSON() {
JSONObject obj = super.toJSON();
obj.put("tow", tow);
obj.put("vpl", vpl);
obj.put("hpl", hpl);
obj.put("lat", lat);
obj.put("lon", lon);
obj.put("height", height);
obj.put("flags", flags);
return obj;
}
}
2 changes: 1 addition & 1 deletion javascript/sbp.bundle.js

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions javascript/sbp/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,53 @@ MsgBaselineHeadingDepA.prototype.fieldSpec.push(['heading', 'writeUInt32LE', 4])
MsgBaselineHeadingDepA.prototype.fieldSpec.push(['n_sats', 'writeUInt8', 1]);
MsgBaselineHeadingDepA.prototype.fieldSpec.push(['flags', 'writeUInt8', 1]);

/**
* SBP class for message MSG_PROTECTION_LEVEL (0x0216).
*
* This message reports the local vertical and horizontal protection levels
* associated with a given LLH position solution. The full GPS time is given by the
* preceding MSG_GPS_TIME with the matching time-of-week (tow).
*
* Fields in the SBP payload (`sbp.payload`):
* @field tow number (unsigned 32-bit int, 4 bytes) GPS Time of Week
* @field vpl number (unsigned 16-bit int, 2 bytes) Vertical protection level
* @field hpl number (unsigned 16-bit int, 2 bytes) Horizontal protection level
* @field lat number (float, 8 bytes) Latitude
* @field lon number (float, 8 bytes) Longitude
* @field height number (float, 8 bytes) Height
* @field flags number (unsigned 8-bit int, 1 byte) Status flags
*
* @param sbp An SBP object with a payload to be decoded.
*/
var MsgProtectionLevel = function (sbp, fields) {
SBP.call(this, sbp);
this.messageType = "MSG_PROTECTION_LEVEL";
this.fields = (fields || this.parser.parse(sbp.payload));

return this;
};
MsgProtectionLevel.prototype = Object.create(SBP.prototype);
MsgProtectionLevel.prototype.messageType = "MSG_PROTECTION_LEVEL";
MsgProtectionLevel.prototype.msg_type = 0x0216;
MsgProtectionLevel.prototype.constructor = MsgProtectionLevel;
MsgProtectionLevel.prototype.parser = new Parser()
.endianess('little')
.uint32('tow')
.uint16('vpl')
.uint16('hpl')
.doublele('lat')
.doublele('lon')
.doublele('height')
.uint8('flags');
MsgProtectionLevel.prototype.fieldSpec = [];
MsgProtectionLevel.prototype.fieldSpec.push(['tow', 'writeUInt32LE', 4]);
MsgProtectionLevel.prototype.fieldSpec.push(['vpl', 'writeUInt16LE', 2]);
MsgProtectionLevel.prototype.fieldSpec.push(['hpl', 'writeUInt16LE', 2]);
MsgProtectionLevel.prototype.fieldSpec.push(['lat', 'writeDoubleLE', 8]);
MsgProtectionLevel.prototype.fieldSpec.push(['lon', 'writeDoubleLE', 8]);
MsgProtectionLevel.prototype.fieldSpec.push(['height', 'writeDoubleLE', 8]);
MsgProtectionLevel.prototype.fieldSpec.push(['flags', 'writeUInt8', 1]);

module.exports = {
0x0102: MsgGpsTime,
MsgGpsTime: MsgGpsTime,
Expand Down Expand Up @@ -1314,4 +1361,6 @@ module.exports = {
MsgVelNedDepA: MsgVelNedDepA,
0x0207: MsgBaselineHeadingDepA,
MsgBaselineHeadingDepA: MsgBaselineHeadingDepA,
0x0216: MsgProtectionLevel,
MsgProtectionLevel: MsgProtectionLevel,
}
16 changes: 16 additions & 0 deletions proto/navigation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,20 @@ message MsgVelBody {
message MsgAgeCorrections {
uint32 tow = 1;
uint32 age = 2;
}

/** Computed Position and Protection Level
*
* This message reports the local vertical and horizontal protection levels
* associated with a given LLH position solution. The full GPS time is given
* by the preceding MSG_GPS_TIME with the matching time-of-week (tow).
*/
message MsgProtectionLevel {
uint32 tow = 1;
uint32 vpl = 2;
uint32 hpl = 3;
double lat = 4;
double lon = 5;
double height = 6;
uint32 flags = 7;
}
Loading