-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/swarinfo 619 angle parameters (#63)
* DTO * Integrate with other messages * Update max pdoa slopes * bump * Remove TDOA * Add board orientation offset * Update common.cmake
- Loading branch information
Showing
11 changed files
with
305 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/pheromones/include/pheromones/interloc/ConfigureAngleParametersDTO.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef __CONFIGUREANGLEPARAMETERSDTO_H__ | ||
#define __CONFIGUREANGLEPARAMETERSDTO_H__ | ||
|
||
#include <array> | ||
#include <cstdint> | ||
#include <message.pb.h> | ||
#include <pheromones/PheromonesSettings.h> | ||
|
||
class ConfigureAngleParametersDTO { | ||
public: | ||
ConfigureAngleParametersDTO(const ConfigureAngleParameters& message); | ||
|
||
uint8_t getPairId() const; | ||
|
||
const std::array<uint8_t, INTERLOC_ANTENNAS_PER_PAIR>& getAntennas() const; | ||
uint8_t getAntennasLength() const; | ||
|
||
const std::array<uint8_t, INTERLOC_MAX_ANTENNA_PAIRS>& getSlopeDecision() const; | ||
uint8_t getSlopeDecisionLength() const; | ||
|
||
const std::array<float, INTERLOC_MAX_PDOA_SLOPES>& getPdoaSlopes() const; | ||
uint8_t getPdoaSlopesLength() const; | ||
|
||
const std::array<float, INTERLOC_MAX_PDOA_SLOPES>& getPdoaIntercepts() const; | ||
uint8_t getPdoaInterceptsLength() const; | ||
|
||
float getPdoaNormalizationFactor() const; | ||
|
||
float getBoardOrientationOffset() const; | ||
|
||
/** | ||
*@brief serialize a Message for nanopb, sets the fields properly before using | ||
*pb_encode | ||
*@param [out] message the message to serialize | ||
*@return a boolean, true if successfull (fields were recognized) false if not */ | ||
bool serialize(ConfigureAngleParameters& message) const; | ||
|
||
private: | ||
uint8_t m_pairId; | ||
|
||
std::array<uint8_t, INTERLOC_ANTENNAS_PER_PAIR> m_antennas; | ||
uint8_t m_antennasLength; | ||
std::array<uint8_t, INTERLOC_MAX_ANTENNA_PAIRS> m_slopeDecision; | ||
uint8_t m_slopeDecisionLength; | ||
|
||
std::array<float, INTERLOC_MAX_PDOA_SLOPES> m_pdoaSlopes; | ||
uint8_t m_pdoaSlopesLength; | ||
std::array<float, INTERLOC_MAX_PDOA_SLOPES> m_pdoaIntercepts; | ||
uint8_t m_pdoaInterceptsLength; | ||
float m_pdoaNormalizationFactor; | ||
|
||
float m_boardOientationOffset; | ||
}; | ||
|
||
#endif //__CONFIGUREANGLEPARAMETERSDTO_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/pheromones/src/interloc/ConfigureAngleParametersDTO.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#include "interloc/ConfigureAngleParametersDTO.h" | ||
|
||
ConfigureAngleParametersDTO::ConfigureAngleParametersDTO(const ConfigureAngleParameters& message) { | ||
m_pairId = message.anglePairId; | ||
|
||
m_antennasLength = | ||
message.antennas_count <= INTERLOC_ANTENNAS_PER_PAIR ? message.antennas_count : 0; | ||
for (unsigned int i = 0; i < m_antennasLength; i++) { | ||
m_antennas[i] = message.antennas[i]; | ||
} | ||
|
||
m_slopeDecisionLength = | ||
message.slopeDecision_count <= INTERLOC_MAX_ANTENNA_PAIRS ? message.slopeDecision_count : 0; | ||
for (unsigned int i = 0; i < m_slopeDecisionLength; i++) { | ||
m_slopeDecision[i] = message.slopeDecision[i]; | ||
} | ||
|
||
m_pdoaSlopesLength = | ||
message.pdoaSlopes_count <= INTERLOC_MAX_PDOA_SLOPES ? message.pdoaSlopes_count : 0; | ||
for (unsigned int i = 0; i < m_pdoaSlopesLength; i++) { | ||
m_pdoaSlopes[i] = message.pdoaSlopes[i]; | ||
} | ||
m_pdoaInterceptsLength = | ||
message.pdoaIntercepts_count <= INTERLOC_MAX_PDOA_SLOPES ? message.pdoaIntercepts_count : 0; | ||
for (unsigned int i = 0; i < m_pdoaInterceptsLength; i++) { | ||
m_pdoaIntercepts[i] = message.pdoaIntercepts[i]; | ||
} | ||
|
||
m_pdoaNormalizationFactor = message.pdoaNormalizationFactor; | ||
m_boardOientationOffset = message.boardOrientationOffset; | ||
} | ||
|
||
uint8_t ConfigureAngleParametersDTO::getPairId() const { return m_pairId; } | ||
|
||
const std::array<uint8_t, INTERLOC_ANTENNAS_PER_PAIR>& ConfigureAngleParametersDTO::getAntennas() | ||
const { | ||
return m_antennas; | ||
} | ||
|
||
uint8_t ConfigureAngleParametersDTO::getAntennasLength() const { return m_antennasLength; } | ||
|
||
const std::array<uint8_t, INTERLOC_MAX_ANTENNA_PAIRS>& ConfigureAngleParametersDTO:: | ||
getSlopeDecision() const { | ||
return m_slopeDecision; | ||
} | ||
|
||
uint8_t ConfigureAngleParametersDTO::getSlopeDecisionLength() const { | ||
return m_slopeDecisionLength; | ||
} | ||
|
||
const std::array<float, INTERLOC_MAX_PDOA_SLOPES>& ConfigureAngleParametersDTO::getPdoaSlopes() | ||
const { | ||
return m_pdoaSlopes; | ||
} | ||
|
||
uint8_t ConfigureAngleParametersDTO::getPdoaSlopesLength() const { return m_pdoaSlopesLength; } | ||
|
||
float ConfigureAngleParametersDTO::getPdoaNormalizationFactor() const { | ||
return m_pdoaNormalizationFactor; | ||
} | ||
|
||
uint8_t ConfigureAngleParametersDTO::getPdoaInterceptsLength() const { | ||
return m_pdoaInterceptsLength; | ||
} | ||
|
||
const std::array<float, INTERLOC_MAX_PDOA_SLOPES>& ConfigureAngleParametersDTO::getPdoaIntercepts() | ||
const { | ||
return m_pdoaIntercepts; | ||
} | ||
|
||
float ConfigureAngleParametersDTO::getBoardOrientationOffset() const { | ||
return m_boardOientationOffset; | ||
} | ||
|
||
bool ConfigureAngleParametersDTO::serialize(ConfigureAngleParameters& message) const { | ||
message.anglePairId = m_pairId; | ||
|
||
message.antennas_count = m_antennasLength; | ||
for (unsigned int i = 0; i < m_antennasLength; i++) { | ||
message.antennas[i] = m_antennas[i]; | ||
} | ||
|
||
message.slopeDecision_count = m_slopeDecisionLength; | ||
for (unsigned int i = 0; i < m_slopeDecisionLength; i++) { | ||
message.slopeDecision[i] = m_slopeDecision[i]; | ||
} | ||
|
||
message.pdoaSlopes_count = m_pdoaSlopesLength; | ||
for (unsigned int i = 0; i < m_pdoaSlopesLength; i++) { | ||
message.pdoaSlopes[i] = m_pdoaSlopes[i]; | ||
} | ||
message.pdoaNormalizationFactor = m_pdoaNormalizationFactor; | ||
message.pdoaIntercepts_count = m_pdoaInterceptsLength; | ||
for (unsigned int i = 0; i < m_pdoaInterceptsLength; i++) { | ||
message.pdoaIntercepts[i] = m_pdoaIntercepts[i]; | ||
} | ||
|
||
message.boardOrientationOffset = m_boardOientationOffset; | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/pheromones/tests/interloc/ConfigureAngleParametersDTOUnitTests.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include <gtest/gtest.h> | ||
#include <pheromones/interloc/ConfigureAngleParametersDTO.h> | ||
|
||
class ConfigureAngleParametersFixture : public testing::Test { | ||
public: | ||
void SetUp() override {} | ||
|
||
void TearDown() override {} | ||
}; | ||
|
||
TEST_F(ConfigureAngleParametersFixture, ConfigureInterlocDumps_deserialize_pairId) { | ||
ConfigureAngleParameters msg; | ||
memset(&msg, 0, sizeof(msg)); | ||
msg.anglePairId = 42; | ||
|
||
auto dto = ConfigureAngleParametersDTO(msg); | ||
|
||
EXPECT_EQ(dto.getPairId(), msg.anglePairId); | ||
} | ||
|
||
TEST_F(ConfigureAngleParametersFixture, ConfigureInterlocDumps_deserialize_slopeDecision) { | ||
ConfigureAngleParameters msg; | ||
memset(&msg, 0, sizeof(msg)); | ||
|
||
msg.slopeDecision[0] = 1; | ||
msg.slopeDecision[1] = 2; | ||
msg.slopeDecision_count = 2; | ||
|
||
auto dto = ConfigureAngleParametersDTO(msg); | ||
|
||
EXPECT_EQ(dto.getSlopeDecision()[0], msg.slopeDecision[0]); | ||
EXPECT_EQ(dto.getSlopeDecision()[1], msg.slopeDecision[1]); | ||
EXPECT_EQ(dto.getSlopeDecisionLength(), msg.slopeDecision_count); | ||
} | ||
|
||
TEST_F(ConfigureAngleParametersFixture, ConfigureInterlocDumps_deserialize_pdoaSlopes) { | ||
ConfigureAngleParameters msg; | ||
memset(&msg, 0, sizeof(msg)); | ||
|
||
msg.pdoaSlopes[0] = 1; | ||
msg.pdoaSlopes[1] = 2; | ||
msg.pdoaSlopes_count = 2; | ||
|
||
auto dto = ConfigureAngleParametersDTO(msg); | ||
|
||
EXPECT_EQ(dto.getPdoaSlopes()[0], msg.pdoaSlopes[0]); | ||
EXPECT_EQ(dto.getPdoaSlopes()[1], msg.pdoaSlopes[1]); | ||
EXPECT_EQ(dto.getPdoaSlopesLength(), msg.pdoaSlopes_count); | ||
} | ||
|
||
TEST_F(ConfigureAngleParametersFixture, ConfigureInterlocDumps_deserialize_pdoaNormalization) { | ||
ConfigureAngleParameters msg; | ||
memset(&msg, 0, sizeof(msg)); | ||
|
||
msg.pdoaNormalizationFactor = 1; | ||
|
||
auto dto = ConfigureAngleParametersDTO(msg); | ||
|
||
EXPECT_EQ(dto.getPdoaNormalizationFactor(), msg.pdoaNormalizationFactor); | ||
} | ||
|
||
TEST_F(ConfigureAngleParametersFixture, ConfigureInterlocDumps_deserialize_boardOffset) { | ||
ConfigureAngleParameters msg; | ||
memset(&msg, 0, sizeof(msg)); | ||
|
||
msg.boardOrientationOffset = 42.42; | ||
|
||
auto dto = ConfigureAngleParametersDTO(msg); | ||
|
||
EXPECT_EQ(dto.getBoardOrientationOffset(), msg.boardOrientationOffset); | ||
} | ||
|
||
TEST_F(ConfigureAngleParametersFixture, ConfigureInterlocDumps_deserialize_pdoaIntercepts) { | ||
ConfigureAngleParameters msg; | ||
memset(&msg, 0, sizeof(msg)); | ||
|
||
msg.pdoaIntercepts[0] = 1; | ||
msg.pdoaIntercepts[1] = 2; | ||
msg.pdoaIntercepts_count = 2; | ||
|
||
auto dto = ConfigureAngleParametersDTO(msg); | ||
|
||
EXPECT_EQ(dto.getPdoaIntercepts()[0], msg.pdoaIntercepts[0]); | ||
EXPECT_EQ(dto.getPdoaIntercepts()[1], msg.pdoaIntercepts[1]); | ||
EXPECT_EQ(dto.getPdoaInterceptsLength(), msg.pdoaIntercepts_count); | ||
} |
Oops, something went wrong.