DESERT 4.0.0
uwsmposition.h
Go to the documentation of this file.
1//
2// Copyright (c) 2017 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29
48#ifndef _UWSMPOSITION_
49#define _UWSMPOSITION_
50
51#include <node-core.h>
52
53#define sgn(x) (((x) == 0.0) ? 0.0 : ((x) / fabs(x)))
54#define pi (4 * atan(1.0))
55
56class UWSMPosition : public Position
57{
58public:
63
67 virtual ~UWSMPosition() = default;
68
75 virtual double getX() override;
76
83 virtual double getY() override;
84
91 virtual double getZ() override;
92
98 virtual double getXdest() const;
99
105 virtual double getYdest() const;
106
112 virtual double getZdest() const;
113
119 double getSpeed() const;
120
138 virtual int command(int argc, const char *const *argv) override;
139
140 /*
141 * Set the destination of the node with a constant speed.
142 *
143 * @param double Coordinate along x-axis of destination point
144 * @param double Coordinate along y-axis of destination point
145 * @param double Coordinate along z-axis of destination point
146 * @param double Speed of the node
147 */
148 virtual void setdest(
149 double x_dest, double y_dest, double z_dest, double speed);
150
151 /*
152 * Set the destination of the node with default speed.
153 *
154 * @param double Coordinate along x-axis of destination point
155 * @param double Coordinate along y-axis of destination point
156 * @param double Coordinate along z-axis of destination point
157 * @param double Speed of the node
158 */
159 virtual void setdest(double x_dest, double y_dest, double z_dest);
160
161 /*
162 * Check if the set destination is reached or not.
163 *
164 * @return bool True if reached, false otherwise
165 */
166 virtual bool isDestReached() const;
167
174 virtual void setX(double x) override;
175
182 virtual void setY(double y) override;
183
190 virtual void setZ(double z) override;
191
192private:
198 virtual void update(double now);
199
201 double trgTime_;
205 double Xdest_;
206 double Ydest_;
207 double Zdest_;
208 double Xsorg_;
209 double Ysorg_;
210 double Zsorg_;
211 double speed_;
212};
213
214#endif
Definition uwsmposition.h:57
virtual void setY(double y) override
Definition uwsmposition.cpp:268
virtual double getY() override
Definition uwsmposition.cpp:283
double lastUpdateTime_
Definition uwsmposition.h:203
int debug_
Definition uwsmposition.h:200
virtual void setZ(double z) override
Definition uwsmposition.cpp:275
virtual bool isDestReached() const
Definition uwsmposition.cpp:238
UWSMPosition()
Definition uwsmposition.cpp:57
virtual void update(double now)
Definition uwsmposition.cpp:179
virtual double getX() override
Definition uwsmposition.cpp:250
double getSpeed() const
Definition uwsmposition.cpp:323
virtual double getZdest() const
Definition uwsmposition.cpp:317
virtual double getYdest() const
Definition uwsmposition.cpp:311
double speed_
Definition uwsmposition.h:211
virtual void setdest(double x_dest, double y_dest, double z_dest, double speed)
Definition uwsmposition.cpp:110
virtual int command(int argc, const char *const *argv) override
Definition uwsmposition.cpp:73
double Zdest_
Definition uwsmposition.h:207
double trgTime_
Definition uwsmposition.h:201
virtual void setX(double x) override
Definition uwsmposition.cpp:261
virtual double getXdest() const
Definition uwsmposition.cpp:305
virtual ~UWSMPosition()=default
double Xdest_
Definition uwsmposition.h:205
double Ydest_
Definition uwsmposition.h:206
virtual double getZ() override
Definition uwsmposition.cpp:294
double Xsorg_
Definition uwsmposition.h:208
double Zsorg_
Definition uwsmposition.h:210
double Ysorg_
Definition uwsmposition.h:209