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 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - federico@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/*
23 * This software has been developed by Federico Guerra and SIGNET lab,
24 * University of Padova, in collaboration with the NATO Centre for
25 * Maritime Research and Experimentation (http://www.cmre.nato.int ;
26 * E-mail: pao@cmre.nato.int), whose support is gratefully acknowledged.
27 */
28
29
40#ifndef UNDERWATER_WOSS_WAYPOINT_POSITION_H
41#define UNDERWATER_WOSS_WAYPOINT_POSITION_H
42
43
44#include <map>
45#include <utility>
46#include <climits>
47#include "uw-woss-position.h"
48
49
51
52
53 public:
54
55
57
58 virtual ~WossWpPosition() { }
59
60
61 virtual int command(int argc, const char*const* argv);
62
63
64 virtual bool isEquivalentTo( const woss::CoordZ& coordz );
65
66
67 virtual woss::CoordZ getLocation();
68
69 virtual double getVerticalOrientation();
70
71 virtual double getBearing();
72
73 virtual double getSpeed();
74
75
76 protected:
77
78
79 class WayPoint {
80
81
82 public:
83
84
85 WayPoint( const woss::CoordZ& destination, double speed = 0.0, double time = HUGE_VAL, int loop_id = INT_MAX, int total_loops = 0 );
86
87
88 void setDestination( const woss::CoordZ& dest ) { destination = dest; }
89
90 void setSpeed( double s ) { speed = s; }
91
92 void setTimeToWait( double t ) { time_to_wait = t; }
93
94 void setLoopId( int id ) { loop_to_waypoint_id = id; }
95
96 void setTotalLoops( int loops ) { total_loops = loops; }
97
98
99 const woss::CoordZ& getDestination() const { return destination; }
100
101 // speed used to reach this node
102 double getSpeed() const { return speed; }
103
104 double getTimeToWait() const { return time_to_wait; }
105
106 int getLoopId() const { return loop_to_waypoint_id; }
107
108 int getTotalLoops() const { return total_loops; }
109
110
111 bool isValid() const { return( destination.isValid() && !( speed == 0.0 && time_to_wait == 0.0 ) ); }
112
113 bool hasToLoop() const { return( loop_to_waypoint_id != INT_MAX && total_loops != 0.0 ); }
114
115 bool hasToWait() const { return( speed == 0.0 && time_to_wait > 0 && time_to_wait != HUGE_VAL ); }
116
117 bool hasToStop() const { return( speed == 0.0 && time_to_wait == HUGE_VAL ); }
118
119
120 virtual double getTimeOfArrival( const WayPoint& dest_waypoint ) const;
121
122 virtual woss::CoordZ getCurrentPosition( const WayPoint& dest_waypoint, double time_elapsed ) const;
123
124
125 friend std::ostream& operator<<( std::ostream& os, const WayPoint& instance ) {
126 os << instance.destination << "; speed = " << instance.speed << "; time to wait = " << instance.time_to_wait
127 << "; loop id = " << instance.loop_to_waypoint_id <<"; total loops = " << instance.total_loops;
128 return os;
129 }
130
131 protected:
132
133
134 woss::CoordZ destination;
135
136 double speed;
137
138 double time_to_wait;
139
140 int loop_to_waypoint_id;
141
142 int total_loops;
143
144
145 };
146
147 typedef ::std::vector< WayPoint > WayPointVect;
148
149 typedef ::std::map< double, int > TimeIdMap;
150 typedef TimeIdMap::iterator TIMIter;
151 typedef TimeIdMap::reverse_iterator TIMRIter;
152
153
154 double time_threshold;
155
156 double last_time_update;
157
158 double current_speed;
159
160 WayPointVect waypoint_vect;
161
162 TimeIdMap timeid_map;
163
164
165 virtual void update( double now );
166
167 virtual void updateVerticalOrientation( const woss::CoordZ& prev, const woss::CoordZ& curr );
168
169 virtual void updateBearing( const woss::CoordZ& prev, const woss::CoordZ& curr );
170
171
172 virtual double addWayPoint( const WayPoint& waypoint );
173
174 virtual double addLoopPoint( const WayPoint& waypoint );
175
176
177};
178
179
180#endif // UNDERWATER_WOSS_WAYPOINT_POSITION_H
181
Definition uw-woss-position.h:48
Definition uw-woss-waypoint-position.h:79
Definition uw-woss-waypoint-position.h:50
virtual double getBearing()
Definition uw-woss-waypoint-position.cpp:341
virtual woss::CoordZ getLocation()
Definition uw-woss-waypoint-position.cpp:325
virtual bool isEquivalentTo(const woss::CoordZ &coordz)
Definition uw-woss-waypoint-position.cpp:209
virtual double getVerticalOrientation()
Definition uw-woss-waypoint-position.cpp:332
3D-Coordinates (lat, long, depth) class definitions and functions library
Definition coordinates-definitions.h:403
virtual bool isValid() const
Definition coordinates-definitions.h:645
Provides the interface for WossWpPosition class.