SOLA
Loading...
Searching...
No Matches
amr_mobility_model_ns3.h
1// Copyright 2023 The SOLA authors
2//
3// This file is part of DAISI.
4//
5// DAISI is free software: you can redistribute it and/or modify it under the terms of the GNU
6// General Public License as published by the Free Software Foundation; version 2.
7//
8// DAISI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10// Public License for more details.
11//
12// You should have received a copy of the GNU General Public License along with DAISI. If not, see
13// <https://www.gnu.org/licenses/>.
14//
15// SPDX-License-Identifier: GPL-2.0-only
16
17#ifndef DAISI_CPPS_AMR_PHYSICAL_AMR_MOBILITY_MODEL_NS3_H_
18#define DAISI_CPPS_AMR_PHYSICAL_AMR_MOBILITY_MODEL_NS3_H_
19
20#include <functional>
21#include <queue>
22
23#include "cpps/amr/amr_description.h"
24#include "cpps/amr/amr_mobility_helper.h"
25#include "cpps/amr/amr_topology.h"
26#include "cpps/amr/physical/amr_mobility_status.h"
27#include "cpps/amr/physical/functionality.h"
28#include "ns3/core-module.h"
29#include "ns3/mobility-model.h"
30#include "utils/structure_helpers.h"
31
32namespace daisi::cpps {
33
34class AmrMobilityModelNs3 : public ns3::MobilityModel {
35public:
36 AmrMobilityModelNs3() { phases_.emplace_back(); }
37
38 ~AmrMobilityModelNs3() override = default;
39
41 static ns3::TypeId GetTypeId();
42
43 ns3::TypeId GetInstanceTypeId() const override;
44
45 void execute(const FunctionalityVariant &functionality, const AmrDescription &description,
46 const Topology &topology, FunctionalityDoneCallback notifyDone);
47
50 util::Pose getPose() const;
51 util::Acceleration getAcceleration() const;
52 util::Position getPosition() const;
53 util::Velocity getVelocity() const;
54
55private:
57 ns3::Vector DoGetPosition() const override;
59 void DoSetPosition(const ns3::Vector &position) override;
61 ns3::Vector DoGetVelocity() const override;
62
63 AmrMobilityStatus getStatus() {
64 return AmrMobilityHelper::calculateMobilityStatus(phases_.front(), now());
65 }
66 void startNextPhase();
67
68 util::Duration now() const { return ns3::Simulator::Now().GetSeconds(); }
69 std::deque<AmrMobilityStatus> phases_;
70 FunctionalityVariant current_functionality_;
71 std::function<void(const FunctionalityVariant &)> notifyDone_;
72};
73
74} // namespace daisi::cpps
75#endif
Definition amr_description.h:27
static daisi::cpps::AmrMobilityStatus calculateMobilityStatus(const daisi::cpps::AmrMobilityStatus &current_phase, const util::Duration &current_timestamp)
Calculates the current status of the AMR for simulation.
Definition amr_mobility_helper.cpp:108
Definition amr_mobility_model_ns3.h:34
static ns3::TypeId GetTypeId()
used by ns3
Definition amr_mobility_model_ns3.cpp:63
util::Pose getPose() const
calculates the position of the asset and the angle of the asset
Definition amr_mobility_model_ns3.cpp:44
Definition amr_topology.h:26
Definition amr_mobility_status.h:32
Definition structure_helpers.h:64