magnetic_model.h
Go to the documentation of this file.
1 #pragma once
2 
3 // SPDX-License-Identifier: BSD-3-Clause
4 // SPDX-FileCopyrightText: Czech Technical University in Prague
5 
12 #include <memory>
13 #include <string>
14 
17 #include <geometry_msgs/Vector3.h>
18 #include <ros/time.h>
19 #include <sensor_msgs/MagneticField.h>
20 #include <sensor_msgs/NavSatFix.h>
21 
22 namespace magnetic_model
23 {
24 
29 {
30  sensor_msgs::MagneticField field;
31  geometry_msgs::Vector3 dt;
32  geometry_msgs::Vector3 error;
33 };
34 
39 {
41  double totalMagnitude;
42  double declination;
43  double inclination;
44 };
45 
50 {
54 };
55 
56 struct MagneticModelPrivate;
57 
62 {
63 public:
64  static const char* WMM2010;
65  static const char* WMM2015;
66  static const char* WMM2020;
67  static const char* WMM2025;
68 
77  MagneticModel(const cras::LogHelperPtr& log, const std::string& name, const std::string& modelPath, bool strict);
78  virtual ~MagneticModel();
79 
85  virtual bool isValid(const ros::Time& time) const;
86 
92  virtual bool isValid(int year) const;
93 
100  virtual cras::expected<MagneticField, std::string> getMagneticField(
101  const sensor_msgs::NavSatFix& fix, const ros::Time& stamp) const;
102 
109  virtual cras::expected<MagneticFieldComponentProperties, std::string> getMagneticFieldComponents(
110  const sensor_msgs::NavSatFix& fix, const ros::Time& stamp) const;
111 
118  virtual cras::expected<MagneticFieldComponentProperties, std::string> getMagneticFieldComponents(
119  const MagneticField& field, const ros::Time& stamp) const;
120 
121 protected:
123  bool strict {true};
124 
126  std::unique_ptr<MagneticModelPrivate> data;
127 };
128 
129 }
magnetic_model::MagneticFieldComponents::declination
double declination
Declination of the vector (angle from North towards East) [rad].
Definition: magnetic_model.h:42
magnetic_model::MagneticFieldComponents
Components into which a 3D magnetic vector can be decomposed.
Definition: magnetic_model.h:38
magnetic_model::MagneticModel::WMM2015
static const char * WMM2015
WMM 2015v2 model name.
Definition: magnetic_model.h:65
time.h
magnetic_model::MagneticModel::getMagneticField
virtual cras::expected< MagneticField, std::string > getMagneticField(const sensor_msgs::NavSatFix &fix, const ros::Time &stamp) const
Get the magnetic field vector on the provided place on Earth.
magnetic_model::MagneticFieldComponents::inclination
double inclination
Inclination of the vector (angle from horizontal direction downwards) [rad].
Definition: magnetic_model.h:43
cras::HasLogger
magnetic_model::MagneticFieldComponents::totalMagnitude
double totalMagnitude
Total magnitude of the vector [T].
Definition: magnetic_model.h:41
magnetic_model::MagneticModel
Earth magnetic model.
Definition: magnetic_model.h:61
magnetic_model::MagneticModel::data
std::unique_ptr< MagneticModelPrivate > data
PIMPL data.
Definition: magnetic_model.h:126
magnetic_model::MagneticModel::WMM2020
static const char * WMM2020
WMM 2020 model name.
Definition: magnetic_model.h:66
magnetic_model::MagneticModel::strict
bool strict
If true, the magnetic model will fail if it is used outside its bounds.
Definition: magnetic_model.h:123
log_utils.h
magnetic_model::MagneticModel::~MagneticModel
virtual ~MagneticModel()
magnetic_model
Definition: magnetic_model.h:22
magnetic_model::MagneticModel::WMM2010
static const char * WMM2010
WMM 2010 model name.
Definition: magnetic_model.h:64
magnetic_model::MagneticModel::getMagneticFieldComponents
virtual cras::expected< MagneticFieldComponentProperties, std::string > getMagneticFieldComponents(const sensor_msgs::NavSatFix &fix, const ros::Time &stamp) const
Get the magnetic field components on the provided place on Earth.
magnetic_model::MagneticField::dt
geometry_msgs::Vector3 dt
Time derivative of the field [T/year].
Definition: magnetic_model.h:31
magnetic_model::MagneticField::error
geometry_msgs::Vector3 error
Standard deviations of the magnetic field vector components.
Definition: magnetic_model.h:32
expected.hpp
magnetic_model::MagneticFieldComponentProperties::errors
MagneticFieldComponents errors
Standard deviations of the components [T or rad].
Definition: magnetic_model.h:53
cras::LogHelperPtr
::cras::LogHelper::Ptr LogHelperPtr
magnetic_model::MagneticModel::MagneticModel
MagneticModel(const cras::LogHelperPtr &log, const std::string &name, const std::string &modelPath, bool strict)
Create the magnetic model.
magnetic_model::MagneticModel::isValid
virtual bool isValid(const ros::Time &time) const
Tell whether this model is valid at the given time instant.
ros::Time
cras::HasLogger::log
::cras::LogHelperPtr log
magnetic_model::MagneticField
Properties of a local magnetic field vector.
Definition: magnetic_model.h:28
magnetic_model::MagneticModel::WMM2025
static const char * WMM2025
WMM 2025 model name.
Definition: magnetic_model.h:67
magnetic_model::MagneticFieldComponentProperties
Magnetic field components together with their time derivatives and error terms.
Definition: magnetic_model.h:49
magnetic_model::MagneticField::field
sensor_msgs::MagneticField field
The computed magnetic field vector in ENU convention [T].
Definition: magnetic_model.h:30
magnetic_model::MagneticFieldComponents::horizontalMagnitude
double horizontalMagnitude
Magnitude of the horizontal component [T].
Definition: magnetic_model.h:40
magnetic_model::MagneticFieldComponentProperties::dt
MagneticFieldComponents dt
Time derivatives of the components [T/year or rad/year].
Definition: magnetic_model.h:52
magnetic_model::MagneticFieldComponentProperties::values
MagneticFieldComponents values
Values of the components [T or rad].
Definition: magnetic_model.h:51


magnetic_model
Author(s): Martin Pecka
autogenerated on Wed Jan 8 2025 04:03:10