DESERT 3.6.0
Loading...
Searching...
No Matches
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(double x_dest, double y_dest, double z_dest, double speed);
149
150 /*
151 * Set the destination of the node with default speed.
152 *
153 * @param double Coordinate along x-axis of destination point
154 * @param double Coordinate along y-axis of destination point
155 * @param double Coordinate along z-axis of destination point
156 * @param double Speed of the node
157 */
158 virtual void setdest(double x_dest, double y_dest, double z_dest);
159
160 /*
161 * Check if the set destination is reached or not.
162 *
163 * @return bool True if reached, false otherwise
164 */
165 virtual bool isDestReached() const;
166
173 virtual void setX(double x) override;
174
181 virtual void setY(double y) override;
182
189 virtual void setZ(double z) override;
190
191private:
197 virtual void update(double now);
198
200 double trgTime_;
202 double Xdest_;
203 double Ydest_;
204 double Zdest_;
205 double Xsorg_;
206 double Ysorg_;
207 double Zsorg_;
208 double speed_;
209};
210
211#endif
virtual void setY(double y) override
Set the projection on y-axis of the node postion.
virtual double getY() override
Get the current projection on y-axis of the node postion If necessary (updating time expired),...
double lastUpdateTime_
Time when last update of the coordinates was computed.
virtual void setZ(double z) override
Set the projection on z-axis of the node postion.
virtual bool isDestReached() const
UWSMPosition()
UWSMPosition constructor.
virtual void update(double now)
Update both the current position coordinates.
virtual double getX() override
Get the current projection on x-axis of the node postion If necessary (updating time expired),...
double getSpeed() const
Get the current speed of the node.
virtual double getZdest() const
Get the z coordinate of the destination point.
virtual double getYdest() const
Get the y coordinate of the destination point.
double speed_
Speed of the node.
virtual void setdest(double x_dest, double y_dest, double z_dest, double speed)
virtual int command(int argc, const char *const *argv) override
TCL command interpreter.
double Zdest_
Position along z-axis of the destination point.
double trgTime_
Time when the TCL command setdest is invoked.
virtual void setX(double x) override
Set the projection on x-axis of the node postion.
virtual double getXdest() const
Get the x coordinate of the destination point.
virtual ~UWSMPosition()=default
UWSMPosition destructor.
double Xdest_
Position along x-axis of the destination point.
double Ydest_
Position along y-axis of the destination point.
virtual double getZ() override
Get the current projection on z-axis of the node postion If necessary (updating time expired),...
double Xsorg_
Position along x-axis of the starting point.
double Zsorg_
Position along z-axis of the starting point.
double Ysorg_
Position along y-axis of the starting point.