Skip to content

Commit

Permalink
address code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Aug 13, 2024
1 parent 06dd957 commit 2f7e112
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
4 changes: 3 additions & 1 deletion src/tmx/Messages/include/Position.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ namespace tmx::messages
{
// Cartesian positiion of object. Assumed to be ENU coordinate frame.
typedef struct Position{
double x, y, z;
double x;
double y;
double z;
Position()=default;
explicit Position(double x, double y, double z):x(x),y(y),z(z){};
static message_tree_type to_tree(const Position& pos){
Expand Down
4 changes: 2 additions & 2 deletions src/tmx/Messages/include/SensorDetectedObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace tmx::messages
class SensorDetectedObject : public tmx::message
{
public:
SensorDetectedObject(){};
SensorDetectedObject(const tmx::message_container_type &contents) : tmx::message(contents) {};
SensorDetectedObject()=default;
explicit SensorDetectedObject(const tmx::message_container_type &contents) : tmx::message(contents) {};
~SensorDetectedObject() override{};
// Message type for routing this message through TMX core
static constexpr const char *MessageType = MSGTYPE_APPLICATION_STRING;
Expand Down
49 changes: 23 additions & 26 deletions src/tmx/Messages/include/Velocity.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
#pragma once
#include <tmx/messages/message.hpp>
namespace tmx
namespace tmx::messages
{
namespace messages
{
// Cartesian velocity vector of object. Assumed to be ENU coordinate frame.
typedef struct Velocity{
double x;
double y;
double z;
Velocity()=default;
explicit Velocity(double x, double y, double z):x(x),y(y),z(z){};
static message_tree_type to_tree(const Velocity& velocity){
message_tree_type tree;
tree.put("x", velocity.x);
tree.put("y", velocity.y);
tree.put("z", velocity.z);
return tree;
}
static Velocity from_tree(const message_tree_type& tree){
Velocity velocity;
velocity.x = tree.get<double>("x");
velocity.y = tree.get<double>("y");
velocity.z = tree.get<double>("z");
return velocity;
}
} Velocity;
}
// Cartesian velocity vector of object. Assumed to be ENU coordinate frame.
typedef struct Velocity{
double x;
double y;
double z;
Velocity()=default;
explicit Velocity(double x, double y, double z):x(x),y(y),z(z){};
static message_tree_type to_tree(const Velocity& velocity){
message_tree_type tree;
tree.put("x", velocity.x);
tree.put("y", velocity.y);
tree.put("z", velocity.z);
return tree;
}
static Velocity from_tree(const message_tree_type& tree){
Velocity velocity;
velocity.x = tree.get<double>("x");
velocity.y = tree.get<double>("y");
velocity.z = tree.get<double>("z");
return velocity;
}
} Velocity;
}

0 comments on commit 2f7e112

Please sign in to comment.