World Ocean Simulation System (WOSS) library
uw-woss-waypoint-position.h
Go to the documentation of this file.
1/* WOSS - World Ocean Simulation System -
2 *
3 * Copyright (C) 2009 2025 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - WOSS@guerra-tlc.com
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation;
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22
33#ifndef UNDERWATER_WOSS_WAYPOINT_POSITION_H
34#define UNDERWATER_WOSS_WAYPOINT_POSITION_H
35
36
37#include <map>
38#include <utility>
39#include <climits>
40#include <uw-woss-position.h>
41
42
44
45 public:
46
48
49 virtual ~WossWpPosition() override = default;
50
51 virtual int command(int argc, const char*const* argv) override;
52
53 virtual bool isEquivalentTo( const woss::CoordZ& coordz ) override;
54
55 virtual woss::CoordZ getLocation() override;
56
57 virtual double getVerticalOrientation() override;
58
59 virtual double getBearing() override;
60
61 virtual double getSpeed();
62
63
64 protected:
65
66
67 class WayPoint {
68
69 public:
70
71 WayPoint( const woss::CoordZ& destination, double speed = 0.0, double time = HUGE_VAL, int loop_id = INT_MAX, int total_loops = 0 );
72
73 void setDestination( const woss::CoordZ& dest ) { destination = dest; }
74
75 void setSpeed( double s ) { speed = s; }
76
77 void setTimeToWait( double t ) { time_to_wait = t; }
78
79 void setLoopId( int id ) { loop_to_waypoint_id = id; }
80
81 void setTotalLoops( int loops ) { total_loops = loops; }
82
83
84 const woss::CoordZ& getDestination() const { return destination; }
85
86 // speed used to reach this node
87 double getSpeed() const { return speed; }
88
89 double getTimeToWait() const { return time_to_wait; }
90
91 int getLoopId() const { return loop_to_waypoint_id; }
92
93 int getTotalLoops() const { return total_loops; }
94
95
96 bool isValid() const { return( destination.isValid() && !( speed == 0.0 && time_to_wait == 0.0 ) ); }
97
98 bool hasToLoop() const { return( loop_to_waypoint_id != INT_MAX && total_loops != 0.0 ); }
99
100 bool hasToWait() const { return( speed == 0.0 && time_to_wait > 0 && time_to_wait != HUGE_VAL ); }
101
102 bool hasToStop() const { return( speed == 0.0 && time_to_wait == HUGE_VAL ); }
103
104
105 virtual double getTimeOfArrival( const WayPoint& dest_waypoint ) const;
106
107 virtual woss::CoordZ getCurrentPosition( const WayPoint& dest_waypoint, double time_elapsed ) const;
108
109
110 friend std::ostream& operator<<( std::ostream& os, const WayPoint& instance ) {
111 os << instance.destination << "; speed = " << instance.speed << "; time to wait = " << instance.time_to_wait
112 << "; loop id = " << instance.loop_to_waypoint_id <<"; total loops = " << instance.total_loops;
113 return os;
114 }
115
116 protected:
117
119
120 double speed;
121
123
125
127
128 };
129
130 using WayPointVect = std::vector< WayPoint >;
131
132 using TimeIdMap = std::map< double, int >;
133 using TIMIter = TimeIdMap::iterator;
134 using TIMRIter = TimeIdMap::reverse_iterator;
135
136
138
140
142
144
146
147
148 virtual void update( double now );
149
150 virtual void updateVerticalOrientation( const woss::CoordZ& prev, const woss::CoordZ& curr );
151
152 virtual void updateBearing( const woss::CoordZ& prev, const woss::CoordZ& curr );
153
154
155 virtual double addWayPoint( const WayPoint& waypoint );
156
157 virtual double addLoopPoint( const WayPoint& waypoint );
158
159};
160
161#endif // UNDERWATER_WOSS_WAYPOINT_POSITION_H
Definition uw-woss-position.h:41
Definition uw-woss-waypoint-position.h:67
bool isValid() const
Definition uw-woss-waypoint-position.h:96
int getTotalLoops() const
Definition uw-woss-waypoint-position.h:93
void setTimeToWait(double t)
Definition uw-woss-waypoint-position.h:77
double time_to_wait
Definition uw-woss-waypoint-position.h:122
void setLoopId(int id)
Definition uw-woss-waypoint-position.h:79
int loop_to_waypoint_id
Definition uw-woss-waypoint-position.h:124
woss::CoordZ destination
Definition uw-woss-waypoint-position.h:118
double speed
Definition uw-woss-waypoint-position.h:120
void setSpeed(double s)
Definition uw-woss-waypoint-position.h:75
void setTotalLoops(int loops)
Definition uw-woss-waypoint-position.h:81
double getTimeToWait() const
Definition uw-woss-waypoint-position.h:89
bool hasToLoop() const
Definition uw-woss-waypoint-position.h:98
bool hasToStop() const
Definition uw-woss-waypoint-position.h:102
const woss::CoordZ & getDestination() const
Definition uw-woss-waypoint-position.h:84
int total_loops
Definition uw-woss-waypoint-position.h:126
virtual woss::CoordZ getCurrentPosition(const WayPoint &dest_waypoint, double time_elapsed) const
Definition uw-woss-waypoint-position.cpp:81
int getLoopId() const
Definition uw-woss-waypoint-position.h:91
bool hasToWait() const
Definition uw-woss-waypoint-position.h:100
double getSpeed() const
Definition uw-woss-waypoint-position.h:87
virtual double getTimeOfArrival(const WayPoint &dest_waypoint) const
Definition uw-woss-waypoint-position.cpp:50
void setDestination(const woss::CoordZ &dest)
Definition uw-woss-waypoint-position.h:73
friend std::ostream & operator<<(std::ostream &os, const WayPoint &instance)
Definition uw-woss-waypoint-position.h:110
Definition uw-woss-waypoint-position.h:43
virtual int command(int argc, const char *const *argv) override
Definition uw-woss-waypoint-position.cpp:118
std::map< double, int > TimeIdMap
Definition uw-woss-waypoint-position.h:132
double current_speed
Definition uw-woss-waypoint-position.h:141
virtual double addWayPoint(const WayPoint &waypoint)
Definition uw-woss-waypoint-position.cpp:246
virtual void updateVerticalOrientation(const woss::CoordZ &prev, const woss::CoordZ &curr)
Definition uw-woss-waypoint-position.cpp:285
virtual void updateBearing(const woss::CoordZ &prev, const woss::CoordZ &curr)
Definition uw-woss-waypoint-position.cpp:324
virtual bool isEquivalentTo(const woss::CoordZ &coordz) override
Definition uw-woss-waypoint-position.cpp:209
double last_time_update
Definition uw-woss-waypoint-position.h:139
double time_threshold
Definition uw-woss-waypoint-position.h:137
virtual double getSpeed()
Definition uw-woss-waypoint-position.cpp:360
virtual double getBearing() override
Definition uw-woss-waypoint-position.cpp:350
virtual woss::CoordZ getLocation() override
Definition uw-woss-waypoint-position.cpp:332
virtual ~WossWpPosition() override=default
WossWpPosition()
Definition uw-woss-waypoint-position.cpp:107
std::vector< WayPoint > WayPointVect
Definition uw-woss-waypoint-position.h:130
TimeIdMap::reverse_iterator TIMRIter
Definition uw-woss-waypoint-position.h:134
TimeIdMap timeid_map
Definition uw-woss-waypoint-position.h:145
virtual double addLoopPoint(const WayPoint &waypoint)
Definition uw-woss-waypoint-position.cpp:263
virtual void update(double now)
Definition uw-woss-waypoint-position.cpp:215
virtual double getVerticalOrientation() override
Definition uw-woss-waypoint-position.cpp:340
WayPointVect waypoint_vect
Definition uw-woss-waypoint-position.h:143
TimeIdMap::iterator TIMIter
Definition uw-woss-waypoint-position.h:133
3D-Coordinates (lat, long, depth) class definitions and functions library
Definition coordinates-definitions.h:384
constexpr bool isValid() const
Definition coordinates-definitions.h:616
Provides the interface for WossWpPosition class.