repo
stringlengths
1
152
file
stringlengths
14
221
code
stringlengths
501
25k
file_length
int64
501
25k
avg_line_length
float64
20
99.5
max_line_length
int64
21
134
extension_type
stringclasses
2 values
octomap
octomap-master/octomap/include/octomap/octomap_utils.h
/* * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees * https://octomap.github.io/ * * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. * License: New BSD * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the University of Freiburg nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef OCTOMAP_UTILS_H_ #define OCTOMAP_UTILS_H_ #include <math.h> namespace octomap{ /// compute log-odds from probability: inline float logodds(double probability){ return (float) log(probability/(1-probability)); } /// compute probability from logodds: inline double probability(double logodds){ return 1. - ( 1. / (1. + exp(logodds))); } } #endif /* OCTOMAP_UTILS_H_ */
2,183
38
78
h
octomap
octomap-master/octomap/include/octomap/math/Pose6D.h
/* * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees * https://octomap.github.io/ * * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. * License: New BSD * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the University of Freiburg nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef OCTOMATH_POSE6D_H #define OCTOMATH_POSE6D_H #include "Vector3.h" #include "Quaternion.h" namespace octomath { /*! * \brief This class represents a tree-dimensional pose of an object * * The tree-dimensional pose is represented by a three-dimensional * translation vector representing the position of the object and * a Quaternion representing the attitude of the object */ class Pose6D { public: Pose6D(); ~Pose6D(); /*! * \brief Constructor * * Constructs a pose from given translation and rotation. */ Pose6D(const Vector3& trans, const Quaternion& rot); /*! * \brief Constructor * * Constructs a pose from a translation represented by * its x, y, z-values and a rotation represented by its * Tait-Bryan angles roll, pitch, and yaw */ Pose6D(float x, float y, float z, double roll, double pitch, double yaw); Pose6D(const Pose6D& other); Pose6D& operator= (const Pose6D& other); bool operator==(const Pose6D& other) const; bool operator!=(const Pose6D& other) const; /*! * \brief Translational component * * @return the translational component of this pose */ inline Vector3& trans() { return translation; } /*! * \brief Rotational component * * @return the rotational component of this pose */ inline Quaternion& rot() { return rotation; } /*! * \brief Translational component * * @return the translational component of this pose */ const Vector3& trans() const { return translation; } /*! * \brief Rotational component * @return the rotational component of this pose */ const Quaternion& rot() const { return rotation; } inline float& x() { return translation(0); } inline float& y() { return translation(1); } inline float& z() { return translation(2); } inline const float& x() const { return translation(0); } inline const float& y() const { return translation(1); } inline const float& z() const { return translation(2); } inline double roll() const {return (rotation.toEuler())(0); } inline double pitch() const {return (rotation.toEuler())(1); } inline double yaw() const {return (rotation.toEuler())(2); } /*! * \brief Transformation of a vector * * Transforms the vector v by the transformation which is * specified by this. * @return the vector which is translated by the translation of * this and afterwards rotated by the rotation of this. */ Vector3 transform (const Vector3 &v) const; /*! * \brief Inversion * * Inverts the coordinate transformation represented by this pose * @return a copy of this pose inverted */ Pose6D inv() const; /*! * \brief Inversion * * Inverts the coordinate transformation represented by this pose * @return a reference to this pose */ Pose6D& inv_IP(); /*! * \brief Concatenation * * Concatenates the coordinate transformations represented * by this and p. * @return this * p (applies first this, then p) */ Pose6D operator* (const Pose6D &p) const; /*! * \brief In place concatenation * * Concatenates p to this Pose6D. * @return this which results from first moving by this and * afterwards by p */ const Pose6D& operator*= (const Pose6D &p); /*! * \brief Translational distance * * @return the translational (euclidian) distance to p */ double distance(const Pose6D &other) const; /*! * \brief Translational length * * @return the translational (euclidian) length of the translation * vector of this Pose6D */ double transLength() const; /*! * \brief Output operator * * Output to stream in a format which can be parsed using read(). */ std::ostream& write(std::ostream &s) const; /*! * \brief Input operator * * Parsing from stream which was written by write(). */ std::istream& read(std::istream &s); /*! * \brief Binary output operator * * Output to stream in a binary format which can be parsed using readBinary(). */ std::ostream& writeBinary(std::ostream &s) const; /*! * \brief Binary input operator * * Parsing from binary stream which was written by writeBinary(). */ std::istream& readBinary(std::istream &s); protected: Vector3 translation; Quaternion rotation; }; //! user friendly output in format (x y z, u x y z) which is (translation, rotation) std::ostream& operator<<(std::ostream& s, const Pose6D& p); } #endif
6,525
30.52657
86
h
octomap
octomap-master/octomap/include/octomap/math/Quaternion.h
/* * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees * https://octomap.github.io/ * * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. * License: New BSD * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the University of Freiburg nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef OCTOMATH_QUATERNION_H #define OCTOMATH_QUATERNION_H #include "Vector3.h" #include <iostream> #include <vector> namespace octomath { /*! * \brief This class represents a Quaternion. * * The Unit Quaternion is one possible representation of the * attitude of an object in tree-dimensional space. * * This Quaternion class is implemented according to Diebel, * James. Representing Attitude: Euler Angle, Unit Quaternions, and * Rotation Vectors. Stanford University. 2006. - Technical Report. */ class Quaternion { public: /*! * \brief Default constructor * * Constructs the (1,0,0,0) Unit Quaternion * representing the identity rotation. */ inline Quaternion() { u() = 1; x() = 0; y() = 0; z() = 0; } /*! * \brief Copy constructor */ Quaternion(const Quaternion& other); /*! * \brief Constructor * * Constructs a Quaternion from four single * values */ Quaternion(float u, float x, float y, float z); /*! * \brief Constructor * * @param other a vector containing euler angles */ Quaternion(const Vector3& other); /*! * \brief Constructor from Euler angles * * Constructs a Unit Quaternion from Euler angles / Tait Bryan * angles (in radians) according to the 1-2-3 convention. * @param roll phi/roll angle (rotation about x-axis) * @param pitch theta/pitch angle (rotation about y-axis) * @param yaw psi/yaw angle (rotation about z-axis) */ Quaternion(double roll, double pitch, double yaw); //! Constructs a Unit Quaternion from a rotation angle and axis. Quaternion(const Vector3& axis, double angle); /*! * \brief Conversion to Euler angles * * Converts the attitude represented by this to * Euler angles (roll, pitch, yaw). */ Vector3 toEuler() const; void toRotMatrix(std::vector <double>& rot_matrix_3_3) const; inline const float& operator() (unsigned int i) const { return data[i]; } inline float& operator() (unsigned int i) { return data[i]; } float norm () const; Quaternion normalized () const; Quaternion& normalize (); void operator/= (float x); Quaternion& operator= (const Quaternion& other); bool operator== (const Quaternion& other) const; /*! * \brief Quaternion multiplication * * Standard Quaternion multiplication which is not * commutative. * @return this * other */ Quaternion operator* (const Quaternion& other) const; /*! * \brief Quaternion multiplication with extended vector * * @return q * (0, v) */ Quaternion operator* (const Vector3 &v) const; /*! * \brief Quaternion multiplication with extended vector * * @return (0, v) * q */ friend Quaternion operator* (const Vector3 &v, const Quaternion &q); /*! * \brief Inversion * * @return A copy of this Quaterion inverted */ inline Quaternion inv() const { return Quaternion(u(), -x(), -y(), -z()); } /*! * \brief Inversion * * Inverts this Quaternion * @return a reference to this Quaternion */ Quaternion& inv_IP(); /*! * \brief Rotate a vector * * Rotates a vector to the body fixed coordinate * system according to the attitude represented by * this Quaternion. * @param v a vector represented in world coordinates * @return v represented in body-fixed coordinates */ Vector3 rotate(const Vector3 &v) const; inline float& u() { return data[0]; } inline float& x() { return data[1]; } inline float& y() { return data[2]; } inline float& z() { return data[3]; } inline const float& u() const { return data[0]; } inline const float& x() const { return data[1]; } inline const float& y() const { return data[2]; } inline const float& z() const { return data[3]; } std::istream& read(std::istream &s); std::ostream& write(std::ostream &s) const; std::istream& readBinary(std::istream &s); std::ostream& writeBinary(std::ostream &s) const; protected: float data[4]; }; //! user friendly output in format (u x y z) std::ostream& operator<<(std::ostream& s, const Quaternion& q); } #endif
6,132
29.063725
80
h
octomap
octomap-master/octomap/include/octomap/math/Utils.h
/* * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees * https://octomap.github.io/ * * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. * License: New BSD * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the University of Freiburg nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef OCTOMATH_UTILS_H #define OCTOMATH_UTILS_H #ifndef M_PI #define M_PI 3.14159265358979323846 #endif #ifndef M_PI_2 #define M_PI_2 1.570796326794896619 #endif #ifndef DEG2RAD #define DEG2RAD(x) ((x) * 0.01745329251994329575) #endif #ifndef RAD2DEG #define RAD2DEG(x) ((x) * 57.29577951308232087721) #endif #endif
2,106
35.964912
78
h
octomap
octomap-master/octomap/include/octomap/math/Vector3.h
/* * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees * https://octomap.github.io/ * * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. * License: New BSD * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the University of Freiburg nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef OCTOMATH_VECTOR3_H #define OCTOMATH_VECTOR3_H #include <iostream> #include <math.h> namespace octomath { /*! * \brief This class represents a three-dimensional vector * * The three-dimensional vector can be used to represent a * translation in three-dimensional space or to represent the * attitude of an object using Euler angle. */ class Vector3 { public: /*! * \brief Default constructor */ Vector3 () { data[0] = data[1] = data[2] = 0.0; } /*! * \brief Copy constructor * * @param other a vector of dimension 3 */ Vector3 (const Vector3& other) { data[0] = other(0); data[1] = other(1); data[2] = other(2); } /*! * \brief Constructor * * Constructs a three-dimensional vector from * three single values x, y, z or roll, pitch, yaw */ Vector3 (float x, float y, float z) { data[0] = x; data[1] = y; data[2] = z; } /* inline Eigen3::Vector3f getVector3f() const { return Eigen3::Vector3f(data[0], data[1], data[2]) ; } */ /* inline Eigen3::Vector4f& getVector4f() { return data; } */ /* inline Eigen3::Vector4f getVector4f() const { return data; } */ /*! * \brief Assignment operator * * @param other a vector of dimension 3 */ inline Vector3& operator= (const Vector3& other) { data[0] = other(0); data[1] = other(1); data[2] = other(2); return *this; } /*! * \brief Three-dimensional vector (cross) product * * Calculates the tree-dimensional cross product, which * represents the vector orthogonal to the plane defined * by this and other. * @return this x other */ inline Vector3 cross (const Vector3& other) const { //return (data.start<3> ().cross (other.data.start<3> ())); // \note should this be renamed? return Vector3(y()*other.z() - z()*other.y(), z()*other.x() - x()*other.z(), x()*other.y() - y()*other.x()); } /// dot product inline double dot (const Vector3& other) const { return x()*other.x() + y()*other.y() + z()*other.z(); } inline const float& operator() (unsigned int i) const { return data[i]; } inline float& operator() (unsigned int i) { return data[i]; } inline float& x() { return operator()(0); } inline float& y() { return operator()(1); } inline float& z() { return operator()(2); } inline const float& x() const { return operator()(0); } inline const float& y() const { return operator()(1); } inline const float& z() const { return operator()(2); } inline float& roll() { return operator()(0); } inline float& pitch() { return operator()(1); } inline float& yaw() { return operator()(2); } inline const float& roll() const { return operator()(0); } inline const float& pitch() const { return operator()(1); } inline const float& yaw() const { return operator()(2); } inline Vector3 operator- () const { Vector3 result; result(0) = -data[0]; result(1) = -data[1]; result(2) = -data[2]; return result; } inline Vector3 operator+ (const Vector3 &other) const { Vector3 result(*this); result(0) += other(0); result(1) += other(1); result(2) += other(2); return result; } inline Vector3 operator* (float x) const { Vector3 result(*this); result(0) *= x; result(1) *= x; result(2) *= x; return result; } inline Vector3 operator- (const Vector3 &other) const { Vector3 result(*this); result(0) -= other(0); result(1) -= other(1); result(2) -= other(2); return result; } inline void operator+= (const Vector3 &other) { data[0] += other(0); data[1] += other(1); data[2] += other(2); } inline void operator-= (const Vector3& other) { data[0] -= other(0); data[1] -= other(1); data[2] -= other(2); } inline void operator/= (float x) { data[0] /= x; data[1] /= x; data[2] /= x; } inline void operator*= (float x) { data[0] *= x; data[1] *= x; data[2] *= x; } inline bool operator== (const Vector3 &other) const { for (unsigned int i=0; i<3; i++) { if (operator()(i) != other(i)) return false; } return true; } /// @return length of the vector ("L2 norm") inline double norm () const { return sqrt(norm_sq()); } /// @return squared length ("L2 norm") of the vector inline double norm_sq() const { return (x()*x() + y()*y() + z()*z()); } /// normalizes this vector, so that it has norm=1.0 inline Vector3& normalize () { double len = norm(); if (len > 0) *this /= (float) len; return *this; } /// @return normalized vector, this one remains unchanged inline Vector3 normalized () const { Vector3 result(*this); result.normalize (); return result; } inline double angleTo(const Vector3& other) const { double dot_prod = this->dot(other); double len1 = this->norm(); double len2 = other.norm(); return acos(dot_prod / (len1*len2)); } inline double distance (const Vector3& other) const { double dist_x = x() - other.x(); double dist_y = y() - other.y(); double dist_z = z() - other.z(); return sqrt(dist_x*dist_x + dist_y*dist_y + dist_z*dist_z); } inline double distanceXY (const Vector3& other) const { double dist_x = x() - other.x(); double dist_y = y() - other.y(); return sqrt(dist_x*dist_x + dist_y*dist_y); } Vector3& rotate_IP (double roll, double pitch, double yaw); // void read (unsigned char * src, unsigned int size); std::istream& read(std::istream &s); std::ostream& write(std::ostream &s) const; std::istream& readBinary(std::istream &s); std::ostream& writeBinary(std::ostream &s) const; protected: float data[3]; }; //! user friendly output in format (x y z) std::ostream& operator<<(std::ostream& out, octomath::Vector3 const& v); } #endif
8,332
24.48318
110
h
octomap
octomap-master/octovis/include/octovis/CameraFollowMode.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef CAMERAFOLLOWMODE_H_ #define CAMERAFOLLOWMODE_H_ #include "SceneObject.h" #include <QObject> class CameraFollowMode : public QObject { Q_OBJECT public: CameraFollowMode(octomap::ScanGraph *graph = NULL); virtual ~CameraFollowMode(); void setScanGraph(octomap::ScanGraph *graph); public slots: void jumpToFrame(unsigned int frame); void cameraPathStopped(int id); void cameraPathFrameChanged(int id, int current_camera_frame); void play(); void pause(); void clearCameraPath(); void saveToCameraPath(); void addToCameraPath(); void removeFromCameraPath(); void followCameraPath(); void followRobotPath(); signals: void changeCamPose(const octomath::Pose6D& pose); void interpolateCamPose(const octomath::Pose6D& old_pose, const octomath::Pose6D& new_pose, double u); void stopped(); void frameChanged(unsigned int frame); void deleteCameraPath(int id); void removeFromCameraPath(int id, int frame); void updateCameraPath(int id, int frame); void appendToCameraPath(int id, const octomath::Pose6D& pose); void appendCurrentToCameraPath(int id); void addCurrentToCameraPath(int id, int frame); void playCameraPath(int id, int start_frame); void stopCameraPath(int id); void jumpToCamFrame(int id, int frame); void changeNumberOfFrames(unsigned count); void scanGraphAvailable(bool available); protected: octomap::ScanGraph *m_scan_graph; unsigned int m_current_scan; unsigned int m_current_cam_frame; unsigned int m_number_cam_frames; unsigned int m_start_frame; bool m_followRobotTrajectory; }; #endif /* CAMERAFOLLOWMODE_H_ */
2,602
31.5375
104
h
octomap
octomap-master/octovis/include/octovis/ColorOcTreeDrawer.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef OCTOVIS_COLOR_OCTREEDRAWER_H_ #define OCTOVIS_COLOR_OCTREEDRAWER_H_ #include <octovis/OcTreeDrawer.h> #include <octomap/ColorOcTree.h> namespace octomap { class ColorOcTreeDrawer : public OcTreeDrawer { public: ColorOcTreeDrawer(); virtual ~ColorOcTreeDrawer(); virtual void setOcTree(const AbstractOcTree& tree_pnt, const pose6d& origin, int map_id_); protected: }; } // end namespace #endif
1,428
28.163265
94
h
octomap
octomap-master/octovis/include/octovis/OcTreeDrawer.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef OCTREEDRAWER_H_ #define OCTREEDRAWER_H_ #include "SceneObject.h" namespace octomap { class OcTreeDrawer: public octomap::SceneObject { public: OcTreeDrawer(); virtual ~OcTreeDrawer(); void clear(); void draw() const; // initialization of drawer ------------------------- /// sets a new OcTree that should be drawn by this drawer void setOcTree(const AbstractOcTree& octree){ octomap::pose6d o; // initialized to (0,0,0) , (0,0,0,1) by default setOcTree(octree, o, 0); } /// sets a new OcTree that should be drawn by this drawer /// origin specifies a global transformation that should be applied virtual void setOcTree(const AbstractOcTree& octree, const octomap::pose6d& origin, int map_id_); // modification of existing drawer ------------------ /// sets a new selection of the current OcTree to be drawn void setOcTreeSelection(const std::list<octomap::OcTreeVolume>& selectedPoints); /// clear the visualization of the OcTree selection void clearOcTreeSelection(); /// sets alpha level for occupied cells void setAlphaOccupied(double alpha); void setAlternativeDrawing(bool flag){m_alternativeDrawing = flag;} void enableOcTree(bool enabled = true); void enableOcTreeCells(bool enabled = true) { m_update = true; m_drawOccupied = enabled; }; void enableFreespace(bool enabled = true) { m_update = true; m_drawFree = enabled; }; void enableSelection(bool enabled = true) { m_update = true; m_drawSelection = enabled; }; void setMax_tree_depth(unsigned int max_tree_depth) { m_update = true; m_max_tree_depth = max_tree_depth;}; // set new origin (move object) void setOrigin(octomap::pose6d t); void enableAxes(bool enabled = true) { m_update = true; m_displayAxes = enabled; }; protected: //void clearOcTree(); void clearOcTreeStructure(); void drawOctreeGrid() const; void drawOccupiedVoxels() const; void drawFreeVoxels() const; void drawSelection() const; void drawCubes(GLfloat** cubeArray, unsigned int cubeArraySize, GLfloat* cubeColorArray = NULL) const; void drawAxes() const; //! Initializes the OpenGL visualization for a list of OcTreeVolumes //! The array is cleared first, if needed /// rotates cubes to correct reference frame void generateCubes(const std::list<octomap::OcTreeVolume>& voxels, GLfloat*** glArray, unsigned int& glArraySize, octomath::Pose6D& origin, GLfloat** glColorArray = NULL); //! clear OpenGL visualization void clearCubes(GLfloat*** glArray, unsigned int& glArraySize, GLfloat** glColorArray = NULL); //! setup OpenGL arrays void initGLArrays(const unsigned int& num_cubes, unsigned int& glArraySize, GLfloat*** glArray, GLfloat** glColorArray); //! setup cube template void initCubeTemplate(const octomath::Pose6D& origin, std::vector<octomath::Vector3>& cube_template); //! add one cube to arrays unsigned int generateCube(const octomap::OcTreeVolume& v, const std::vector<octomath::Vector3>& cube_template, const unsigned int& current_array_idx, GLfloat*** glArray); unsigned int setCubeColorHeightmap(const octomap::OcTreeVolume& v, const unsigned int& current_array_idx, GLfloat** glColorArray); unsigned int setCubeColorRGBA(const unsigned char& r, const unsigned char& g, const unsigned char& b, const unsigned char& a, const unsigned int& current_array_idx, GLfloat** glColorArray); void initOctreeGridVis(); //! OpenGL representation of Octree cells (cubes) GLfloat** m_occupiedThresArray; unsigned int m_occupiedThresSize; GLfloat** m_freeThresArray; unsigned int m_freeThresSize; GLfloat** m_occupiedArray; unsigned int m_occupiedSize; GLfloat** m_freeArray; unsigned int m_freeSize; GLfloat** m_selectionArray; unsigned int m_selectionSize; //! Color array for occupied cells (height) GLfloat* m_occupiedThresColorArray; GLfloat* m_occupiedColorArray; //! OpenGL representation of Octree (grid structure) // TODO: put in its own drawer object! GLfloat* octree_grid_vertex_array; unsigned int octree_grid_vertex_size; std::list<octomap::OcTreeVolume> m_grid_voxels; bool m_drawOccupied; bool m_drawOcTreeGrid; bool m_drawFree; bool m_drawSelection; bool m_octree_grid_vis_initialized; bool m_displayAxes; bool m_alternativeDrawing; mutable bool m_update; unsigned int m_max_tree_depth; double m_alphaOccupied; octomap::pose6d origin; octomap::pose6d initial_origin; int map_id; }; } #endif /* OCTREEDRAWER_H_ */
6,070
36.018293
111
h
octomap
octomap-master/octovis/include/octovis/OcTreeRecord.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef OCTOVIS_OC_TREE_RECORD #define OCTOVIS_OC_TREE_RECORD #include <octovis/OcTreeDrawer.h> namespace octomap { class OcTreeRecord { public: AbstractOcTree* octree; OcTreeDrawer* octree_drawer; unsigned int id; pose6d origin; }; } // namespace #endif
1,289
29
77
h
octomap
octomap-master/octovis/include/octovis/PointcloudDrawer.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef POINTCLOUDDRAWER_H_ #define POINTCLOUDDRAWER_H_ #include "SceneObject.h" namespace octomap { /** * Drawer which visualizes Pointclouds */ class PointcloudDrawer: public ScanGraphDrawer { public: PointcloudDrawer(); PointcloudDrawer(const ScanGraph& graph); virtual ~PointcloudDrawer(); virtual void draw() const; virtual void clear(); virtual void setScanGraph(const ScanGraph& graph); protected: GLfloat* m_pointsArray; unsigned m_numberPoints; }; } #endif /* POINTCLOUDDRAWER_H_ */
1,537
27.481481
77
h
octomap
octomap-master/octovis/include/octovis/SceneObject.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef SCENEOBJECT_H_ #define SCENEOBJECT_H_ // fix Windows includes #include <qglobal.h> #if defined(Q_WS_WIN) || defined(Q_OS_WIN) #include <QtCore/qt_windows.h> #endif #if defined(Q_WS_MAC) || defined(Q_OS_MAC) #include <OpenGL/glu.h> #else #include <GL/glu.h> #endif #include <octomap/octomap.h> namespace octomap { /** * Abstract base class for objects to be drawn in the ViewerWidget. * */ class SceneObject { public: enum ColorMode { CM_FLAT, CM_PRINTOUT, CM_COLOR_HEIGHT, CM_GRAY_HEIGHT, CM_SEMANTIC }; public: SceneObject(); virtual ~SceneObject(){}; /** * Actual draw function which will be called to visualize the object */ virtual void draw() const = 0; /** * Clears the object's representation (will be called when it gets invalid) */ virtual void clear(){}; public: //! the color mode has to be set before calling OcTreDrawer::setMap() //! because the cubes are generated in OcTreDrawer::setMap() using the color information inline void setColorMode(ColorMode mode) { m_colorMode = mode; } inline void enablePrintoutMode(bool enabled = true) { if (enabled) m_colorMode = CM_PRINTOUT; else m_colorMode = CM_FLAT; } inline void enableHeightColorMode(bool enabled = true) { if (enabled) m_colorMode = CM_COLOR_HEIGHT; else m_colorMode = CM_FLAT; } inline void enableSemanticColoring(bool enabled = true) { if (enabled) m_colorMode = CM_SEMANTIC; else m_colorMode = CM_FLAT; } protected: /// writes rgb values which correspond to a rel. height in the map. /// (glArrayPos needs to have at least size 3!) void heightMapColor(double h, GLfloat* glArrayPos) const; void heightMapGray(double h, GLfloat* glArrayPos) const; double m_zMin; double m_zMax; ColorMode m_colorMode; }; /** * Abstract base class for all objects visualizing ScanGraphs. */ class ScanGraphDrawer : public SceneObject { public: ScanGraphDrawer(): SceneObject(){}; virtual ~ScanGraphDrawer(){}; /** * Notifies drawer of a new or changed ScanGraph, so that the internal * representation can be rebuilt. Needs to be overloaded by each specific * drawer. * * @param graph ScanGraph to be visualized */ virtual void setScanGraph(const octomap::ScanGraph& graph) = 0; }; } #endif /* SCENEOBJECT_H_ */
3,389
28.736842
134
h
octomap
octomap-master/octovis/include/octovis/SelectionBox.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef SELECTIONBOX_H_ #define SELECTIONBOX_H_ #include <qglviewer.h> namespace octomap { class SelectionBox{ public: SelectionBox(); virtual ~SelectionBox(); void draw(bool withNames = false); const qglviewer::ManipulatedFrame* frame (unsigned short i) const { return m_frames.at(i); } qglviewer::ManipulatedFrame* frame (unsigned short i) { return m_frames.at(i); } void getBBXMin(float& x, float& y, float& z) const; void getBBXMax(float& x, float& y, float& z) const; int getGrabbedFrame() const; protected: void drawAxis(float length = 0.2f) const; bool m_visible; std::vector<qglviewer::ManipulatedFrame*> m_frames; unsigned short m_selectedFrame; qglviewer::Vec m_minPt; qglviewer::Vec m_maxPt; float m_arrowLength; }; } #endif
1,806
27.68254
96
h
octomap
octomap-master/octovis/include/octovis/TrajectoryDrawer.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef TRAJECTORYDRAWER_H_ #define TRAJECTORYDRAWER_H_ #include "SceneObject.h" #include <vector> namespace octomap { class TrajectoryDrawer : public ScanGraphDrawer{ public: TrajectoryDrawer(); TrajectoryDrawer(const ScanGraph& graph); virtual ~TrajectoryDrawer(); virtual void draw() const; virtual void clear(); virtual void setScanGraph(const octomap::ScanGraph& graph); protected: GLfloat* m_trajectoryVertexArray; GLfloat* m_trajectoryColorArray; unsigned int m_trajectorySize; //!< number of nodes in the ScanGraph }; } #endif /* TRAJECTORYDRAWER_H_ */
1,600
30.392157
77
h
octomap
octomap-master/octovis/include/octovis/ViewerGui.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef VIEWERGUI_H #define VIEWERGUI_H #include <qglobal.h> #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include <QtWidgets> #else // QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include <QtGui> #endif // QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include <QFileDialog> #include <QMessageBox> #include <QDockWidget> #include <string> #include <cmath> #include "TrajectoryDrawer.h" #include "PointcloudDrawer.h" #include "OcTreeDrawer.h" #include "CameraFollowMode.h" #include "ViewerWidget.h" #include "ViewerSettings.h" #include "ViewerSettingsPanel.h" #include "ViewerSettingsPanelCamera.h" #include "ui_ViewerGui.h" #include <octomap/AbstractOcTree.h> #include <octomap/OcTreeBase.h> #include <octovis/OcTreeRecord.h> namespace octomap { class ViewerGui : public QMainWindow { Q_OBJECT public: ViewerGui(const std::string& filename="", QWidget *parent = 0, unsigned int initTreeDepth = 16); ~ViewerGui(); static const unsigned int LASERTYPE_URG = 0; static const unsigned int LASERTYPE_SICK = 1; // use this drawer id if loading files or none is specified in msg static const unsigned int DEFAULT_OCTREE_ID = 0; public slots: void changeTreeDepth(int depth); void addNextScans(unsigned scans); void gotoFirstScan(); bool isShown(); private slots: // auto-connected Slots (by name)) void on_actionExit_triggered(); void on_actionOpen_file_triggered(); void on_actionOpen_graph_incremental_triggered(); void on_actionSave_file_triggered(); void on_actionExport_view_triggered(); void on_actionExport_sequence_triggered(bool checked); void on_actionClear_selection_triggered(); void on_actionFill_selection_triggered(); void on_actionClear_unknown_in_selection_triggered(); void on_actionFill_unknown_in_selection_triggered(); void on_actionClear_nodes_in_selection_triggered(); void on_actionFill_nodes_in_selection_triggered(); void on_actionDelete_nodes_in_selection_triggered(); void on_actionDelete_nodes_outside_of_selection_triggered(); void on_actionHelp_triggered(); void on_actionSettings_triggered(); void on_actionPrune_tree_triggered(); void on_actionExpand_tree_triggered(); void on_actionConvert_ml_tree_triggered(); void on_actionReload_Octree_triggered(); void on_actionPrintout_mode_toggled(bool checked); void on_actionSelection_box_toggled(bool checked); void on_actionHeight_map_toggled(bool checked); void on_actionSemanticColoring_toggled(bool checked); void on_actionStore_camera_triggered(); void on_actionRestore_camera_triggered(); void on_actionPointcloud_toggled(bool checked); void on_actionTrajectory_toggled(bool checked); void on_actionOctree_cells_toggled(bool enabled); void on_actionOctree_structure_toggled(bool enabled); void on_actionFree_toggled(bool enabled); void on_actionSelected_toggled(bool enabled); void on_actionAxes_toggled(bool checked); void on_actionHideBackground_toggled(bool checked); void on_actionAlternateRendering_toggled(bool checked); void on_actionClear_triggered(); void voxelSelected(const QMouseEvent* e); void on_action_bg_black_triggered(); void on_action_bg_white_triggered(); void on_action_bg_gray_triggered(); void on_savecampose_triggered(); void on_loadcampose_triggered(); // use it for testcases etc. void on_actionTest_triggered(); signals: void updateStatusBar(QString message, int duration); void changeNumberOfScans(unsigned scans); void changeCurrentScan(unsigned scans); void changeResolution(double resolution); void changeCamPosition(double x, double y, double z, double lookX, double lookY, double lookZ); private: /** * (Re-)load the data file stored in m_fileName. * Depending on the extension, the respective load function is used. */ void openFile(); /** * Reads in a .dat file which consists of single points in ASCII, * one point per line, values separated by white spaces */ void openPointcloud(); /** * Opens a .graph file and generates a ScanGraph from it. Afterwards, * loadGraph() is called. */ void openGraph(bool completeGraph = true); /** * Finishes loading a ScanGraph, either from .log or .graph. */ void loadGraph(bool completeGraph = true); /** * Adds a scan from the graph to the OcTree */ void addNextScan(); /** * Opens a .pc PointCloud */ void openPC(); /// open "regular" file containing an octree void openOcTree(); /// open binary format OcTree void openTree(); // EXPERIMENTAL // open a map collection (.hot-file) void openMapCollection(); void setOcTreeUISwitches(); /*! * (Re-)generates OcTree from the internally stored ScanGraph */ void generateOctree(); void showOcTree(); void showInfo(QString string, bool newline=false); void addOctree(AbstractOcTree* tree, int id, pose6d origin); void addOctree(AbstractOcTree* tree, int id); bool getOctreeRecord(int id, OcTreeRecord*& otr); void saveCameraPosition(const char* filename) const; void loadCameraPosition(const char* filename); void updateNodesInBBX(const point3d& min, const point3d& max, bool occupied); void setNodesInBBX(const point3d& min, const point3d& max, bool occupied); void setNonNodesInBBX(const point3d& min, const point3d& max, bool occupied); std::map<int, OcTreeRecord> m_octrees; ScanGraph* m_scanGraph; ScanGraph::iterator m_nextScanToAdd; Ui::ViewerGuiClass ui; ViewerWidget* m_glwidget; TrajectoryDrawer* m_trajectoryDrawer; PointcloudDrawer* m_pointcloudDrawer; CameraFollowMode* m_cameraFollowMode; double m_octreeResolution; double m_laserMaxRange; double m_occupancyThresh; // FIXME: This is not really used at the moment... unsigned int m_max_tree_depth; unsigned int m_laserType; // SICK or Hokuyo /URG bool m_cameraStored; QLabel* m_nodeSelected; QLabel* m_mapSizeStatus; QLabel* m_mapMemoryStatus; /// Filename of last loaded file, in case it is necessary to reload it std::string m_filename; }; } // namespace #endif // VIEWERGUI_H
7,314
30.943231
100
h
octomap
octomap-master/octovis/include/octovis/ViewerSettings.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef VIEWERSETTINGS_H #define VIEWERSETTINGS_H #include <QtGlobal> #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include <QtWidgets/QDialog> #else // QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include <QtGui/QDialog> #endif // QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include "ui_ViewerSettings.h" class ViewerSettings : public QDialog { Q_OBJECT public: ViewerSettings(QWidget *parent = 0); ~ViewerSettings(); double getResolution(){return ui.resolution->value(); }; void setResolution(double resolution){ui.resolution->setValue(resolution);}; unsigned int getLaserType(){return ui.laserType->currentIndex(); }; void setLaserType(int type){ui.laserType->setCurrentIndex(type); }; double getMaxRange(){return ui.maxRange->value(); }; void setMaxRange(double range){ui.maxRange->setValue(range); }; private: Ui::ViewerSettingsClass ui; }; #endif // VIEWERSETTINGS_H
1,900
33.563636
80
h
octomap
octomap-master/octovis/include/octovis/ViewerSettingsPanel.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef VIEWERSETTINGSPANEL_H #define VIEWERSETTINGSPANEL_H #include <math.h> #include <QWidget> #include "ui_ViewerSettingsPanel.h" #define _TREE_MAX_DEPTH 16 class ViewerSettingsPanel : public QWidget { Q_OBJECT public: ViewerSettingsPanel(QWidget *parent = 0); ~ViewerSettingsPanel(); public slots: void setNumberOfScans(unsigned scans); void setCurrentScan(unsigned scan); void setResolution(double resolution); void setTreeDepth(int depth); private slots: void on_firstScanButton_clicked(); void on_lastScanButton_clicked(); void on_nextScanButton_clicked(); void on_fastFwdScanButton_clicked(); signals: void treeDepthChanged(int depth); void addNextScans(unsigned scans); void gotoFirstScan(); private: void scanProgressChanged(); void leafSizeChanged(); Ui::ViewerSettingsPanelClass ui; unsigned m_currentScan; unsigned m_numberScans; unsigned m_treeDepth; double m_resolution; }; #endif // VIEWERSETTINGSPANEL_H
1,998
27.15493
77
h
octomap
octomap-master/octovis/include/octovis/ViewerSettingsPanelCamera.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef VIEWERSETTINGSPANELFLYMODE_H #define VIEWERSETTINGSPANELFLYMODE_H #include <qglobal.h> #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include <QtWidgets/QWidget> #else #include <QtGui/QWidget> #endif #include "ui_ViewerSettingsPanelCamera.h" class ViewerSettingsPanelCamera : public QWidget { Q_OBJECT public: ViewerSettingsPanelCamera(QWidget *parent = 0); ~ViewerSettingsPanelCamera(); QSize sizeHint() const; public slots: void setNumberOfFrames(unsigned frames); void setCurrentFrame(unsigned frame); void setRobotTrajectoryAvailable(bool available); void setStopped(); private slots: void on_firstScanButton_clicked(); void on_lastScanButton_clicked(); void on_nextScanButton_clicked(); void on_previousScanButton_clicked(); void on_playScanButton_clicked(); void on_scanProgressSlider_sliderMoved(int value); void on_followCameraPathButton_clicked(); void on_followTrajectoryButton_clicked(); void on_cameraPathAdd_clicked(); void on_cameraPathRemove_clicked(); void on_cameraPathSave_clicked(); void on_cameraPathClear_clicked(); void positionEditDone(double); signals: void changeCamPosition(double x, double y, double z, double lookX, double lookY, double lookZ); void jumpToFrame(unsigned int frame); void play(); void pause(); void clearCameraPath(); void saveToCameraPath(); void removeFromCameraPath(); void addToCameraPath(); void followCameraPath(); void followRobotPath(); private: void dataChanged(); void gotoFrame(unsigned int frame); bool followRobotTrajectory(); Ui::ViewerSettingsPanelCameraClass ui; unsigned int m_currentFrame; unsigned int m_numberFrames; bool m_robotTrajectoryAvailable; }; #endif // VIEWERSETTINGSPANELFLYMODE_H
2,782
29.922222
96
h
octomap
octomap-master/octovis/include/octovis/ViewerWidget.h
/* * This file is part of OctoMap - An Efficient Probabilistic 3D Mapping * Framework Based on Octrees * http://octomap.github.io * * Copyright (c) 2009-2014, K.M. Wurm and A. Hornung, University of Freiburg * All rights reserved. License for the viewer octovis: GNU GPL v2 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef VIEWERWIDGET_H_ #define VIEWERWIDGET_H_ #include "SceneObject.h" #include "SelectionBox.h" #include <octomap/octomap.h> #include <qglviewer.h> namespace octomap{ class ViewerWidget : public QGLViewer { Q_OBJECT public: ViewerWidget(QWidget* parent = NULL); void clearAll(); /** * Adds an object to the scene that can be drawn * * @param obj SceneObject to be added */ void addSceneObject(SceneObject* obj); /** * Removes a SceneObject from the list of drawable objects if * it has been added previously. Does nothing otherwise. * * @param obj SceneObject to be removed */ void removeSceneObject(SceneObject* obj); public slots: void enablePrintoutMode (bool enabled = true); void enableHeightColorMode (bool enabled = true); void enableSemanticColoring (bool enabled = true); void enableSelectionBox (bool enabled = true); void setCamPosition(double x, double y, double z, double lookX, double lookY, double lookZ); void setCamPose(const octomath::Pose6D& pose); virtual void setSceneBoundingBox(const qglviewer::Vec& min, const qglviewer::Vec& max); void deleteCameraPath(int id); void appendToCameraPath(int id, const octomath::Pose6D& pose); void appendCurrentToCameraPath(int id); void addCurrentToCameraPath(int id, int frame); void removeFromCameraPath(int id, int frame); void updateCameraPath(int id, int frame); void jumpToCamFrame(int id, int frame); void playCameraPath(int id, int start_frame); void stopCameraPath(int id); const SelectionBox& selectionBox() const { return m_selectionBox;} /** * Resets the 3D viewpoint to the initial value */ void resetView(); private slots: void cameraPathFinished(); void cameraPathInterpolated(); signals: void cameraPathStopped(int id); void cameraPathFrameChanged(int id, int current_camera_frame); void select(const QMouseEvent* e); protected: virtual void draw(); virtual void drawWithNames(); virtual void init(); /** * Overloaded from QGLViewer. Draws own axis and grid in scale, then calls QGLViewer::postDraw(). */ virtual void postDraw(); virtual void postSelection(const QPoint&); virtual QString helpString() const; qglviewer::Quaternion poseToQGLQuaternion(const octomath::Pose6D& pose); std::vector<SceneObject*> m_sceneObjects; SelectionBox m_selectionBox; bool m_printoutMode; bool m_heightColorMode; bool m_semantic_coloring; bool m_drawAxis; // actual state of axis (original overwritten) bool m_drawGrid; // actual state of grid (original overwritten) bool m_drawSelectionBox; double m_zMin; double m_zMax; int m_current_camera_path; int m_current_camera_frame; }; } #endif /* VIEWERWIDGET_H_ */
3,732
28.626984
99
h
octomap
octomap-master/octovis/src/extern/QGLViewer/config.h
/**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ /////////////////////////////////////////////////////////////////// // libQGLViewer configuration file // // Modify these settings according to your local configuration // /////////////////////////////////////////////////////////////////// #ifndef QGLVIEWER_CONFIG_H #define QGLVIEWER_CONFIG_H #define QGLVIEWER_VERSION 0x020603 // Needed for Qt < 4 (?) #ifndef QT_CLEAN_NAMESPACE # define QT_CLEAN_NAMESPACE #endif // Get QT_VERSION and other Qt flags #include <qglobal.h> #if QT_VERSION < 0x040000 Error : libQGLViewer requires a minimum Qt version of 4.0 #endif // Win 32 DLL export macros #ifdef Q_OS_WIN32 # ifndef M_PI # define M_PI 3.14159265358979323846 # endif # ifndef QGLVIEWER_STATIC # ifdef CREATE_QGLVIEWER_DLL # if QT_VERSION >= 0x040500 # define QGLVIEWER_EXPORT Q_DECL_EXPORT # else # define QGLVIEWER_EXPORT __declspec(dllexport) # endif # else # if QT_VERSION >= 0x040500 # define QGLVIEWER_EXPORT Q_DECL_IMPORT # else # define QGLVIEWER_EXPORT __declspec(dllimport) # endif # endif # endif # ifndef __MINGW32__ # pragma warning( disable : 4251 ) // DLL interface, needed with Visual 6 # pragma warning( disable : 4786 ) // identifier truncated to 255 in browser information (Visual 6). # endif #endif // Q_OS_WIN32 // For other architectures, this macro is empty #ifndef QGLVIEWER_EXPORT # define QGLVIEWER_EXPORT #endif // OpenGL includes - Included here and hence shared by all the files that need OpenGL headers. # include <QGLWidget> // GLU was removed from Qt in version 4.8 #ifdef Q_OS_MAC # include <OpenGL/glu.h> #else # include <GL/glu.h> #endif // Container classes interfaces changed a lot in Qt. // Compatibility patches are all grouped here. #include <QList> #include <QVector> // For deprecated methods // #define __WHERE__ "In file "<<__FILE__<<", line "<<__LINE__<<": " // #define orientationAxisAngle(x,y,z,a) { std::cout << __WHERE__ << "getOrientationAxisAngle()." << std::endl; exit(0); } // Patch for gcc version <= 2.95. Seems to no longer be needed with recent Qt versions. // Uncomment these lines if you have error message dealing with operator << on QStrings // #if defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ < 3) && (__GNUC_MINOR__ < 96) // # include <iostream> // # include <qstring.h> // std::ostream& operator<<(std::ostream& out, const QString& str) // { out << str.latin1(); return out; } // #endif #endif // QGLVIEWER_CONFIG_H
3,466
32.019048
122
h
octomap
octomap-master/octovis/src/extern/QGLViewer/constraint.h
/**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef QGLVIEWER_CONSTRAINT_H #define QGLVIEWER_CONSTRAINT_H #include "vec.h" #include "quaternion.h" namespace qglviewer { class Frame; class Camera; /*! \brief An interface class for Frame constraints. \class Constraint constraint.h QGLViewer/constraint.h This class defines the interface for the Constraints that can be applied to a Frame to limit its motion. Use Frame::setConstraint() to associate a Constraint to a Frame (default is a \c NULL Frame::constraint()). <h3>How does it work ?</h3> The Constraint acts as a filter on the translation and rotation Frame increments. constrainTranslation() and constrainRotation() should be overloaded to specify the constraint behavior: the desired displacement is given as a parameter that can optionally be modified. Here is how the Frame::translate() and Frame::rotate() methods use the Constraint: \code Frame::translate(Vec& T) { if (constraint()) constraint()->constrainTranslation(T, this); t += T; } Frame::rotate(Quaternion& Q) { if (constraint()) constraint()->constrainRotation(Q, this); q *= Q; } \endcode The default behavior of constrainTranslation() and constrainRotation() is empty (meaning no filtering). The Frame which uses the Constraint is passed as a parameter to the constrainTranslation() and constrainRotation() methods, so that they can have access to its current state (mainly Frame::position() and Frame::orientation()). It is not \c const for versatility reasons, but directly modifying it should be avoided. \attention Frame::setTranslation(), Frame::setRotation() and similar methods will actually indeed set the frame position and orientation, without taking the constraint into account. Use the \e WithConstraint versions of these methods to enforce the Constraint. <h3>Implemented Constraints</h3> Classical axial and plane Constraints are provided for convenience: see the LocalConstraint, WorldConstraint and CameraConstraint classes' documentations. Try the <a href="../examples/constrainedFrame.html">constrainedFrame</a> and <a href="../examples/constrainedCamera.html">constrainedCamera</a> examples for an illustration. <h3>Creating new Constraints</h3> The implementation of a new Constraint class simply consists in overloading the filtering methods: \code // This Constraint enforces that the Frame cannot have a negative z world coordinate. class myConstraint : public Constraint { public: virtual void constrainTranslation(Vec& t, Frame * const fr) { // Express t in the world coordinate system. const Vec tWorld = fr->inverseTransformOf(t); if (fr->position().z + tWorld.z < 0.0) // check the new fr z coordinate t.z = fr->transformOf(-fr->position().z); // t.z is clamped so that next z position is 0.0 } }; \endcode Note that the translation (resp. rotation) parameter passed to constrainTranslation() (resp. constrainRotation()) is expressed in the \e local Frame coordinate system. Here, we use the Frame::transformOf() and Frame::inverseTransformOf() method to convert it to and from the world coordinate system. Combined constraints can easily be achieved by creating a new class that applies the different constraint filters: \code myConstraint::constrainTranslation(Vec& v, Frame* const fr) { constraint1->constrainTranslation(v, fr); constraint2->constrainTranslation(v, fr); // and so on, with possible branches, tests, loops... } \endcode */ class QGLVIEWER_EXPORT Constraint { public: /*! Virtual destructor. Empty. */ virtual ~Constraint() {} /*! Filters the translation applied to the \p frame. This default implementation is empty (no filtering). Overload this method in your own Constraint class to define a new translation constraint. \p frame is the Frame to which is applied the translation. It is not defined \c const, but you should refrain from directly changing its value in the constraint. Use its Frame::position() and update the \p translation accordingly instead. \p translation is expressed in local frame coordinate system. Use Frame::inverseTransformOf() to express it in the world coordinate system if needed. */ virtual void constrainTranslation(Vec& translation, Frame* const frame) { Q_UNUSED(translation); Q_UNUSED(frame); } /*! Filters the rotation applied to the \p frame. This default implementation is empty (no filtering). Overload this method in your own Constraint class to define a new rotation constraint. See constrainTranslation() for details. Use Frame::inverseTransformOf() on the \p rotation Quaternion::axis() to express \p rotation in the world coordinate system if needed. */ virtual void constrainRotation(Quaternion& rotation, Frame* const frame) { Q_UNUSED(rotation); Q_UNUSED(frame); } }; /*! \brief An abstract class for Frame Constraints defined by an axis or a plane. \class AxisPlaneConstraint constraint.h QGLViewer/constraint.h AxisPlaneConstraint is an interface for (translation and/or rotation) Constraint that are defined by a direction. translationConstraintType() and rotationConstraintType() define how this direction should be interpreted: as an axis (AxisPlaneConstraint::AXIS) or as a plane normal (AxisPlaneConstraint::PLANE). See the Type() documentation for details. The three implementations of this class: LocalConstraint, WorldConstraint and CameraConstraint differ by the coordinate system in which this direction is expressed. Different implementations of this class are illustrated in the <a href="../examples/constrainedCamera.html">contrainedCamera</a> and <a href="../examples/constrainedFrame.html">constrainedFrame</a> examples. \attention When applied, the rotational Constraint may not intuitively follow the mouse displacement. A solution would be to directly measure the rotation angle in screen coordinates, but that would imply to know the QGLViewer::camera(), so that we can compute the projected coordinates of the rotation center (as is done with the QGLViewer::SCREEN_ROTATE binding). However, adding an extra pointer to the QGLViewer::camera() in all the AxisPlaneConstraint derived classes (which the user would have to update in a multi-viewer application) was judged as an overkill. */ class QGLVIEWER_EXPORT AxisPlaneConstraint : public Constraint { public: AxisPlaneConstraint(); /*! Virtual destructor. Empty. */ virtual ~AxisPlaneConstraint() {} /*! Type lists the different types of translation and rotation constraints that are available. It specifies the meaning of the constraint direction (see translationConstraintDirection() and rotationConstraintDirection()): as an axis direction (AxisPlaneConstraint::AXIS) or a plane normal (AxisPlaneConstraint::PLANE). AxisPlaneConstraint::FREE means no constraint while AxisPlaneConstraint::FORBIDDEN completely forbids the translation and/or the rotation. See translationConstraintType() and rotationConstraintType(). \attention The AxisPlaneConstraint::PLANE Type is not valid for rotational constraint. New derived classes can use their own extended enum for specific constraints: \code class MyAxisPlaneConstraint : public AxisPlaneConstraint { public: enum MyType { FREE, AXIS, PLANE, FORBIDDEN, CUSTOM }; virtual void constrainTranslation(Vec &translation, Frame *const frame) { // translationConstraintType() is simply an int. CUSTOM Type is handled seamlessly. switch (translationConstraintType()) { case MyAxisPlaneConstraint::FREE: ... break; case MyAxisPlaneConstraint::CUSTOM: ... break; } }; MyAxisPlaneConstraint* c = new MyAxisPlaneConstraint(); // Note the Type conversion c->setTranslationConstraintType(AxisPlaneConstraint::Type(MyAxisPlaneConstraint::CUSTOM)); }; \endcode */ enum Type { FREE, AXIS, PLANE, FORBIDDEN }; /*! @name Translation constraint */ //@{ /*! Overloading of Constraint::constrainTranslation(). Empty */ virtual void constrainTranslation(Vec& translation, Frame* const frame) { Q_UNUSED(translation); Q_UNUSED(frame); }; void setTranslationConstraint(Type type, const Vec& direction); /*! Sets the Type() of the translationConstraintType(). Default is AxisPlaneConstraint::FREE. */ void setTranslationConstraintType(Type type) { translationConstraintType_ = type; }; void setTranslationConstraintDirection(const Vec& direction); /*! Returns the translation constraint Type(). Depending on this value, the Frame will freely translate (AxisPlaneConstraint::FREE), will only be able to translate along an axis direction (AxisPlaneConstraint::AXIS), will be forced to stay into a plane (AxisPlaneConstraint::PLANE) or will not able to translate at all (AxisPlaneConstraint::FORBIDDEN). Use Frame::setPosition() to define the position of the constrained Frame before it gets constrained. */ Type translationConstraintType() const { return translationConstraintType_; }; /*! Returns the direction used by the translation constraint. It represents the axis direction (AxisPlaneConstraint::AXIS) or the plane normal (AxisPlaneConstraint::PLANE) depending on the translationConstraintType(). It is undefined for AxisPlaneConstraint::FREE or AxisPlaneConstraint::FORBIDDEN. The AxisPlaneConstraint derived classes express this direction in different coordinate system (camera for CameraConstraint, local for LocalConstraint, and world for WorldConstraint). This value can be modified with setTranslationConstraintDirection(). */ Vec translationConstraintDirection() const { return translationConstraintDir_; }; //@} /*! @name Rotation constraint */ //@{ /*! Overloading of Constraint::constrainRotation(). Empty. */ virtual void constrainRotation(Quaternion& rotation, Frame* const frame) { Q_UNUSED(rotation); Q_UNUSED(frame); }; void setRotationConstraint(Type type, const Vec& direction); void setRotationConstraintType(Type type); void setRotationConstraintDirection(const Vec& direction); /*! Returns the rotation constraint Type(). */ Type rotationConstraintType() const { return rotationConstraintType_; }; /*! Returns the axis direction used by the rotation constraint. This direction is defined only when rotationConstraintType() is AxisPlaneConstraint::AXIS. The AxisPlaneConstraint derived classes express this direction in different coordinate system (camera for CameraConstraint, local for LocalConstraint, and world for WorldConstraint). This value can be modified with setRotationConstraintDirection(). */ Vec rotationConstraintDirection() const { return rotationConstraintDir_; }; //@} private: // int and not Type to allow for overloading and new types definition. Type translationConstraintType_; Type rotationConstraintType_; Vec translationConstraintDir_; Vec rotationConstraintDir_; }; /*! \brief An AxisPlaneConstraint defined in the Frame local coordinate system. \class LocalConstraint constraint.h QGLViewer/constraint.h The translationConstraintDirection() and rotationConstraintDirection() are expressed in the Frame local coordinate system (see Frame::referenceFrame()). See the <a href="../examples/constrainedFrame.html">constrainedFrame</a> example for an illustration. */ class QGLVIEWER_EXPORT LocalConstraint : public AxisPlaneConstraint { public: /*! Virtual destructor. Empty. */ virtual ~LocalConstraint() {}; virtual void constrainTranslation(Vec& translation, Frame* const frame); virtual void constrainRotation (Quaternion& rotation, Frame* const frame); }; /*! \brief An AxisPlaneConstraint defined in the world coordinate system. \class WorldConstraint constraint.h QGLViewer/constraint.h The translationConstraintDirection() and rotationConstraintDirection() are expressed in world coordinate system. See the <a href="../examples/constrainedFrame.html">constrainedFrame</a> and <a href="../examples/multiView.html">multiView</a> examples for an illustration. */ class QGLVIEWER_EXPORT WorldConstraint : public AxisPlaneConstraint { public: /*! Virtual destructor. Empty. */ virtual ~WorldConstraint() {}; virtual void constrainTranslation(Vec& translation, Frame* const frame); virtual void constrainRotation (Quaternion& rotation, Frame* const frame); }; /*! \brief An AxisPlaneConstraint defined in the camera coordinate system. \class CameraConstraint constraint.h QGLViewer/constraint.h The translationConstraintDirection() and rotationConstraintDirection() are expressed in the associated camera() coordinate system. See the <a href="../examples/constrainedFrame.html">constrainedFrame</a> and <a href="../examples/constrainedCamera.html">constrainedCamera</a> examples for an illustration. */ class QGLVIEWER_EXPORT CameraConstraint : public AxisPlaneConstraint { public: explicit CameraConstraint(const Camera* const camera); /*! Virtual destructor. Empty. */ virtual ~CameraConstraint() {}; virtual void constrainTranslation(Vec& translation, Frame* const frame); virtual void constrainRotation (Quaternion& rotation, Frame* const frame); /*! Returns the associated Camera. Set using the CameraConstraint constructor. */ const Camera* camera() const { return camera_; }; private: const Camera* const camera_; }; } // namespace qglviewer #endif // QGLVIEWER_CONSTRAINT_H
14,304
41.19764
117
h
octomap
octomap-master/octovis/src/extern/QGLViewer/frame.h
/**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef QGLVIEWER_FRAME_H #define QGLVIEWER_FRAME_H #include <QObject> #include <QString> #include "constraint.h" // #include "GL/gl.h" is now included in config.h for ease of configuration namespace qglviewer { /*! \brief The Frame class represents a coordinate system, defined by a position and an orientation. \class Frame frame.h QGLViewer/frame.h A Frame is a 3D coordinate system, represented by a position() and an orientation(). The order of these transformations is important: the Frame is first translated \e and \e then rotated around the new translated origin. A Frame is useful to define the position and orientation of a 3D rigid object, using its matrix() method, as shown below: \code // Builds a Frame at position (0.5,0,0) and oriented such that its Y axis is along the (1,1,1) // direction. One could also have used setPosition() and setOrientation(). Frame fr(Vec(0.5,0,0), Quaternion(Vec(0,1,0), Vec(1,1,1))); glPushMatrix(); glMultMatrixd(fr.matrix()); // Draw your object here, in the local fr coordinate system. glPopMatrix(); \endcode Many functions are provided to transform a 3D point from one coordinate system (Frame) to an other: see coordinatesOf(), inverseCoordinatesOf(), coordinatesOfIn(), coordinatesOfFrom()... You may also want to transform a 3D vector (such as a normal), which corresponds to applying only the rotational part of the frame transformation: see transformOf() and inverseTransformOf(). See the <a href="../examples/frameTransform.html">frameTransform example</a> for an illustration. The translation() and the rotation() that are encapsulated in a Frame can also be used to represent a \e rigid \e transformation of space. Such a transformation can also be interpreted as a change of coordinate system, and the coordinate system conversion functions actually allow you to use a Frame as a rigid transformation. Use inverseCoordinatesOf() (resp. coordinatesOf()) to apply the transformation (resp. its inverse). Note the inversion. <h3>Hierarchy of Frames</h3> The position and the orientation of a Frame are actually defined with respect to a referenceFrame(). The default referenceFrame() is the world coordinate system (represented by a \c NULL referenceFrame()). If you setReferenceFrame() to a different Frame, you must then differentiate: \arg the \e local translation() and rotation(), defined with respect to the referenceFrame(), \arg the \e global position() and orientation(), always defined with respect to the world coordinate system. A Frame is actually defined by its translation() with respect to its referenceFrame(), and then by a rotation() of the coordinate system around the new translated origin. This terminology for \e local (translation() and rotation()) and \e global (position() and orientation()) definitions is used in all the methods' names and should be sufficient to prevent ambiguities. These notions are obviously identical when the referenceFrame() is \c NULL, i.e. when the Frame is defined in the world coordinate system (the one you are in at the beginning of the QGLViewer::draw() method, see the <a href="../introduction.html">introduction page</a>). Frames can hence easily be organized in a tree hierarchy, which root is the world coordinate system. A loop in the hierarchy would result in an inconsistent (multiple) Frame definition. settingAsReferenceFrameWillCreateALoop() checks this and prevents setReferenceFrame() from creating such a loop. This frame hierarchy is used in methods like coordinatesOfIn(), coordinatesOfFrom()... which allow coordinates (or vector) conversions from a Frame to any other one (including the world coordinate system). However, one must note that this hierarchical representation is internal to the Frame classes. When the Frames represent OpenGL coordinates system, one should map this hierarchical representation to the OpenGL GL_MODELVIEW matrix stack. See the matrix() documentation for details. <h3>Constraints</h3> An interesting feature of Frames is that their displacements can be constrained. When a Constraint is attached to a Frame, it filters the input of translate() and rotate(), and only the resulting filtered motion is applied to the Frame. The default constraint() is \c NULL resulting in no filtering. Use setConstraint() to attach a Constraint to a frame. Constraints are especially usefull for the ManipulatedFrame instances, in order to forbid some mouse motions. See the <a href="../examples/constrainedFrame.html">constrainedFrame</a>, <a href="../examples/constrainedCamera.html">constrainedCamera</a> and <a href="../examples/luxo.html">luxo</a> examples for an illustration. Classical constraints are provided for convenience (see LocalConstraint, WorldConstraint and CameraConstraint) and new constraints can very easily be implemented. <h3>Derived classes</h3> The ManipulatedFrame class inherits Frame and implements a mouse motion convertion, so that a Frame (and hence an object) can be manipulated in the scene with the mouse. \nosubgrouping */ class QGLVIEWER_EXPORT Frame : public QObject { Q_OBJECT public: Frame(); /*! Virtual destructor. Empty. */ virtual ~Frame() {} Frame(const Frame& frame); Frame& operator=(const Frame& frame); Q_SIGNALS: /*! This signal is emitted whenever the position() or the orientation() of the Frame is modified. Connect this signal to any object that must be notified: \code QObject::connect(myFrame, SIGNAL(modified()), myObject, SLOT(update())); \endcode Use the QGLViewer::QGLViewerPool() to connect the signal to all the viewers. \note If your Frame is part of a Frame hierarchy (see referenceFrame()), a modification of one of the parents of this Frame will \e not emit this signal. Use code like this to change this behavior (you can do this recursively for all the referenceFrame() until the \c NULL world root frame is encountered): \code // Emits the Frame modified() signal when its referenceFrame() is modified(). connect(myFrame->referenceFrame(), SIGNAL(modified()), myFrame, SIGNAL(modified())); \endcode \attention Connecting this signal to a QGLWidget::update() slot (or a method that calls it) will prevent you from modifying the Frame \e inside your QGLViewer::draw() method as it would result in an infinite loop. However, QGLViewer::draw() should not modify the scene. \note Note that this signal might be emitted even if the Frame is not actually modified, for instance after a translate(Vec(0,0,0)) or a setPosition(position()). */ void modified(); /*! This signal is emitted when the Frame is interpolated by a KeyFrameInterpolator. See the KeyFrameInterpolator documentation for details. If a KeyFrameInterpolator is used to successively interpolate several Frames in your scene, connect the KeyFrameInterpolator::interpolated() signal instead (identical, but independent of the interpolated Frame). */ void interpolated(); public: /*! @name World coordinates position and orientation */ //@{ Frame(const Vec& position, const Quaternion& orientation); void setPosition(const Vec& position); void setPosition(qreal x, qreal y, qreal z); void setPositionWithConstraint(Vec& position); void setOrientation(const Quaternion& orientation); void setOrientation(qreal q0, qreal q1, qreal q2, qreal q3); void setOrientationWithConstraint(Quaternion& orientation); void setPositionAndOrientation(const Vec& position, const Quaternion& orientation); void setPositionAndOrientationWithConstraint(Vec& position, Quaternion& orientation); Vec position() const; Quaternion orientation() const; void getPosition(qreal& x, qreal& y, qreal& z) const; void getOrientation(qreal& q0, qreal& q1, qreal& q2, qreal& q3) const; //@} public: /*! @name Local translation and rotation w/r reference Frame */ //@{ /*! Sets the translation() of the frame, locally defined with respect to the referenceFrame(). Emits the modified() signal. Use setPosition() to define the world coordinates position(). Use setTranslationWithConstraint() to take into account the potential constraint() of the Frame. */ void setTranslation(const Vec& translation) { t_ = translation; Q_EMIT modified(); } void setTranslation(qreal x, qreal y, qreal z); void setTranslationWithConstraint(Vec& translation); /*! Set the current rotation Quaternion. See rotation() and the different Quaternion constructors. Emits the modified() signal. See also setTranslation() and setRotationWithConstraint(). */ /*! Sets the rotation() of the Frame, locally defined with respect to the referenceFrame(). Emits the modified() signal. Use setOrientation() to define the world coordinates orientation(). The potential constraint() of the Frame is not taken into account, use setRotationWithConstraint() instead. */ void setRotation(const Quaternion& rotation) { q_ = rotation; Q_EMIT modified(); } void setRotation(qreal q0, qreal q1, qreal q2, qreal q3); void setRotationWithConstraint(Quaternion& rotation); void setTranslationAndRotation(const Vec& translation, const Quaternion& rotation); void setTranslationAndRotationWithConstraint(Vec& translation, Quaternion& rotation); /*! Returns the Frame translation, defined with respect to the referenceFrame(). Use position() to get the result in the world coordinates. These two values are identical when the referenceFrame() is \c NULL (default). See also setTranslation() and setTranslationWithConstraint(). */ Vec translation() const { return t_; } /*! Returns the Frame rotation, defined with respect to the referenceFrame(). Use orientation() to get the result in the world coordinates. These two values are identical when the referenceFrame() is \c NULL (default). See also setRotation() and setRotationWithConstraint(). */ /*! Returns the current Quaternion orientation. See setRotation(). */ Quaternion rotation() const { return q_; } void getTranslation(qreal& x, qreal& y, qreal& z) const; void getRotation(qreal& q0, qreal& q1, qreal& q2, qreal& q3) const; //@} public: /*! @name Frame hierarchy */ //@{ /*! Returns the reference Frame, in which coordinates system the Frame is defined. The translation() and rotation() of the Frame are defined with respect to the referenceFrame() coordinate system. A \c NULL referenceFrame() (default value) means that the Frame is defined in the world coordinate system. Use position() and orientation() to recursively convert values along the referenceFrame() chain and to get values expressed in the world coordinate system. The values match when the referenceFrame() is \c NULL. Use setReferenceFrame() to set this value and create a Frame hierarchy. Convenient functions allow you to convert 3D coordinates from one Frame to an other: see coordinatesOf(), localCoordinatesOf(), coordinatesOfIn() and their inverse functions. Vectors can also be converted using transformOf(), transformOfIn, localTransformOf() and their inverse functions. */ const Frame* referenceFrame() const { return referenceFrame_; } void setReferenceFrame(const Frame* const refFrame); bool settingAsReferenceFrameWillCreateALoop(const Frame* const frame); //@} /*! @name Frame modification */ //@{ void translate(Vec& t); void translate(const Vec& t); // Some compilers complain about "overloading cannot distinguish from previous declaration" // Simply comment out the following method and its associated implementation void translate(qreal x, qreal y, qreal z); void translate(qreal& x, qreal& y, qreal& z); void rotate(Quaternion& q); void rotate(const Quaternion& q); // Some compilers complain about "overloading cannot distinguish from previous declaration" // Simply comment out the following method and its associated implementation void rotate(qreal q0, qreal q1, qreal q2, qreal q3); void rotate(qreal& q0, qreal& q1, qreal& q2, qreal& q3); void rotateAroundPoint(Quaternion& rotation, const Vec& point); void rotateAroundPoint(const Quaternion& rotation, const Vec& point); void alignWithFrame(const Frame* const frame, bool move=false, qreal threshold=0.0); void projectOnLine(const Vec& origin, const Vec& direction); //@} /*! @name Coordinate system transformation of 3D coordinates */ //@{ Vec coordinatesOf(const Vec& src) const; Vec inverseCoordinatesOf(const Vec& src) const; Vec localCoordinatesOf(const Vec& src) const; Vec localInverseCoordinatesOf(const Vec& src) const; Vec coordinatesOfIn(const Vec& src, const Frame* const in) const; Vec coordinatesOfFrom(const Vec& src, const Frame* const from) const; void getCoordinatesOf(const qreal src[3], qreal res[3]) const; void getInverseCoordinatesOf(const qreal src[3], qreal res[3]) const; void getLocalCoordinatesOf(const qreal src[3], qreal res[3]) const; void getLocalInverseCoordinatesOf(const qreal src[3], qreal res[3]) const; void getCoordinatesOfIn(const qreal src[3], qreal res[3], const Frame* const in) const; void getCoordinatesOfFrom(const qreal src[3], qreal res[3], const Frame* const from) const; //@} /*! @name Coordinate system transformation of vectors */ // A frame is as a new coordinate system, defined with respect to a reference frame (the world // coordinate system by default, see the "Composition of frame" section). // The transformOf() (resp. inverseTransformOf()) functions transform a 3D vector from (resp. // to) the world coordinates system. This section defines the 3D vector transformation // functions. See the Coordinate system transformation of 3D points above for the transformation // of 3D points. The difference between the two sets of functions is simple: for vectors, only // the rotational part of the transformations is taken into account, while translation is also // considered for 3D points. // The length of the resulting transformed vector is identical to the one of the source vector // for all the described functions. // When local is prepended to the names of the functions, the functions simply transform from // (and to) the reference frame. // When In (resp. From) is appended to the names, the functions transform from (resp. To) the // frame that is given as an argument. The frame does not need to be in the same branch or the // hierarchical tree, and can be \c NULL (the world coordinates system). // Combining any of these functions with its inverse (in any order) leads to the identity. //@{ Vec transformOf(const Vec& src) const; Vec inverseTransformOf(const Vec& src) const; Vec localTransformOf(const Vec& src) const; Vec localInverseTransformOf(const Vec& src) const; Vec transformOfIn(const Vec& src, const Frame* const in) const; Vec transformOfFrom(const Vec& src, const Frame* const from) const; void getTransformOf(const qreal src[3], qreal res[3]) const; void getInverseTransformOf(const qreal src[3], qreal res[3]) const; void getLocalTransformOf(const qreal src[3], qreal res[3]) const; void getLocalInverseTransformOf(const qreal src[3], qreal res[3]) const; void getTransformOfIn(const qreal src[3], qreal res[3], const Frame* const in) const; void getTransformOfFrom(const qreal src[3], qreal res[3], const Frame* const from) const; //@} /*! @name Constraint on the displacement */ //@{ /*! Returns the current constraint applied to the Frame. A \c NULL value (default) means that no Constraint is used to filter Frame translation and rotation. See the Constraint class documentation for details. You may have to use a \c dynamic_cast to convert the result to a Constraint derived class. */ Constraint* constraint() const { return constraint_; } /*! Sets the constraint() attached to the Frame. A \c NULL value means no constraint. The previous constraint() should be deleted by the calling method if needed. */ void setConstraint(Constraint* const constraint) { constraint_ = constraint; } //@} /*! @name Associated matrices */ //@{ public: const GLdouble* matrix() const; void getMatrix(GLdouble m[4][4]) const; void getMatrix(GLdouble m[16]) const; const GLdouble* worldMatrix() const; void getWorldMatrix(GLdouble m[4][4]) const; void getWorldMatrix(GLdouble m[16]) const; void setFromMatrix(const GLdouble m[4][4]); void setFromMatrix(const GLdouble m[16]); //@} /*! @name Inversion of the transformation */ //@{ Frame inverse() const; /*! Returns the inverse() of the Frame world transformation. The orientation() of the new Frame is the Quaternion::inverse() of the original orientation. Its position() is the negated and inverse rotated image of the original position. The result Frame has a \c NULL referenceFrame() and a \c NULL constraint(). Use inverse() for a local (i.e. with respect to referenceFrame()) transformation inverse. */ Frame worldInverse() const { return Frame(-(orientation().inverseRotate(position())), orientation().inverse()); } //@} /*! @name XML representation */ //@{ public: virtual QDomElement domElement(const QString& name, QDomDocument& document) const; public Q_SLOTS: virtual void initFromDOMElement(const QDomElement& element); //@} private: // P o s i t i o n a n d o r i e n t a t i o n Vec t_; Quaternion q_; // C o n s t r a i n t s Constraint* constraint_; // F r a m e c o m p o s i t i o n const Frame* referenceFrame_; }; } // namespace qglviewer #endif // QGLVIEWER_FRAME_H
18,425
43.293269
114
h
octomap
octomap-master/octovis/src/extern/QGLViewer/keyFrameInterpolator.h
/**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef QGLVIEWER_KEY_FRAME_INTERPOLATOR_H #define QGLVIEWER_KEY_FRAME_INTERPOLATOR_H #include <QObject> #include <QTimer> #include "quaternion.h" // Not actually needed, but some bad compilers (Microsoft VS6) complain. #include "frame.h" // If you compiler complains about incomplete type, uncomment the next line // #include "frame.h" // and comment "class Frame;" 3 lines below namespace qglviewer { class Camera; class Frame; /*! \brief A keyFrame Catmull-Rom Frame interpolator. \class KeyFrameInterpolator keyFrameInterpolator.h QGLViewer/keyFrameInterpolator.h A KeyFrameInterpolator holds keyFrames (that define a path) and a pointer to a Frame of your application (which will be interpolated). When the user startInterpolation(), the KeyFrameInterpolator regularly updates the frame() position and orientation along the path. Here is a typical utilization example (see also the <a href="../examples/keyFrames.html">keyFrames example</a>): \code init() { // The KeyFrameInterpolator kfi is given the Frame that it will drive over time. kfi = new KeyFrameInterpolator( new Frame() ); kfi->addKeyFrame( Frame( Vec(1,0,0), Quaternion() ) ); kfi->addKeyFrame( new Frame( Vec(2,1,0), Quaternion() ) ); // ...and so on for all the keyFrames. // Ask for a display update after each update of the KeyFrameInterpolator connect(kfi, SIGNAL(interpolated()), SLOT(update())); kfi->startInterpolation(); } draw() { glPushMatrix(); glMultMatrixd( kfi->frame()->matrix() ); // Draw your object here. Its position and orientation are interpolated. glPopMatrix(); } \endcode The keyFrames are defined by a Frame and a time, expressed in seconds. The Frame can be provided as a const reference or as a pointer to a Frame (see the addKeyFrame() methods). In the latter case, the path will automatically be updated when the Frame is modified (using the Frame::modified() signal). The time has to be monotonously increasing over keyFrames. When interpolationSpeed() equals 1.0 (default value), these times correspond to actual user's seconds during interpolation (provided that your main loop is fast enough). The interpolation is then real-time: the keyFrames will be reached at their keyFrameTime(). <h3>Interpolation details</h3> When the user startInterpolation(), a timer is started which will update the frame()'s position and orientation every interpolationPeriod() milliseconds. This update increases the interpolationTime() by interpolationPeriod() * interpolationSpeed() milliseconds. Note that this mechanism ensures that the number of interpolation steps is constant and equal to the total path duration() divided by the interpolationPeriod() * interpolationSpeed(). This is especially useful for benchmarking or movie creation (constant number of snapshots). During the interpolation, the KeyFrameInterpolator emits an interpolated() signal, which will usually be connected to the QGLViewer::update() slot. The interpolation is stopped when interpolationTime() is greater than the lastTime() (unless loopInterpolation() is \c true) and the endReached() signal is then emitted. Note that a Camera has Camera::keyFrameInterpolator(), that can be used to drive the Camera along a path, or to restore a saved position (a path made of a single keyFrame). Press Alt+Fx to define a new keyFrame for path x. Pressing Fx plays/pauses path interpolation. See QGLViewer::pathKey() and the <a href="../keyboard.html">keyboard page</a> for details. \attention If a Constraint is attached to the frame() (see Frame::constraint()), it should be deactivated before interpolationIsStarted(), otherwise the interpolated motion (computed as if there was no constraint) will probably be erroneous. <h3>Retrieving interpolated values</h3> This code defines a KeyFrameInterpolator, and displays the positions that will be followed by the frame() along the path: \code KeyFrameInterpolator kfi( new Frame() ); // calls to kfi.addKeyFrame() to define the path. const qreal deltaTime = 0.04; // output a position every deltaTime seconds for (qreal time=kfi.firstTime(); time<=kfi.lastTime(); time += deltaTime) { kfi.interpolateAtTime(time); cout << "t=" << time << "\tpos=" << kfi.frame()->position() << endl; } \endcode You may want to temporally disconnect the \c kfi interpolated() signal from the QGLViewer::update() slot before calling this code. \nosubgrouping */ class QGLVIEWER_EXPORT KeyFrameInterpolator : public QObject { // todo closedPath, insertKeyFrames, deleteKeyFrame, replaceKeyFrame Q_OBJECT public: KeyFrameInterpolator(Frame* fr=NULL); virtual ~KeyFrameInterpolator(); Q_SIGNALS: /*! This signal is emitted whenever the frame() state is interpolated. The emission of this signal triggers the synchronous emission of the frame() Frame::interpolated() signal, which may also be useful. This signal should especially be connected to your QGLViewer::update() slot, so that the display is updated after every update of the KeyFrameInterpolator frame(): \code connect(myKeyFrameInterpolator, SIGNAL(interpolated()), SLOT(update())); \endcode Use the QGLViewer::QGLViewerPool() to connect the signal to all the viewers. Note that the QGLViewer::camera() Camera::keyFrameInterpolator() created using QGLViewer::pathKey() have their interpolated() signals automatically connected to the QGLViewer::update() slot. */ void interpolated(); /*! This signal is emitted when the interpolation reaches the first (when interpolationSpeed() is negative) or the last keyFrame. When loopInterpolation() is \c true, interpolationTime() is reset and the interpolation continues. It otherwise stops. */ void endReached(); /*! @name Path creation */ //@{ public Q_SLOTS: void addKeyFrame(const Frame& frame); void addKeyFrame(const Frame& frame, qreal time); void addKeyFrame(const Frame* const frame); void addKeyFrame(const Frame* const frame, qreal time); void deletePath(); //@} /*! @name Associated Frame */ //@{ public: /*! Returns the associated Frame and that is interpolated by the KeyFrameInterpolator. When interpolationIsStarted(), this Frame's position and orientation will regularly be updated by a timer, so that they follow the KeyFrameInterpolator path. Set using setFrame() or with the KeyFrameInterpolator constructor. */ Frame* frame() const { return frame_; } public Q_SLOTS: void setFrame(Frame* const frame); //@} /*! @name Path parameters */ //@{ public: Frame keyFrame(int index) const; qreal keyFrameTime(int index) const; /*! Returns the number of keyFrames used by the interpolation. Use addKeyFrame() to add new keyFrames. */ int numberOfKeyFrames() const { return keyFrame_.count(); } qreal duration() const; qreal firstTime() const; qreal lastTime() const; //@} /*! @name Interpolation parameters */ //@{ public: /*! Returns the current interpolation time (in seconds) along the KeyFrameInterpolator path. This time is regularly updated when interpolationIsStarted(). Can be set directly with setInterpolationTime() or interpolateAtTime(). */ qreal interpolationTime() const { return interpolationTime_; } /*! Returns the current interpolation speed. Default value is 1.0, which means keyFrameTime() will be matched during the interpolation (provided that your main loop is fast enough). A negative value will result in a reverse interpolation of the keyFrames. See also interpolationPeriod(). */ qreal interpolationSpeed() const { return interpolationSpeed_; } /*! Returns the current interpolation period, expressed in milliseconds. The update of the frame() state will be done by a timer at this period when interpolationIsStarted(). This period (multiplied by interpolationSpeed()) is added to the interpolationTime() at each update, and the frame() state is modified accordingly (see interpolateAtTime()). Default value is 40 milliseconds. */ int interpolationPeriod() const { return period_; } /*! Returns \c true when the interpolation is played in an infinite loop. When \c false (default), the interpolation stops when interpolationTime() reaches firstTime() (with negative interpolationSpeed()) or lastTime(). interpolationTime() is otherwise reset to firstTime() (+ interpolationTime() - lastTime()) (and inversely for negative interpolationSpeed()) and interpolation continues. In both cases, the endReached() signal is emitted. */ bool loopInterpolation() const { return loopInterpolation_; } #ifndef DOXYGEN /*! Whether or not (default) the path defined by the keyFrames is a closed loop. When \c true, the last and the first KeyFrame are linked by a new spline segment. Use setLoopInterpolation() to create a continuous animation over the entire path. \attention The closed path feature is not yet implemented. */ bool closedPath() const { return closedPath_; } #endif public Q_SLOTS: /*! Sets the interpolationTime(). \attention The frame() state is not affected by this method. Use this function to define the starting time of a future interpolation (see startInterpolation()). Use interpolateAtTime() to actually interpolate at a given time. */ void setInterpolationTime(qreal time) { interpolationTime_ = time; } /*! Sets the interpolationSpeed(). Negative or null values are allowed. */ void setInterpolationSpeed(qreal speed) { interpolationSpeed_ = speed; } /*! Sets the interpolationPeriod(). */ void setInterpolationPeriod(int period) { period_ = period; } /*! Sets the loopInterpolation() value. */ void setLoopInterpolation(bool loop=true) { loopInterpolation_ = loop; } #ifndef DOXYGEN /*! Sets the closedPath() value. \attention The closed path feature is not yet implemented. */ void setClosedPath(bool closed=true) { closedPath_ = closed; } #endif //@} /*! @name Interpolation */ //@{ public: /*! Returns \c true when the interpolation is being performed. Use startInterpolation(), stopInterpolation() or toggleInterpolation() to modify this state. */ bool interpolationIsStarted() const { return interpolationStarted_; } public Q_SLOTS: void startInterpolation(int period = -1); void stopInterpolation(); void resetInterpolation(); /*! Calls startInterpolation() or stopInterpolation(), depending on interpolationIsStarted(). */ void toggleInterpolation() { if (interpolationIsStarted()) stopInterpolation(); else startInterpolation(); } virtual void interpolateAtTime(qreal time); //@} /*! @name Path drawing */ //@{ public: virtual void drawPath(int mask=1, int nbFrames=6, qreal scale=1.0); //@} /*! @name XML representation */ //@{ public: virtual QDomElement domElement(const QString& name, QDomDocument& document) const; virtual void initFromDOMElement(const QDomElement& element); //@} private Q_SLOTS: virtual void update(); virtual void invalidateValues() { valuesAreValid_ = false; pathIsValid_ = false; splineCacheIsValid_ = false; } private: // Copy constructor and opertor= are declared private and undefined // Prevents everyone from trying to use them // KeyFrameInterpolator(const KeyFrameInterpolator& kfi); // KeyFrameInterpolator& operator=(const KeyFrameInterpolator& kfi); void updateCurrentKeyFrameForTime(qreal time); void updateModifiedFrameValues(); void updateSplineCache(); #ifndef DOXYGEN // Internal private KeyFrame representation class KeyFrame { public: KeyFrame(const Frame& fr, qreal t); KeyFrame(const Frame* fr, qreal t); Vec position() const { return p_; } Quaternion orientation() const { return q_; } Vec tgP() const { return tgP_; } Quaternion tgQ() const { return tgQ_; } qreal time() const { return time_; } const Frame* frame() const { return frame_; } void updateValuesFromPointer(); void flipOrientationIfNeeded(const Quaternion& prev); void computeTangent(const KeyFrame* const prev, const KeyFrame* const next); private: Vec p_, tgP_; Quaternion q_, tgQ_; qreal time_; const Frame* const frame_; }; #endif // K e y F r a m e s mutable QList<KeyFrame*> keyFrame_; QMutableListIterator<KeyFrame*>* currentFrame_[4]; QList<Frame> path_; // A s s o c i a t e d f r a m e Frame* frame_; // R h y t h m QTimer timer_; int period_; qreal interpolationTime_; qreal interpolationSpeed_; bool interpolationStarted_; // M i s c bool closedPath_; bool loopInterpolation_; // C a c h e d v a l u e s a n d f l a g s bool pathIsValid_; bool valuesAreValid_; bool currentFrameValid_; bool splineCacheIsValid_; Vec v1, v2; }; } // namespace qglviewer #endif // QGLVIEWER_KEY_FRAME_INTERPOLATOR_H
13,603
37
112
h
octomap
octomap-master/octovis/src/extern/QGLViewer/mouseGrabber.h
/**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef QGLVIEWER_MOUSE_GRABBER_H #define QGLVIEWER_MOUSE_GRABBER_H #include "config.h" #include <QEvent> class QGLViewer; namespace qglviewer { class Camera; /*! \brief Abstract class for objects that grab mouse focus in a QGLViewer. \class MouseGrabber mouseGrabber.h QGLViewer/mouseGrabber.h MouseGrabber are objects which react to the mouse cursor, usually when it hovers over them. This abstract class only provides an interface for all these objects: their actual behavior has to be defined in a derived class. <h3>How does it work ?</h3> All the created MouseGrabber are grouped in a MouseGrabberPool(). The QGLViewers parse this pool, calling all the MouseGrabbers' checkIfGrabsMouse() methods that setGrabsMouse() if desired. When a MouseGrabber grabsMouse(), it becomes the QGLViewer::mouseGrabber(). All the mouse events (mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), mouseDoubleClickEvent() and wheelEvent()) are then transmitted to the QGLViewer::mouseGrabber() instead of being normally processed. This continues while grabsMouse() (updated using checkIfGrabsMouse()) returns \c true. If you want to (temporarily) disable a specific MouseGrabbers, you can remove it from this pool using removeFromMouseGrabberPool(). You can also disable a MouseGrabber in a specific QGLViewer using QGLViewer::setMouseGrabberIsEnabled(). <h3>Implementation details</h3> In order to make MouseGrabber react to mouse events, mouse tracking has to be activated in the QGLViewer which wants to use MouseGrabbers: \code init() { setMouseTracking(true); } \endcode Call \c QGLWidget::hasMouseTracking() to get the current state of this flag. The \p camera parameter of the different mouse event methods is a pointer to the QGLViewer::camera() of the QGLViewer that uses the MouseGrabber. It can be used to compute 2D to 3D coordinates conversion using Camera::projectedCoordinatesOf() and Camera::unprojectedCoordinatesOf(). Very complex behaviors can be implemented using this framework: auto-selected objects (no need to press a key to use them), automatic drop-down menus, 3D GUI, spinners using the wheelEvent(), and whatever your imagination creates. See the <a href="../examples/mouseGrabber.html">mouseGrabber example</a> for an illustration. Note that ManipulatedFrame are MouseGrabber: see the <a href="../examples/keyFrames.html">keyFrame example</a> for an illustration. Every created ManipulatedFrame is hence present in the MouseGrabberPool() (note however that ManipulatedCameraFrame are not inserted). <h3>Example</h3> Here is for instance a draft version of a MovableObject class. Instances of these class can freely be moved on screen using the mouse, as movable post-it-like notes: \code class MovableObject : public MouseGrabber { public: MovableObject() : pos(0,0), moved(false) {} void checkIfGrabsMouse(int x, int y, const qglviewer::Camera* const) { // MovableObject is active in a region of 5 pixels around its pos. // May depend on the actual shape of the object. Customize as desired. // Once clicked (moved = true), it keeps grabbing mouse until button is released. setGrabsMouse( moved || ((pos-QPoint(x,y)).manhattanLength() < 5) ); } void mousePressEvent( QMouseEvent* const e, Camera* const) { prevPos = e->pos(); moved = true; } void mouseMoveEvent(QMouseEvent* const e, const Camera* const) { if (moved) { // Add position delta to current pos pos += e->pos() - prevPos; prevPos = e->pos(); } } void mouseReleaseEvent(QMouseEvent* const, Camera* const) { moved = false; } void draw() { // The object is drawn centered on its pos, with different possible aspects: if (grabsMouse()) if (moved) // Object being moved, maybe a transparent display else // Object ready to be moved, maybe a highlighted visual feedback else // Normal display } private: QPoint pos, prevPos; bool moved; }; \endcode Note that the different event callback methods are called only once the MouseGrabber grabsMouse(). \nosubgrouping */ class QGLVIEWER_EXPORT MouseGrabber { #ifndef DOXYGEN friend class ::QGLViewer; #endif public: MouseGrabber(); /*! Virtual destructor. Removes the MouseGrabber from the MouseGrabberPool(). */ virtual ~MouseGrabber() { MouseGrabber::MouseGrabberPool_.removeAll(this); } /*! @name Mouse grabbing detection */ //@{ public: /*! Pure virtual method, called by the QGLViewers before they test if the MouseGrabber grabsMouse(). Should setGrabsMouse() according to the mouse position. This is the core method of the MouseGrabber. It has to be overloaded in your derived class. Its goal is to update the grabsMouse() flag according to the mouse and MouseGrabber current positions, using setGrabsMouse(). grabsMouse() is usually set to \c true when the mouse cursor is close enough to the MouseGrabber position. It should also be set to \c false when the mouse cursor leaves this region in order to release the mouse focus. \p x and \p y are the mouse cursor coordinates (Qt coordinate system: (0,0) corresponds to the upper left corner). A typical implementation will look like: \code // (posX,posY) is the position of the MouseGrabber on screen. // Here, distance to mouse must be less than 10 pixels to activate the MouseGrabber. setGrabsMouse( sqrt((x-posX)*(x-posX) + (y-posY)*(y-posY)) < 10); \endcode If the MouseGrabber position is defined in 3D, use the \p camera parameter, corresponding to the calling QGLViewer Camera. Project on screen and then compare the projected coordinates: \code Vec proj = camera->projectedCoordinatesOf(myMouseGrabber->frame()->position()); setGrabsMouse((fabs(x-proj.x) < 5) && (fabs(y-proj.y) < 2)); // Rectangular region \endcode See examples in the <a href="#_details">detailed description</a> section and in the <a href="../examples/mouseGrabber.html">mouseGrabber example</a>. */ virtual void checkIfGrabsMouse(int x, int y, const Camera* const camera) = 0; /*! Returns \c true when the MouseGrabber grabs the QGLViewer's mouse events. This flag is set with setGrabsMouse() by the checkIfGrabsMouse() method. */ bool grabsMouse() const { return grabsMouse_; } protected: /*! Sets the grabsMouse() flag. Normally used by checkIfGrabsMouse(). */ void setGrabsMouse(bool grabs) { grabsMouse_ = grabs; } //@} /*! @name MouseGrabber pool */ //@{ public: /*! Returns a list containing pointers to all the active MouseGrabbers. Used by the QGLViewer to parse all the MouseGrabbers and to check if any of them grabsMouse() using checkIfGrabsMouse(). You should not have to directly use this list. Use removeFromMouseGrabberPool() and addInMouseGrabberPool() to modify this list. \attention This method returns a \c QPtrList<MouseGrabber> with Qt 3 and a \c QList<MouseGrabber> with Qt 2. */ static const QList<MouseGrabber*>& MouseGrabberPool() { return MouseGrabber::MouseGrabberPool_; } /*! Returns \c true if the MouseGrabber is currently in the MouseGrabberPool() list. Default value is \c true. When set to \c false using removeFromMouseGrabberPool(), the QGLViewers no longer checkIfGrabsMouse() on this MouseGrabber. Use addInMouseGrabberPool() to insert it back. */ bool isInMouseGrabberPool() const { return MouseGrabber::MouseGrabberPool_.contains(const_cast<MouseGrabber*>(this)); } void addInMouseGrabberPool(); void removeFromMouseGrabberPool(); void clearMouseGrabberPool(bool autoDelete=false); //@} /*! @name Mouse event handlers */ //@{ protected: /*! Callback method called when the MouseGrabber grabsMouse() and a mouse button is pressed. The MouseGrabber will typically start an action or change its state when a mouse button is pressed. mouseMoveEvent() (called at each mouse displacement) will then update the MouseGrabber accordingly and mouseReleaseEvent() (called when the mouse button is released) will terminate this action. Use the \p event QMouseEvent::state() and QMouseEvent::button() to test the keyboard and button state and possibly change the MouseGrabber behavior accordingly. See the <a href="#_details">detailed description section</a> and the <a href="../examples/mouseGrabber.html">mouseGrabber example</a> for examples. See the \c QGLWidget::mousePressEvent() and the \c QMouseEvent documentations for details. */ virtual void mousePressEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event); Q_UNUSED(camera); } /*! Callback method called when the MouseGrabber grabsMouse() and a mouse button is double clicked. See the \c QGLWidget::mouseDoubleClickEvent() and the \c QMouseEvent documentations for details. */ virtual void mouseDoubleClickEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event); Q_UNUSED(camera); } /*! Mouse release event callback method. See mousePressEvent(). */ virtual void mouseReleaseEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event); Q_UNUSED(camera); } /*! Callback method called when the MouseGrabber grabsMouse() and the mouse is moved while a button is pressed. This method will typically update the state of the MouseGrabber from the mouse displacement. See the mousePressEvent() documentation for details. */ virtual void mouseMoveEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event); Q_UNUSED(camera); } /*! Callback method called when the MouseGrabber grabsMouse() and the mouse wheel is used. See the \c QGLWidget::wheelEvent() and the \c QWheelEvent documentations for details. */ virtual void wheelEvent(QWheelEvent* const event, Camera* const camera) { Q_UNUSED(event); Q_UNUSED(camera); } //@} private: // Copy constructor and opertor= are declared private and undefined // Prevents everyone from trying to use them MouseGrabber(const MouseGrabber&); MouseGrabber& operator=(const MouseGrabber&); bool grabsMouse_; // Q G L V i e w e r p o o l static QList<MouseGrabber*> MouseGrabberPool_; }; } // namespace qglviewer #endif // QGLVIEWER_MOUSE_GRABBER_H
11,050
40.701887
122
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/AxisAlignedBox.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _VRENDER_AXISALIGNEDBOX_H #define _VRENDER_AXISALIGNEDBOX_H namespace vrender { class Vector2; class Vector3; template<class T> class AxisAlignedBox { public: AxisAlignedBox() ; AxisAlignedBox(const T& v) ; AxisAlignedBox(const T& v,const T& w) ; const T& mini() const { return _min ; } const T& maxi() const { return _max ; } void include(const T& v) ; void include(const AxisAlignedBox<T>& b) ; private: T _min ; T _max ; }; typedef AxisAlignedBox< Vector2 > AxisAlignedBox_xy ; typedef AxisAlignedBox< Vector3 > AxisAlignedBox_xyz ; template<class T> AxisAlignedBox<T>::AxisAlignedBox() : _min(T::inf), _max(-T::inf) { } template<class T> AxisAlignedBox<T>::AxisAlignedBox(const T& v) : _min(v), _max(v) { } template<class T> AxisAlignedBox<T>::AxisAlignedBox(const T& v,const T& w) : _min(v), _max(v) { include(w) ; } template<class T> void AxisAlignedBox<T>::include(const T& v) { _min = T::mini(_min,v) ; _max = T::maxi(_max,v) ; } template<class T> void AxisAlignedBox<T>::include(const AxisAlignedBox<T>& b) { include(b._min) ; include(b._max) ; } } #endif
2,992
28.343137
78
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/Exporter.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _VRENDER_EXPORTER_H #define _VRENDER_EXPORTER_H // Set of classes for exporting in various formats, like EPS, XFig3.2, SVG. #include "Primitive.h" #include "../config.h" #include <QTextStream> #include <QString> namespace vrender { class VRenderParams ; class Exporter { public: Exporter() ; virtual ~Exporter() {}; virtual void exportToFile(const QString& filename,const std::vector<PtrPrimitive>&,VRenderParams&) ; void setBoundingBox(float xmin,float ymin,float xmax,float ymax) ; void setClearColor(float r,float g,float b) ; void setClearBackground(bool b) ; void setBlackAndWhite(bool b) ; protected: virtual void spewPoint(const Point *, QTextStream& out) = 0 ; virtual void spewSegment(const Segment *, QTextStream& out) = 0 ; virtual void spewPolygone(const Polygone *, QTextStream& out) = 0 ; virtual void writeHeader(QTextStream& out) const = 0 ; virtual void writeFooter(QTextStream& out) const = 0 ; float _clearR,_clearG,_clearB ; float _pointSize ; float _lineWidth ; GLfloat _xmin,_xmax,_ymin,_ymax,_zmin,_zmax ; bool _clearBG,_blackAndWhite ; }; // Exports to encapsulated postscript. class EPSExporter: public Exporter { public: EPSExporter() ; virtual ~EPSExporter() {}; protected: virtual void spewPoint(const Point *, QTextStream& out) ; virtual void spewSegment(const Segment *, QTextStream& out) ; virtual void spewPolygone(const Polygone *, QTextStream& out) ; virtual void writeHeader(QTextStream& out) const ; virtual void writeFooter(QTextStream& out) const ; private: void setColor(QTextStream& out,float,float,float) ; static const double EPS_GOURAUD_THRESHOLD ; static const char *GOURAUD_TRIANGLE_EPS[] ; static const char *CREATOR ; static float last_r ; static float last_g ; static float last_b ; }; // Exports to postscript. The only difference is the filename extension and // the showpage at the end. class PSExporter: public EPSExporter { public: virtual ~PSExporter() {}; protected: virtual void writeFooter(QTextStream& out) const ; }; class FIGExporter: public Exporter { public: FIGExporter() ; virtual ~FIGExporter() {}; protected: virtual void spewPoint(const Point *, QTextStream& out) ; virtual void spewSegment(const Segment *, QTextStream& out) ; virtual void spewPolygone(const Polygone *, QTextStream& out) ; virtual void writeHeader(QTextStream& out) const ; virtual void writeFooter(QTextStream& out) const ; private: mutable int _sizeX ; mutable int _sizeY ; mutable int _depth ; int FigCoordX(double) const ; int FigCoordY(double) const ; int FigGrayScaleIndex(float red, float green, float blue) const ; }; #ifdef A_FAIRE class SVGExporter: public Exporter { protected: virtual void spewPoint(const Point *, QTextStream& out) ; virtual void spewSegment(const Segment *, QTextStream& out) ; virtual void spewPolygone(const Polygone *, QTextStream& out) ; virtual void writeHeader(QTextStream& out) const ; virtual void writeFooter(QTextStream& out) const ; }; #endif } #endif
4,999
29.120482
103
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/NVector3.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _VRENDER_NVECTOR3_H #define _VRENDER_NVECTOR3_H #include <iostream> #include <stdexcept> namespace vrender { class Vector3; class NVector3 { public: NVector3(); NVector3(const NVector3& u); inline NVector3(double x,double y,double z,bool normalization=true) { setXYZ(x,y,z,normalization); } NVector3(const Vector3 &u,bool normalization=true); inline double x() const {return _n[0];} inline double y() const {return _n[1];} inline double z() const {return _n[2];} void setXYZ(double x,double y,double z,bool normalization=true); NVector3& operator=(const NVector3& u); /* inline friend bool operator==(const NVector3 &u,const Vector3 &v) {return u.isEqualTo(v);} inline friend bool operator==(const Vector3 &u,const NVector3 &v) {return v.isEqualTo(u);} inline friend bool operator==(const NVector3 &u,const NVector3 &v) {return u.isEqualTo(v);} inline friend bool operator!=(const NVector3 &u,const Vector3 &v) {return !(u == v);} inline friend bool operator!=(const Vector3 &u,const NVector3 &v) {return !(u == v);} inline friend bool operator!=(const NVector3 &u,const NVector3 &v) {return !(u == v);} */ inline friend NVector3 operator-(const NVector3 &u) { return NVector3(-u[0],-u[1],-u[2],false); } //inline friend Vector3 operator+(const NVector3 &u,const Vector3 &v); //inline friend Vector3 operator+(const Vector3 &u,const NVector3 &v); //inline friend Vector3 operator+(const NVector3 &u,const NVector3 &v); //inline friend Vector3 operator-(const NVector3 &u,const Vector3 &v); //inline friend Vector3 operator-(const Vector3 &u,const NVector3 &v); //inline friend Vector3 operator-(const NVector3 &u,const NVector3 &v); friend double operator*(const NVector3 &u,const Vector3 &v); friend double operator*(const Vector3 &u,const NVector3 &v); //inline friend double operator*(const NVector3 &u,const NVector3 &v); //inline friend Vector3 operator*(double r,const NVector3 &u); //inline friend Vector3 operator/(const NVector3 &u,double r); //inline friend Vector3 operator^(const NVector3 &u,const Vector3 &v); //inline friend Vector3 operator^(const Vector3 &u,const NVector3 &v); //inline friend Vector3 operator^(const NVector3 &u,const NVector3 &v); inline double norm() const {return 1.0;} inline double squareNorm() const {return 1.0;} friend std::ostream& operator<<(std::ostream &out,const NVector3 &u); double operator[](int i) const { if((i < 0)||(i > 2)) throw std::runtime_error("Out of bounds in NVector3::operator[]") ; return _n[i]; } private: void normalize(); double _n[3]; //!< normalized vector }; // interface of NVector3 } #endif // _NVECTOR3_H
4,665
37.561983
101
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/Optimizer.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _OPTIMIZER_H #define _OPTIMIZER_H #include "Types.h" namespace vrender { // Implements some global optimizations on the polygon sorting. class VRenderParams ; class Optimizer { public: virtual void optimize(std::vector<PtrPrimitive>&,VRenderParams&) = 0 ; virtual ~Optimizer() {} ; }; // Optimizes visibility by culling primitives which do not appear in the // rendered image. Computations are done analytically rather than using an item // buffer. class VisibilityOptimizer: public Optimizer { public: virtual void optimize(std::vector<PtrPrimitive>&,VRenderParams&) ; virtual ~VisibilityOptimizer() {} ; }; // Optimizes by collapsing together primitives which can be, without // perturbating the back to front painting algorithm. class PrimitiveSplitOptimizer: public Optimizer { public: virtual void optimize(std::vector<PtrPrimitive>&,VRenderParams&) {} virtual ~PrimitiveSplitOptimizer() {} ; }; class BackFaceCullingOptimizer: public Optimizer { public: virtual void optimize(std::vector<PtrPrimitive>&,VRenderParams&) ; virtual ~BackFaceCullingOptimizer() {} ; }; } #endif
2,989
31.5
80
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/ParserGL.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _VRENDER_PARSERGL_H #define _VRENDER_PARSERGL_H // This class implements the conversion from OpenGL feedback buffer into more // usable data structures such as points, segments, and polygons (See Primitive.h) #include <vector> #include "Primitive.h" namespace vrender { class ParserGL { public: void parseFeedbackBuffer( GLfloat *, int size, std::vector<PtrPrimitive>& primitive_tab, VRenderParams& vparams) ; void printStats() const ; inline GLfloat xmin() const { return _xmin ; } inline GLfloat ymin() const { return _ymin ; } inline GLfloat zmin() const { return _zmin ; } inline GLfloat xmax() const { return _xmax ; } inline GLfloat ymax() const { return _ymax ; } inline GLfloat zmax() const { return _zmax ; } private: int nb_lines ; int nb_polys ; int nb_points ; int nb_degenerated_lines ; int nb_degenerated_polys ; int nb_degenerated_points ; GLfloat _xmin ; GLfloat _ymin ; GLfloat _zmin ; GLfloat _xmax ; GLfloat _ymax ; GLfloat _zmax ; }; } #endif
2,920
31.820225
82
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/Primitive.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _PRIMITIVE_H_ #define _PRIMITIVE_H_ #include <vector> #include "AxisAlignedBox.h" #include "Vector3.h" #include "NVector3.h" #include "Types.h" #ifdef WIN32 # include <windows.h> #endif #ifdef __APPLE__ # include <OpenGL/gl.h> #else # include <GL/gl.h> #endif namespace vrender { class Feedback3DColor ; class Primitive ; #define EPS_SMOOTH_LINE_FACTOR 0.06 /* Lower for better smooth lines. */ // A Feedback3DColor is a structure containing informations about a vertex projected into // the frame buffer. class Feedback3DColor { public: Feedback3DColor(GLfloat *loc) : _pos(loc[0],loc[1],loc[2]), _red(loc[3]),_green(loc[4]),_blue(loc[5]),_alpha(loc[6]) {} inline FLOAT x() const { return _pos[0] ; } inline FLOAT y() const { return _pos[1] ; } inline FLOAT z() const { return _pos[2] ; } inline GLfloat red() const { return _red ; } inline GLfloat green() const { return _green ; } inline GLfloat blue() const { return _blue ; } inline GLfloat alpha() const { return _alpha ; } inline const Vector3& pos() const { return _pos ; } inline Feedback3DColor operator+(const Feedback3DColor & v) const { return Feedback3DColor(x()+v.x(),y()+v.y(),z()+v.z(),red()+v.red(),green()+v.green(),blue()+v.blue(),alpha()+v.alpha()) ; } inline Feedback3DColor operator*(const GLFLOAT & f) const { return Feedback3DColor(x()*f,y()*f,z()*f,red()*GLfloat(f),green()*GLfloat(f),blue()*GLfloat(f),alpha()*GLfloat(f)) ; } friend inline Feedback3DColor operator*(const GLFLOAT & f,const Feedback3DColor& F) { return F*f ; } static size_t sizeInBuffer() { return 7 ; } friend std::ostream& operator<<(std::ostream&,const Feedback3DColor&) ; protected: Feedback3DColor(FLOAT x, FLOAT y, FLOAT z, GLfloat r, GLfloat g, GLfloat b, GLfloat a) :_pos(x,y,z), _red(r), _green(g), _blue(b), _alpha(a) {} Vector3 _pos ; GLfloat _red; GLfloat _green; GLfloat _blue; GLfloat _alpha; } ; // A primitive is an entity // class Primitive { public: virtual ~Primitive() {} virtual const Feedback3DColor& sommet3DColor(size_t) const =0 ; // Renvoie le ieme vertex modulo le nombre de vertex. virtual const Vector3& vertex(size_t) const = 0 ; #ifdef A_FAIRE virtual FLOAT Get_I_EPS(Primitive *) const ; Vect3 VerticalProjectPointOnSupportPlane(const Vector3 &) const ; void IntersectPrimitiveWithSupportPlane(Primitive *,int[],FLOAT[],Vect3 *&,Vect3 *&) ; inline FLOAT Equation(const Vect3& p) { return p*_normal-_C ; } virtual void Split(Vect3,FLOAT,Primitive * &,Primitive * &) = 0 ; void GetSigns(Primitive *,int * &,FLOAT * &,int &,int &,FLOAT) ; FLOAT Const() const { return _C ; } int depth() const { return _depth ; } void setDepth(int d) const { _depth = d ; } #endif virtual AxisAlignedBox_xyz bbox() const = 0 ; virtual size_t nbVertices() const = 0 ; protected: int _vibility ; } ; class Point: public Primitive { public: Point(const Feedback3DColor& f); virtual ~Point() {} virtual const Vector3& vertex(size_t) const ; virtual size_t nbVertices() const { return 1 ; } virtual const Feedback3DColor& sommet3DColor(size_t) const ; virtual AxisAlignedBox_xyz bbox() const ; private: Feedback3DColor _position_and_color ; }; class Segment: public Primitive { public: Segment(const Feedback3DColor & p1, const Feedback3DColor & p2): P1(p1), P2(p2) {} virtual ~Segment() {} virtual size_t nbVertices() const { return 2 ; } virtual const Vector3& vertex(size_t) const ; virtual const Feedback3DColor& sommet3DColor(size_t i) const ; virtual AxisAlignedBox_xyz bbox() const ; #ifdef A_FAIRE virtual void Split(const Vector3&,FLOAT,Primitive * &,Primitive * &) ; #endif protected: Feedback3DColor P1 ; Feedback3DColor P2 ; } ; class Polygone: public Primitive { public: Polygone(const std::vector<Feedback3DColor>&) ; virtual ~Polygone() {} #ifdef A_FAIRE virtual int IsAPolygon() { return 1 ; } virtual void Split(const Vector3&,FLOAT,Primitive * &,Primitive * &) ; void InitEquation(double &,double &,double &,double &) ; #endif virtual const Feedback3DColor& sommet3DColor(size_t) const ; virtual const Vector3& vertex(size_t) const ; virtual size_t nbVertices() const { return _vertices.size() ; } virtual AxisAlignedBox_xyz bbox() const ; double equation(const Vector3& p) const ; const NVector3& normal() const { return _normal ; } double c() const { return _c ; } FLOAT FlatFactor() const { return anglefactor ; } protected: virtual void initNormal() ; void CheckInfoForPositionOperators() ; AxisAlignedBox_xyz _bbox ; std::vector<Feedback3DColor> _vertices ; // std::vector<FLOAT> _sommetsProjetes ; // Vector3 N,M,L ; double anglefactor ; // Determine a quel point un polygone est plat. // Comparer a FLAT_POLYGON_EPS double _c ; NVector3 _normal ; } ; } #endif
6,735
29.618182
124
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/PrimitivePositioning.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _PRIMITIVEPOSITIONING_H #define _PRIMITIVEPOSITIONING_H #include <vector> #include "gpc.h" namespace vrender { class Primitive ; // This class implements a static method for positioning two primitives relative to each other. class PrimitivePositioning { public: typedef enum { Independent = 0x0, Upper = 0x1, Lower = 0x2 } RelativePosition ; static int computeRelativePosition(const Primitive *p1,const Primitive *p2) ; static void splitPrimitive(Primitive *P,const NVector3& v,double c,Primitive *& prim_up,Primitive *& prim_lo) ; static void split(Segment *S, const NVector3& v,double C,Primitive * & P_plus,Primitive * & P_moins) ; static void split(Point *P, const NVector3& v,double C,Primitive * & P_plus,Primitive * & P_moins) ; static void split(Polygone *P,const NVector3& v,double C,Primitive * & P_plus,Primitive * & P_moins) ; private: static void getsigns(const Primitive *P,const NVector3& v, double C,std::vector<int>& signs,std::vector<double>& zvals, int& Smin,int& Smax,double I_EPS) ; static int computeRelativePosition(const Polygone *p1,const Polygone *p2) ; static int computeRelativePosition(const Polygone *p1,const Segment *p2) ; static int computeRelativePosition(const Polygone *p1,const Point *p2) ; static int computeRelativePosition(const Segment *p1,const Segment *p2) ; // 2D intersection/positioning methods. Parameter I_EPS may be positive of negative // depending on the wanted degree of conservativeness of the result. static bool pointOutOfPolygon_XY(const Vector3& P,const Polygone *Q,double I_EPS) ; static bool intersectSegments_XY(const Vector2& P1,const Vector2& Q1, const Vector2& P2,const Vector2& Q2, double I_EPS,double & t1,double & t2) ; static gpc_polygon createGPCPolygon_XY(const Polygone *P) ; static int inverseRP(int) ; // This value is *non negative*. It may be used with a negative sign // in 2D methods such as pointOutOfPolygon() so as to rule the behaviour of // the positionning. static double _EPS ; }; } #endif
3,993
37.776699
114
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/SortMethod.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _SORTMETHOD_H #define _SORTMETHOD_H #include <vector> #include "Types.h" namespace vrender { // Class which implements the sorting of the primitives. An object of class VRenderParams ; class SortMethod { public: SortMethod() {} virtual ~SortMethod() {} virtual void sortPrimitives(std::vector<PtrPrimitive>&,VRenderParams&) = 0 ; void SetZDepth(FLOAT s) { zSize = s ; } FLOAT ZDepth() const { return zSize ; } protected: FLOAT zSize ; }; class DontSortMethod: public SortMethod { public: DontSortMethod() {} virtual ~DontSortMethod() {} virtual void sortPrimitives(std::vector<PtrPrimitive>&,VRenderParams&) {} }; class BSPSortMethod: public SortMethod { public: BSPSortMethod() {} ; virtual ~BSPSortMethod() {} virtual void sortPrimitives(std::vector<PtrPrimitive>&,VRenderParams&) ; }; class TopologicalSortMethod: public SortMethod { public: TopologicalSortMethod() ; virtual ~TopologicalSortMethod() {} virtual void sortPrimitives(std::vector<PtrPrimitive>&,VRenderParams&) ; void setBreakCycles(bool b) { _break_cycles = b ; } private: bool _break_cycles ; }; } #endif
3,011
28.242718
79
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/Types.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _VRENDER_TYPES_H #define _VRENDER_TYPES_H #ifdef WIN32 # include <windows.h> #endif #ifdef __APPLE__ # include <OpenGL/gl.h> #else # include <GL/gl.h> #endif namespace vrender { typedef double FLOAT ; typedef GLdouble GLFLOAT ; #ifdef A_VOIR typedef T_Vect3<double> DVector3 ; typedef T_Vect2<double> Vector2 ; #endif class Primitive ; typedef Primitive *PtrPrimitive ; const float FLAT_POLYGON_EPS = 1e-5f ; } #endif
2,279
29.4
78
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/VRender.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _VRENDER_H_ #define _VRENDER_H_ #include "../config.h" #include <QTextStream> #include <QString> #include "../qglviewer.h" namespace vrender { class VRenderParams ; typedef void (*RenderCB)(void *) ; typedef void (*ProgressFunction)(float,const QString&) ; void VectorialRender(RenderCB DrawFunc, void *callback_params, VRenderParams& render_params) ; class VRenderParams { public: VRenderParams() ; ~VRenderParams() ; enum VRenderSortMethod { NoSorting, BSPSort, TopologicalSort, AdvancedTopologicalSort }; enum VRenderFormat { EPS, PS, XFIG, SVG }; enum VRenderOption { CullHiddenFaces = 0x1, OptimizeBackFaceCulling = 0x4, RenderBlackAndWhite = 0x8, AddBackground = 0x10, TightenBoundingBox = 0x20 } ; int sortMethod() { return _sortMethod; } void setSortMethod(VRenderParams::VRenderSortMethod s) { _sortMethod = s ; } int format() { return _format; } void setFormat(VRenderFormat f) { _format = f; } const QString filename() { return _filename ; } void setFilename(const QString& filename) ; void setOption(VRenderOption,bool) ; bool isEnabled(VRenderOption) ; void setProgressFunction(ProgressFunction pf) { _progress_function = pf ; } private: int _error; VRenderSortMethod _sortMethod; VRenderFormat _format ; ProgressFunction _progress_function ; unsigned int _options; // _DrawMode; _ClearBG; _TightenBB; QString _filename; friend void VectorialRender( RenderCB render_callback, void *callback_params, VRenderParams& vparams); friend class ParserGL ; friend class Exporter ; friend class BSPSortMethod ; friend class VisibilityOptimizer ; friend class TopologicalSortMethod ; friend class TopologicalSortUtils ; int& error() { return _error ; } int& size() { static int size=1000000; return size ; } void progress(float,const QString&) ; }; } #endif
3,811
31.033613
95
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/Vector2.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _VRENDER_VECTOR2_H #define _VRENDER_VECTOR2_H #include <stdexcept> #include <iostream> namespace vrender { class Vector3; class Vector2 { public: // --------------------------------------------------------------------------- //! @name Constant //@{ static const Vector2 inf; //@} // --------------------------------------------------------------------------- //! @name Constructor(s) and destructor //@{ Vector2 (); ~Vector2 (); Vector2 (const Vector2&); Vector2 (const Vector3& u); Vector2 (double,double); //@} // --------------------------------------------------------------------------- //! @name Access methods //@{ inline double x() const { return _xyz[0]; } inline double y() const { return _xyz[1]; } inline void setX(double r) { _xyz[0] = r; } inline void setY(double r) { _xyz[1] = r; } inline void setXY (double x,double y) { _xyz[0] = x; _xyz[1] = y; } //@} // --------------------------------------------------------------------------- //! @name Assignment //@{ inline Vector2& operator= (const Vector2& u) { _xyz[0] = u._xyz[0]; _xyz[1] = u._xyz[1]; return *this; } //@} // --------------------------------------------------------------------------- //! @name Comparisons //@{ friend bool operator== (const Vector2&,const Vector2&); friend bool operator!= (const Vector2&,const Vector2&); //@} // --------------------------------------------------------------------------- //! @name Algebraic operations //@{ inline Vector2& operator+= (const Vector2& v) { _xyz[0] += v._xyz[0]; _xyz[1] += v._xyz[1]; return *this; } inline Vector2& operator-= (const Vector2& v) { _xyz[0] -= v._xyz[0]; _xyz[1] -= v._xyz[1]; return *this; } inline Vector2& operator*= (double f) { _xyz[0] *= f; _xyz[1] *= f; return *this;} inline Vector2& operator/= (double f) { _xyz[0] /= f; _xyz[1] /= f; return *this;} friend Vector2 operator- (const Vector2&); static Vector2 mini(const Vector2&,const Vector2&) ; static Vector2 maxi(const Vector2&,const Vector2&) ; inline Vector2 operator+(const Vector2& u) const { return Vector2(_xyz[0]+u._xyz[0],_xyz[1]+u._xyz[1]); } inline Vector2 operator-(const Vector2& u) const { return Vector2(_xyz[0]-u._xyz[0],_xyz[1]-u._xyz[1]); } inline double operator*(const Vector2& u) const { return _xyz[0]*u._xyz[0] + _xyz[1]*u._xyz[1] ; } inline double operator^(const Vector2& v) const { return _xyz[0]*v._xyz[1] - _xyz[1]*v._xyz[0] ; } Vector2 operator/ (double v) { return Vector2(_xyz[0]/v,_xyz[1]/v); } Vector2 operator* (double v) { return Vector2(_xyz[0]*v,_xyz[1]*v); } friend Vector2 operator* (double,const Vector2&); //@} // --------------------------------------------------------------------------- //! @name Metrics //@{ double norm () const; double squareNorm () const; double infNorm () const; /// Should be used for most comparisons, for efficiency reasons. //@} // --------------------------------------------------------------------------- //! @name Stream overrides //@{ friend std::ostream& operator<< (std::ostream&,const Vector2&); //@} double operator[] (int i) const { if((i < 0)||(i > 1)) throw std::runtime_error("Out of bounds in Vector2::operator[]") ; return _xyz[i]; } double& operator[] (int i) { if((i < 0)||(i > 1)) throw std::runtime_error("Out of bounds in Vector2::operator[]") ; return _xyz[i]; } private: double _xyz[2]; //!< The 3 vector components }; // interface of Vector2 } #endif // _VECTOR2_H
5,582
29.675824
108
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/Vector3.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ #ifndef _VRENDER_VECTOR3_H #define _VRENDER_VECTOR3_H #include <stdexcept> #ifndef FLT_MAX # define FLT_MAX 9.99E20f #endif namespace vrender { class NVector3; class Vector3 { public: // --------------------------------------------------------------------------- //! @name Constant //@{ static const Vector3 inf; //@} // --------------------------------------------------------------------------- //! @name Constructor(s) and destructor //@{ Vector3 (); ~Vector3 (); Vector3 (const Vector3&); Vector3 (const NVector3&); Vector3 (double, double, double); //@} // --------------------------------------------------------------------------- //! @name Access methods //@{ inline double x() const { return _xyz[0]; } inline double y() const { return _xyz[1]; } inline double z() const { return _xyz[2]; } inline void setX(double r) { _xyz[0] = r; } inline void setY(double r) { _xyz[1] = r; } inline void setZ(double r) { _xyz[2] = r; } inline void setXYZ (double x,double y,double z) { _xyz[0] = x; _xyz[1] = y; _xyz[2] = z; } //@} // --------------------------------------------------------------------------- //! @name Assignment //@{ inline Vector3& operator= (const Vector3& u) { _xyz[0] = u._xyz[0]; _xyz[1] = u._xyz[1]; _xyz[2] = u._xyz[2]; return *this; } Vector3& operator= (const NVector3& u); //@} // --------------------------------------------------------------------------- //! @name Comparisons //@{ friend bool operator== (const Vector3&,const Vector3&); friend bool operator!= (const Vector3&,const Vector3&); //@} // --------------------------------------------------------------------------- //! @name Algebraic operations //@{ inline Vector3& operator+= (const Vector3& v) { _xyz[0] += v._xyz[0]; _xyz[1] += v._xyz[1]; _xyz[2] += v._xyz[2]; return *this; } inline Vector3& operator-= (const Vector3& v) { _xyz[0] -= v._xyz[0]; _xyz[1] -= v._xyz[1]; _xyz[2] -= v._xyz[2]; return *this; } inline Vector3& operator*= (double f) { _xyz[0] *= f; _xyz[1] *= f; _xyz[2] *= f; return *this;} inline Vector3& operator/= (double f) { _xyz[0] /= f; _xyz[1] /= f; _xyz[2] /= f; return *this;} static Vector3 mini(const Vector3&,const Vector3&) ; static Vector3 maxi(const Vector3&,const Vector3&) ; Vector3& operator-= (const NVector3&); Vector3& operator+= (const NVector3&); friend Vector3 operator- (const Vector3& u) { return Vector3(-u[0], -u[1], -u[2]); } inline Vector3 operator+(const Vector3& u) const { return Vector3(_xyz[0]+u._xyz[0],_xyz[1]+u._xyz[1],_xyz[2]+u._xyz[2]); } inline Vector3 operator-(const Vector3& u) const { return Vector3(_xyz[0]-u._xyz[0],_xyz[1]-u._xyz[1],_xyz[2]-u._xyz[2]); } inline double operator*(const Vector3& u) const { return _xyz[0]*u._xyz[0] + _xyz[1]*u._xyz[1] + _xyz[2]*u._xyz[2]; } inline Vector3 operator^(const Vector3& v) const { return Vector3( _xyz[1]*v._xyz[2] - _xyz[2]*v._xyz[1], _xyz[2]*v._xyz[0] - _xyz[0]*v._xyz[2], _xyz[0]*v._xyz[1] - _xyz[1]*v._xyz[0]); } Vector3 operator/ (double v) { return Vector3(_xyz[0]/v,_xyz[1]/v,_xyz[2]/v); } Vector3 operator* (double v) { return Vector3(_xyz[0]*v,_xyz[1]*v,_xyz[2]*v); } friend Vector3 operator* (double,const Vector3&); //@} // --------------------------------------------------------------------------- //! @name Metrics //@{ double norm () const; double squareNorm () const; double infNorm () const; /// Should be used for most comparisons, for efficiency reasons. //@} // --------------------------------------------------------------------------- //! @name Stream overrides //@{ friend std::ostream& operator<< (std::ostream&,const Vector3&); //@} double operator[] (int i) const { if((i < 0)||(i > 2)) throw std::runtime_error("Out of bounds in Vector3::operator[]") ; return _xyz[i]; } double& operator[] (int i) { if((i < 0)||(i > 2)) throw std::runtime_error("Out of bounds in Vector3::operator[]") ; return _xyz[i]; } private: double _xyz[3]; //!< The 3 vector components }; // interface of Vector3 } #endif // _VECTOR3_H
6,196
30.617347
129
h
octomap
octomap-master/octovis/src/extern/QGLViewer/VRender/gpc.h
/* This file is part of the VRender library. Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr) Version 1.0.0, released on June 27, 2005. http://artis.imag.fr/Members/Cyril.Soler/VRender VRender is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. VRender is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VRender; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /**************************************************************************** Copyright (C) 2002-2014 Gilles Debunne. All rights reserved. This file is part of the QGLViewer library version 2.6.3. http://www.libqglviewer.com - contact@libqglviewer.com This file may be used under the terms of the GNU General Public License versions 2.0 or 3.0 as published by the Free Software Foundation and appearing in the LICENSE file included in the packaging of this file. In addition, as a special exception, Gilles Debunne gives you certain additional rights, described in the file GPL_EXCEPTION in this package. libQGLViewer uses dual licensing. Commercial/proprietary software must purchase a libQGLViewer Commercial License. This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *****************************************************************************/ /* =========================================================================== Project: Generic Polygon Clipper A new algorithm for calculating the difference, intersection, exclusive-or or union of arbitrary polygon sets. File: gpc.h Author: Alan Murta (email: gpc@cs.man.ac.uk) Version: 2.32 Date: 17th December 2004 Copyright: (C) 1997-2004, Advanced Interfaces Group, University of Manchester. This software is free for non-commercial use. It may be copied, modified, and redistributed provided that this copyright notice is preserved on all copies. The intellectual property rights of the algorithms used reside with the University of Manchester Advanced Interfaces Group. You may not use this software, in whole or in part, in support of any commercial product without the express consent of the author. There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is". =========================================================================== */ #ifndef __gpc_h #define __gpc_h #include <stdio.h> /* =========================================================================== Constants =========================================================================== */ /* Increase GPC_EPSILON to encourage merging of near coincident edges */ //#define GPC_EPSILON (DBL_EPSILON) #define GPC_EPSILON 1e-7 #define GPC_VERSION "2.32" /* =========================================================================== Public Data Types =========================================================================== */ typedef enum /* Set operation type */ { GPC_DIFF, /* Difference */ GPC_INT, /* Intersection */ GPC_XOR, /* Exclusive or */ GPC_UNION /* Union */ } gpc_op; typedef struct /* Polygon vertex structure */ { double x; /* Vertex x component */ double y; /* vertex y component */ } gpc_vertex; typedef struct /* Vertex list structure */ { long num_vertices; /* Number of vertices in list */ gpc_vertex *vertex; /* Vertex array pointer */ } gpc_vertex_list; typedef struct /* Polygon set structure */ { unsigned long num_contours; /* Number of contours in polygon */ int *hole; /* Hole / external contour flags */ gpc_vertex_list *contour; /* Contour array pointer */ } gpc_polygon; typedef struct /* Tristrip set structure */ { unsigned long num_strips; /* Number of tristrips */ gpc_vertex_list *strip; /* Tristrip array pointer */ } gpc_tristrip; /* =========================================================================== Public Function Prototypes =========================================================================== */ void gpc_read_polygon (FILE *infile_ptr, int read_hole_flags, gpc_polygon *polygon); void gpc_write_polygon (FILE *outfile_ptr, int write_hole_flags, gpc_polygon *polygon); void gpc_add_contour (gpc_polygon *polygon, gpc_vertex_list *contour, int hole); void gpc_polygon_clip (gpc_op set_operation, gpc_polygon *subject_polygon, gpc_polygon *clip_polygon, gpc_polygon *result_polygon); void gpc_tristrip_clip (gpc_op set_operation, gpc_polygon *subject_polygon, gpc_polygon *clip_polygon, gpc_tristrip *result_tristrip); void gpc_polygon_to_tristrip (gpc_polygon *polygon, gpc_tristrip *tristrip); void gpc_free_polygon (gpc_polygon *polygon); void gpc_free_tristrip (gpc_tristrip *tristrip); #endif /* =========================================================================== End of file: gpc.h =========================================================================== */
6,364
34.361111
78
h
spaCy
spaCy-master/spacy/matcher/polyleven.c
/* * Adapted from Polyleven (https://ceptord.net/) * * Source: https://github.com/fujimotos/polyleven/blob/c3f95a080626c5652f0151a2e449963288ccae84/polyleven.c * * Copyright (c) 2021 Fujimoto Seiji <fujimoto@ceptord.net> * Copyright (c) 2021 Max Bachmann <kontakt@maxbachmann.de> * Copyright (c) 2022 Nick Mazuk * Copyright (c) 2022 Michael Weiss <code@mweiss.ch> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <Python.h> #include <stdint.h> #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) #define CDIV(a,b) ((a) / (b) + ((a) % (b) > 0)) #define BIT(i,n) (((i) >> (n)) & 1) #define FLIP(i,n) ((i) ^ ((uint64_t) 1 << (n))) #define ISASCII(kd) ((kd) == PyUnicode_1BYTE_KIND) /* * Bare bone of PyUnicode */ struct strbuf { void *ptr; int kind; int64_t len; }; static void strbuf_init(struct strbuf *s, PyObject *o) { s->ptr = PyUnicode_DATA(o); s->kind = PyUnicode_KIND(o); s->len = PyUnicode_GET_LENGTH(o); } #define strbuf_read(s, i) PyUnicode_READ((s)->kind, (s)->ptr, (i)) /* * An encoded mbleven model table. * * Each 8-bit integer represents an edit sequence, with using two * bits for a single operation. * * 01 = DELETE, 10 = INSERT, 11 = REPLACE * * For example, 13 is '1101' in binary notation, so it means * DELETE + REPLACE. */ static const uint8_t MBLEVEN_MATRIX[] = { 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 15, 9, 6, 0, 0, 0, 0, 0, 13, 7, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 63, 39, 45, 57, 54, 30, 27, 0, 61, 55, 31, 37, 25, 22, 0, 0, 53, 29, 23, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, }; #define MBLEVEN_MATRIX_GET(k, d) ((((k) + (k) * (k)) / 2 - 1) + (d)) * 8 static int64_t mbleven_ascii(char *s1, int64_t len1, char *s2, int64_t len2, int k) { int pos; uint8_t m; int64_t i, j, c, r; pos = MBLEVEN_MATRIX_GET(k, len1 - len2); r = k + 1; while (MBLEVEN_MATRIX[pos]) { m = MBLEVEN_MATRIX[pos++]; i = j = c = 0; while (i < len1 && j < len2) { if (s1[i] != s2[j]) { c++; if (!m) break; if (m & 1) i++; if (m & 2) j++; m >>= 2; } else { i++; j++; } } c += (len1 - i) + (len2 - j); r = MIN(r, c); if (r < 2) { return r; } } return r; } static int64_t mbleven(PyObject *o1, PyObject *o2, int64_t k) { int pos; uint8_t m; int64_t i, j, c, r; struct strbuf s1, s2; strbuf_init(&s1, o1); strbuf_init(&s2, o2); if (s1.len < s2.len) return mbleven(o2, o1, k); if (k > 3) return -1; if (k < s1.len - s2.len) return k + 1; if (ISASCII(s1.kind) && ISASCII(s2.kind)) return mbleven_ascii(s1.ptr, s1.len, s2.ptr, s2.len, k); pos = MBLEVEN_MATRIX_GET(k, s1.len - s2.len); r = k + 1; while (MBLEVEN_MATRIX[pos]) { m = MBLEVEN_MATRIX[pos++]; i = j = c = 0; while (i < s1.len && j < s2.len) { if (strbuf_read(&s1, i) != strbuf_read(&s2, j)) { c++; if (!m) break; if (m & 1) i++; if (m & 2) j++; m >>= 2; } else { i++; j++; } } c += (s1.len - i) + (s2.len - j); r = MIN(r, c); if (r < 2) { return r; } } return r; } /* * Data structure to store Peq (equality bit-vector). */ struct blockmap_entry { uint32_t key[128]; uint64_t val[128]; }; struct blockmap { int64_t nr; struct blockmap_entry *list; }; #define blockmap_key(c) ((c) | 0x80000000U) #define blockmap_hash(c) ((c) % 128) static int blockmap_init(struct blockmap *map, struct strbuf *s) { int64_t i; struct blockmap_entry *be; uint32_t c, k; uint8_t h; map->nr = CDIV(s->len, 64); map->list = calloc(1, map->nr * sizeof(struct blockmap_entry)); if (map->list == NULL) { PyErr_NoMemory(); return -1; } for (i = 0; i < s->len; i++) { be = &(map->list[i / 64]); c = strbuf_read(s, i); h = blockmap_hash(c); k = blockmap_key(c); while (be->key[h] && be->key[h] != k) h = blockmap_hash(h + 1); be->key[h] = k; be->val[h] |= (uint64_t) 1 << (i % 64); } return 0; } static void blockmap_clear(struct blockmap *map) { if (map->list) free(map->list); map->list = NULL; map->nr = 0; } static uint64_t blockmap_get(struct blockmap *map, int block, uint32_t c) { struct blockmap_entry *be; uint8_t h; uint32_t k; h = blockmap_hash(c); k = blockmap_key(c); be = &(map->list[block]); while (be->key[h] && be->key[h] != k) h = blockmap_hash(h + 1); return be->key[h] == k ? be->val[h] : 0; } /* * Myers' bit-parallel algorithm * * See: G. Myers. "A fast bit-vector algorithm for approximate string * matching based on dynamic programming." Journal of the ACM, 1999. */ static int64_t myers1999_block(struct strbuf *s1, struct strbuf *s2, struct blockmap *map) { uint64_t Eq, Xv, Xh, Ph, Mh, Pv, Mv, Last; uint64_t *Mhc, *Phc; int64_t i, b, hsize, vsize, Score; uint8_t Pb, Mb; hsize = CDIV(s1->len, 64); vsize = CDIV(s2->len, 64); Score = s2->len; Phc = malloc(hsize * 2 * sizeof(uint64_t)); if (Phc == NULL) { PyErr_NoMemory(); return -1; } Mhc = Phc + hsize; memset(Phc, -1, hsize * sizeof(uint64_t)); memset(Mhc, 0, hsize * sizeof(uint64_t)); Last = (uint64_t)1 << ((s2->len - 1) % 64); for (b = 0; b < vsize; b++) { Mv = 0; Pv = (uint64_t) -1; Score = s2->len; for (i = 0; i < s1->len; i++) { Eq = blockmap_get(map, b, strbuf_read(s1, i)); Pb = BIT(Phc[i / 64], i % 64); Mb = BIT(Mhc[i / 64], i % 64); Xv = Eq | Mv; Xh = ((((Eq | Mb) & Pv) + Pv) ^ Pv) | Eq | Mb; Ph = Mv | ~ (Xh | Pv); Mh = Pv & Xh; if (Ph & Last) Score++; if (Mh & Last) Score--; if ((Ph >> 63) ^ Pb) Phc[i / 64] = FLIP(Phc[i / 64], i % 64); if ((Mh >> 63) ^ Mb) Mhc[i / 64] = FLIP(Mhc[i / 64], i % 64); Ph = (Ph << 1) | Pb; Mh = (Mh << 1) | Mb; Pv = Mh | ~ (Xv | Ph); Mv = Ph & Xv; } } free(Phc); return Score; } static int64_t myers1999_simple(uint8_t *s1, int64_t len1, uint8_t *s2, int64_t len2) { uint64_t Peq[256]; uint64_t Eq, Xv, Xh, Ph, Mh, Pv, Mv, Last; int64_t i; int64_t Score = len2; memset(Peq, 0, sizeof(Peq)); for (i = 0; i < len2; i++) Peq[s2[i]] |= (uint64_t) 1 << i; Mv = 0; Pv = (uint64_t) -1; Last = (uint64_t) 1 << (len2 - 1); for (i = 0; i < len1; i++) { Eq = Peq[s1[i]]; Xv = Eq | Mv; Xh = (((Eq & Pv) + Pv) ^ Pv) | Eq; Ph = Mv | ~ (Xh | Pv); Mh = Pv & Xh; if (Ph & Last) Score++; if (Mh & Last) Score--; Ph = (Ph << 1) | 1; Mh = (Mh << 1); Pv = Mh | ~ (Xv | Ph); Mv = Ph & Xv; } return Score; } static int64_t myers1999(PyObject *o1, PyObject *o2) { struct strbuf s1, s2; struct blockmap map; int64_t ret; strbuf_init(&s1, o1); strbuf_init(&s2, o2); if (s1.len < s2.len) return myers1999(o2, o1); if (ISASCII(s1.kind) && ISASCII(s2.kind) && s2.len < 65) return myers1999_simple(s1.ptr, s1.len, s2.ptr, s2.len); if (blockmap_init(&map, &s2)) return -1; ret = myers1999_block(&s1, &s2, &map); blockmap_clear(&map); return ret; } /* * Interface functions */ static int64_t polyleven(PyObject *o1, PyObject *o2, int64_t k) { int64_t len1, len2; len1 = PyUnicode_GET_LENGTH(o1); len2 = PyUnicode_GET_LENGTH(o2); if (len1 < len2) return polyleven(o2, o1, k); if (k == 0) return PyUnicode_Compare(o1, o2) ? 1 : 0; if (0 < k && k < len1 - len2) return k + 1; if (len2 == 0) return len1; if (0 < k && k < 4) return mbleven(o1, o2, k); return myers1999(o1, o2); }
9,571
23.862338
107
c
la3dm
la3dm-master/include/bgkloctomap/bgklblock.h
#ifndef LA3DM_BGKL_BLOCK_H #define LA3DM_BGKL_BLOCK_H #include <unordered_map> #include <array> #include "point3f.h" #include "bgkloctree_node.h" #include "bgkloctree.h" namespace la3dm { /// Hask key to index Block given block's center. typedef int64_t BlockHashKey; /// Initialize Look-Up Table std::unordered_map<OcTreeHashKey, point3f> init_key_loc_map(float resolution, unsigned short max_depth); std::unordered_map<unsigned short, OcTreeHashKey> init_index_map(const std::unordered_map<OcTreeHashKey, point3f> &key_loc_map, unsigned short max_depth); /// Extended Block #ifdef PREDICT typedef std::array<BlockHashKey, 27> ExtendedBlock; #else typedef std::array<BlockHashKey, 7> ExtendedBlock; #endif /// Convert from block to hash key. BlockHashKey block_to_hash_key(point3f center); /// Convert from block to hash key. BlockHashKey block_to_hash_key(float x, float y, float z); /// Convert from hash key to block. point3f hash_key_to_block(BlockHashKey key); /// Get current block's extended block. ExtendedBlock get_extended_block(BlockHashKey key); /* * @brief Block is built on top of OcTree, providing the functions to locate nodes. * * Block stores the information needed to locate each OcTreeNode's position: * fixed resolution, fixed block_size, both of which must be initialized. * The localization is implemented using Loop-Up Table. */ class Block : public OcTree { friend BlockHashKey block_to_hash_key(point3f center); friend BlockHashKey block_to_hash_key(float x, float y, float z); friend point3f hash_key_to_block(BlockHashKey key); friend ExtendedBlock get_extended_block(BlockHashKey key); friend class BGKLOctoMap; public: Block(); Block(point3f center); /// @return location of the OcTreeNode given OcTree's LeafIterator. inline point3f get_loc(const LeafIterator &it) const { return Block::key_loc_map[it.get_hash_key()] + center; } /// @return size of the OcTreeNode given OcTree's LeafIterator. inline float get_size(const LeafIterator &it) const { unsigned short depth, index; hash_key_to_node(it.get_hash_key(), depth, index); return float(size / pow(2, depth)); } /// @return center of current Block. inline point3f get_center() const { return center; } /// @return min lim of current Block. inline point3f get_lim_min() const { return center - point3f(size / 2.0f, size / 2.0f, size / 2.0f); } /// @return max lim of current Block. inline point3f get_lim_max() const { return center + point3f(size / 2.0f, size / 2.0f, size / 2.0f); } /// @return ExtendedBlock of current Block. ExtendedBlock get_extended_block() const; OcTreeHashKey get_node(unsigned short x, unsigned short y, unsigned short z) const; point3f get_point(unsigned short x, unsigned short y, unsigned short z) const; void get_index(const point3f &p, unsigned short &x, unsigned short &y, unsigned short &z) const; OcTreeNode &search(float x, float y, float z) const; OcTreeNode &search(point3f p) const; private: // Loop-Up Table static std::unordered_map<OcTreeHashKey, point3f> key_loc_map; static std::unordered_map<unsigned short, OcTreeHashKey> index_map; static float resolution; static float size; static unsigned short cell_num; point3f center; }; } #endif // LA3DM_BGKL_BLOCK_H
3,715
32.781818
131
h
la3dm
la3dm-master/include/bgkloctomap/bgklinference.h
#ifndef LA3DM_BGKL_H #define LA3DM_BGKL_H namespace la3dm { /* * @brief Bayesian Generalized Kernel Inference on Bernoulli distribution * @param dim dimension of data (2, 3, etc.) * @param T data type (float, double, etc.) * @ref Nonparametric Bayesian inference on multivariate exponential families */ template<int dim, typename T> class BGKLInference { public: /// Eigen matrix type for training and test data and kernel using MatrixXType = Eigen::Matrix<T, -1, 2*dim, Eigen::RowMajor>; using MatrixPType = Eigen::Matrix<T, -1, dim, Eigen::RowMajor>; using MatrixKType = Eigen::Matrix<T, -1, -1, Eigen::RowMajor>; using MatrixDKType = Eigen::Matrix<T, -1, 1>; using MatrixYType = Eigen::Matrix<T, -1, 1>; float EPSILON = 0.0001; BGKLInference(T sf2, T ell) : sf2(sf2), ell(ell), trained(false) { } /* * @brief Fit BGK Model * @param x input vector (3N, row major) * @param y target vector (N) */ void train(const std::vector<T> &x, const std::vector<T> &y) { assert(x.size() % (2*dim) == 0 && (int) (x.size() / (2*dim)) == y.size()); MatrixXType _x = Eigen::Map<const MatrixXType>(x.data(), x.size() / (2*dim), 2*dim); MatrixYType _y = Eigen::Map<const MatrixYType>(y.data(), y.size(), 1); train(_x, _y); } /* * @brief Fit BGK Model * @param x input matrix (NX3) * @param y target matrix (NX1) */ void train(const MatrixXType &x, const MatrixYType &y) { // std::cout << "training pt2" << std::endl; this->x = MatrixXType(x); this->y = MatrixYType(y); trained = true; } /* * @brief Predict with BGK Model * @param xs input vector (3M, row major) * @param ybar positive class kernel density estimate (\bar{y}) * @param kbar kernel density estimate (\bar{k}) */ void predict(const std::vector<T> &xs, std::vector<T> &ybar, std::vector<T> &kbar) const { // std::cout << "predicting" << std::endl; assert(xs.size() % dim == 0); // std::cout << "passed assertion" << std::endl; MatrixPType _xs = Eigen::Map<const MatrixPType>(xs.data(), xs.size() / dim, dim); // std::cout << "matrix conversion successful" << std::endl; MatrixYType _ybar, _kbar; predict(_xs, _ybar, _kbar); // std::cout << "finished prediction" << std::endl; ybar.resize(_ybar.rows()); kbar.resize(_kbar.rows()); for (int r = 0; r < _ybar.rows(); ++r) { ybar[r] = _ybar(r, 0); kbar[r] = _kbar(r, 0); } } /* * @brief Predict with nonparametric Bayesian generalized kernel inference * @param xs input vector (M x 3) * @param ybar positive class kernel density estimate (M x 1) * @param kbar kernel density estimate (M x 1) */ void predict(const MatrixPType &xs, MatrixYType &ybar, MatrixYType &kbar) const { // std::cout << "second prediction step" << std::endl; assert(trained == true); MatrixKType Ks; covSparseLine(xs, x, Ks); // std::cout << "computed covsparseline" << std::endl; ybar = (Ks * y).array(); kbar = Ks.rowwise().sum().array(); } private: /* * @brief Compute Euclid distances between two vectors. * @param x input vector * @param z input vecotr * @return d distance matrix */ void dist(const MatrixXType &x, const MatrixXType &z, MatrixKType &d) const { d = MatrixKType::Zero(x.rows(), z.rows()); for (int i = 0; i < x.rows(); ++i) { d.row(i) = (z.rowwise() - x.row(i)).rowwise().norm(); } } // TODO: validate me void point_to_line_dist(const MatrixPType &x, const MatrixXType &z, MatrixKType &d) const { assert((x.cols() == 3) && (z.cols() == 6)); // std::cout << "made it" << std::endl; d = MatrixKType::Zero(x.rows(), z.rows()); float line_len; point3f p, p0, p1, v, w, line_vec, pnt_vec, nearest; float t; for (int i = 0; i < x.rows(); ++i) { p = point3f(x(i,0), x(i,1), x(i,2)); for (int j = 0; j < z.rows(); ++j) { p0 = point3f(z(j,0), z(j,1), z(j,2)); p1 = point3f(z(j,3), z(j,4), z(j,5)); line_vec = p1 - p0; line_len = line_vec.norm(); pnt_vec = p - p0; if (line_len < EPSILON) { d(i,j) = (p-p0).norm(); } else { double c1 = pnt_vec.dot(line_vec); double c2 = line_vec.dot(line_vec); if ( c1 <= 0) { d(i,j) = (p - p0).norm(); } else if (c2 <= c1) { d(i,j) = (p - p1).norm(); } else{ double b = c1 / c2; nearest = p0 + (line_vec*b); d(i,j) = (p - nearest).norm(); } } } } } /* * @brief Matern3 kernel. * @param x input vector * @param z input vector * @return Kxz covariance matrix */ void covMaterniso3(const MatrixXType &x, const MatrixXType &z, MatrixKType &Kxz) const { dist(1.73205 / ell * x, 1.73205 / ell * z, Kxz); Kxz = ((1 + Kxz.array()) * exp(-Kxz.array())).matrix() * sf2; } /* * @brief Sparse kernel. * @param x input vector * @param z input vector * @return Kxz covariance matrix * @ref A sparse covariance function for exact gaussian process inference in large datasets. */ void covSparse(const MatrixXType &x, const MatrixXType &z, MatrixKType &Kxz) const { dist(x / ell, z / ell, Kxz); Kxz = (((2.0f + (Kxz * 2.0f * 3.1415926f).array().cos()) * (1.0f - Kxz.array()) / 3.0f) + (Kxz * 2.0f * 3.1415926f).array().sin() / (2.0f * 3.1415926f)).matrix() * sf2; // Clean up for values with distance outside length scale // Possible because Kxz <= 0 when dist >= ell for (int i = 0; i < Kxz.rows(); ++i) { for (int j = 0; j < Kxz.cols(); ++j) if (Kxz(i,j) < 0.0) Kxz(i,j) = 0.0f; } } /* * @brief Sparse kernel. * @param x input vector * @param z input vector * @return Kxz covariance matrix * @ref A sparse covariance function for exact gaussian process inference in large datasets. */ void covSparseLine(const MatrixPType &x, const MatrixXType &z, MatrixKType &Kxz) const { point_to_line_dist(x, z, Kxz); // Check on this Kxz /= ell; Kxz = (((2.0f + (Kxz * 2.0f * 3.1415926f).array().cos()) * (1.0f - Kxz.array()) / 3.0f) + (Kxz * 2.0f * 3.1415926f).array().sin() / (2.0f * 3.1415926f)).matrix() * sf2; // Clean up for values with distance outside length scale // Possible because Kxz <= 0 when dist >= ell for (int i = 0; i < Kxz.rows(); ++i) { for (int j = 0; j < Kxz.cols(); ++j) if (Kxz(i,j) < 0.0) Kxz(i,j) = 0.0f; } } T sf2; // signal variance T ell; // length-scale MatrixXType x; // temporary storage of training data MatrixYType y; // temporary storage of training labels bool trained; // true if bgkinference stored training data }; typedef BGKLInference<3, float> BGKL3f; } #endif // LA3DM_BGKL_H
8,306
38.183962
101
h
la3dm
la3dm-master/include/bgkloctomap/bgkloctree.h
#ifndef LA3DM_BGKL_OCTREE_H #define LA3DM_BGKL_OCTREE_H #include <stack> #include <vector> #include "point3f.h" #include "bgkloctree_node.h" namespace la3dm { /// Hash key to index OcTree nodes given depth and the index in that layer. typedef int OcTreeHashKey; /// Convert from node to hask key. OcTreeHashKey node_to_hash_key(unsigned short depth, unsigned short index); /// Convert from hash key to node. void hash_key_to_node(OcTreeHashKey key, unsigned short &depth, unsigned short &index); /* * @brief A simple OcTree to organize occupancy data in one block. * * OcTree doesn't store positions of nodes in order to reduce memory usage. * The nodes in OcTrees are indexed by OcTreeHashKey which can be used to * retrieve positions later (See Block). * For the purpose of mapping, this OcTree has fixed depth which should be * set before using OcTrees. */ class OcTree { friend class BGKLOctoMap; public: OcTree(); ~OcTree(); OcTree(const OcTree &other); OcTree &operator=(const OcTree &other); /* * @brief Rursively pruning OcTreeNodes with the same state. * * Prune nodes by setting nodes to PRUNED. * Delete the layer if all nodes are pruned. */ bool prune(); /// @return true if this node is a leaf node. bool is_leaf(OcTreeHashKey key) const; /// @return true if this node is a leaf node. bool is_leaf(unsigned short depth, unsigned short index) const; /// @return true if this node exists and is not pruned. bool search(OcTreeHashKey key) const; /// @return Occupancy of the node (without checking if it exists!) OcTreeNode &operator[](OcTreeHashKey key) const; /// Leaf iterator for OcTrees: iterate all leaf nodes not pruned. class LeafIterator : public std::iterator<std::forward_iterator_tag, OcTreeNode> { public: LeafIterator() : tree(nullptr) { } LeafIterator(const OcTree *tree) : tree(tree != nullptr && tree->node_arr != nullptr ? tree : nullptr) { if (tree != nullptr) { stack.emplace(0, 0); stack.emplace(0, 0); ++(*this); } } LeafIterator(const LeafIterator &other) : tree(other.tree), stack(other.stack) { } LeafIterator &operator=(const LeafIterator &other) { tree = other.tree; stack = other.stack; return *this; } bool operator==(const LeafIterator &other) const { return (tree == other.tree) && (stack.size() == other.stack.size()) && (stack.size() == 0 || (stack.size() > 0 && (stack.top().depth == other.stack.top().depth) && (stack.top().index == other.stack.top().index))); } bool operator!=(const LeafIterator &other) const { return !(this->operator==(other)); } LeafIterator operator++(int) { LeafIterator result(*this); ++(*this); return result; } LeafIterator &operator++() { if (stack.empty()) { tree = nullptr; } else { stack.pop(); while (!stack.empty() && !tree->is_leaf(stack.top().depth, stack.top().index)) single_inc(); if (stack.empty()) tree = nullptr; } return *this; } inline OcTreeNode &operator*() const { return (*tree)[get_hash_key()]; } inline OcTreeNode &get_node() const { return operator*(); } inline OcTreeHashKey get_hash_key() const { OcTreeHashKey key = node_to_hash_key(stack.top().depth, stack.top().index); return key; } protected: void single_inc() { StackElement top(stack.top()); stack.pop(); for (int i = 0; i < 8; ++i) { stack.emplace(top.depth + 1, top.index * 8 + i); } } struct StackElement { unsigned short depth; unsigned short index; StackElement(unsigned short depth, unsigned short index) : depth(depth), index(index) { } }; const OcTree *tree; std::stack<StackElement, std::vector<StackElement> > stack; }; /// @return the beginning of leaf iterator inline LeafIterator begin_leaf() const { return LeafIterator(this); }; /// @return the end of leaf iterator inline LeafIterator end_leaf() const { return LeafIterator(nullptr); }; private: OcTreeNode **node_arr; static unsigned short max_depth; }; } #endif // LA3DM_BGKL_OCTREE_H
5,281
31.604938
98
h
la3dm
la3dm-master/include/bgkloctomap/bgkloctree_node.h
#ifndef LA3DM_BGKL_OCCUPANCY_H #define LA3DM_BGKL_OCCUPANCY_H #include <iostream> #include <fstream> namespace la3dm { /// Occupancy state: before pruning: FREE, OCCUPIED, UNKNOWN; after pruning: PRUNED enum class State : char { FREE, OCCUPIED, UNKNOWN, PRUNED }; /* * @brief Inference ouputs and occupancy state. * * Occupancy has member variables: m_A and m_B (kernel densities of positive * and negative class, respectively) and State. * Before using this class, set the static member variables first. */ class Occupancy { friend std::ostream &operator<<(std::ostream &os, const Occupancy &oc); friend std::ofstream &operator<<(std::ofstream &os, const Occupancy &oc); friend std::ifstream &operator>>(std::ifstream &is, Occupancy &oc); friend class BGKLOctoMap; public: /* * @brief Constructors and destructor. */ Occupancy() : m_A(Occupancy::prior_A), m_B(Occupancy::prior_B), state(State::UNKNOWN) { classified = false; } Occupancy(float A, float B); Occupancy(const Occupancy &other) : m_A(other.m_A), m_B(other.m_B), state(other.state) { } Occupancy &operator=(const Occupancy &other) { m_A = other.m_A; m_B = other.m_B; state = other.state; return *this; } ~Occupancy() { } /* * @brief Exact updates for nonparametric Bayesian kernel inference * @param ybar kernel density estimate of positive class (occupied) * @param kbar kernel density of negative class (unoccupied) */ void update(float ybar, float kbar); /// Get probability of occupancy. float get_prob() const; /// Get variance of occupancy (uncertainty) inline float get_var() const { return (m_A * m_B) / ( (m_A + m_B) * (m_A + m_B) * (m_A + m_B + 1.0f)); } /* * @brief Get occupancy state of the node. * @return occupancy state (see State). */ inline State get_state() const { return state; } /// Prune current node; set state to PRUNED. inline void prune() { state = State::PRUNED; } /// Only FREE and OCCUPIED nodes can be equal. inline bool operator==(const Occupancy &rhs) const { return this->state != State::UNKNOWN && this->state == rhs.state; } bool classified; private: float m_A; float m_B; State state; static float sf2; static float ell; // length-scale static float prior_A; // prior on alpha static float prior_B; // prior on beta static float free_thresh; // FREE occupancy threshold static float occupied_thresh; // OCCUPIED occupancy threshold static float var_thresh; }; typedef Occupancy OcTreeNode; } #endif // LA3DM_BGKL_OCCUPANCY_H
2,950
29.112245
117
h
la3dm
la3dm-master/include/bgklvoctomap/bgklvblock.h
#ifndef LA3DM_BGKLV_BLOCK_H #define LA3DM_BGKLV_BLOCK_H #include <unordered_map> #include <array> #include "point3f.h" #include "bgklvoctree_node.h" #include "bgklvoctree.h" namespace la3dm { /// Hask key to index Block given block's center. typedef int64_t BlockHashKey; /// Initialize Look-Up Table std::unordered_map<OcTreeHashKey, point3f> init_key_loc_map(float resolution, unsigned short max_depth); std::unordered_map<unsigned short, OcTreeHashKey> init_index_map(const std::unordered_map<OcTreeHashKey, point3f> &key_loc_map, unsigned short max_depth); /// Extended Block #ifdef PREDICT typedef std::array<BlockHashKey, 27> ExtendedBlock; #else typedef std::array<BlockHashKey, 7> ExtendedBlock; #endif /// Convert from block to hash key. BlockHashKey block_to_hash_key(point3f center); /// Convert from block to hash key. BlockHashKey block_to_hash_key(float x, float y, float z); /// Convert from hash key to block. point3f hash_key_to_block(BlockHashKey key); /// Get current block's extended block. ExtendedBlock get_extended_block(BlockHashKey key); /* * @brief Block is built on top of OcTree, providing the functions to locate nodes. * * Block stores the information needed to locate each OcTreeNode's position: * fixed resolution, fixed block_size, both of which must be initialized. * The localization is implemented using Loop-Up Table. */ class Block : public OcTree { friend BlockHashKey block_to_hash_key(point3f center); friend BlockHashKey block_to_hash_key(float x, float y, float z); friend point3f hash_key_to_block(BlockHashKey key); friend ExtendedBlock get_extended_block(BlockHashKey key); friend class BGKLVOctoMap; public: Block(); Block(point3f center); /// @return location of the OcTreeNode given OcTree's LeafIterator. inline point3f get_loc(const LeafIterator &it) const { return Block::key_loc_map[it.get_hash_key()] + center; } /// @return size of the OcTreeNode given OcTree's LeafIterator. inline float get_size(const LeafIterator &it) const { unsigned short depth; unsigned long index; hash_key_to_node(it.get_hash_key(), depth, index); return float(size / pow(2, depth)); } /// @return center of current Block. inline point3f get_center() const { return center; } /// @return min lim of current Block. inline point3f get_lim_min() const { return center - point3f(size / 2.0f, size / 2.0f, size / 2.0f); } /// @return max lim of current Block. inline point3f get_lim_max() const { return center + point3f(size / 2.0f, size / 2.0f, size / 2.0f); } /// @return ExtendedBlock of current Block. ExtendedBlock get_extended_block() const; OcTreeHashKey get_node(unsigned short x, unsigned short y, unsigned short z) const; point3f get_point(unsigned short x, unsigned short y, unsigned short z) const; void get_index(const point3f &p, unsigned short &x, unsigned short &y, unsigned short &z) const; OcTreeNode &search(float x, float y, float z) const; OcTreeNode &search(point3f p) const; private: // Loop-Up Table static std::unordered_map<OcTreeHashKey, point3f> key_loc_map; static std::unordered_map<unsigned short, OcTreeHashKey> index_map; static float resolution; static float size; static unsigned short cell_num; point3f center; }; } #endif // LA3DM_BGKLV_BLOCK_H
3,747
32.765766
131
h
la3dm
la3dm-master/include/bgklvoctomap/bgklvoctree.h
#ifndef LA3DM_BGKLV_OCTREE_H #define LA3DM_BGKLV_OCTREE_H #include <stack> #include <vector> #include "point3f.h" #include "bgklvoctree_node.h" namespace la3dm { /// Hash key to index OcTree nodes given depth and the index in that layer. typedef int OcTreeHashKey; /// Convert from node to hask key. OcTreeHashKey node_to_hash_key(unsigned short depth, unsigned long index); /// Convert from hash key to node. void hash_key_to_node(OcTreeHashKey key, unsigned short &depth, unsigned long &index); /* * @brief A simple OcTree to organize occupancy data in one block. * * OcTree doesn't store positions of nodes in order to reduce memory usage. * The nodes in OcTrees are indexed by OcTreeHashKey which can be used to * retrieve positions later (See Block). * For the purpose of mapping, this OcTree has fixed depth which should be * set before using OcTrees. */ class OcTree { friend class BGKLVOctoMap; public: OcTree(); ~OcTree(); OcTree(const OcTree &other); OcTree &operator=(const OcTree &other); /* * @brief Rursively pruning OcTreeNodes with the same state. * * Prune nodes by setting nodes to PRUNED. * Delete the layer if all nodes are pruned. */ bool prune(); /// @return true if this node is a leaf node. bool is_leaf(OcTreeHashKey key) const; /// @return true if this node is a leaf node. bool is_leaf(unsigned short depth, unsigned long index) const; /// @return true if this node exists and is not pruned. bool search(OcTreeHashKey key) const; /// @return Occupancy of the node (without checking if it exists!) OcTreeNode &operator[](OcTreeHashKey key) const; /// Leaf iterator for OcTrees: iterate all leaf nodes not pruned. class LeafIterator : public std::iterator<std::forward_iterator_tag, OcTreeNode> { public: LeafIterator() : tree(nullptr) { } LeafIterator(const OcTree *tree) : tree(tree != nullptr && tree->node_arr != nullptr ? tree : nullptr) { if (tree != nullptr) { stack.emplace(0, 0); stack.emplace(0, 0); ++(*this); } } LeafIterator(const LeafIterator &other) : tree(other.tree), stack(other.stack) { } LeafIterator &operator=(const LeafIterator &other) { tree = other.tree; stack = other.stack; return *this; } bool operator==(const LeafIterator &other) const { return (tree == other.tree) && (stack.size() == other.stack.size()) && (stack.size() == 0 || (stack.size() > 0 && (stack.top().depth == other.stack.top().depth) && (stack.top().index == other.stack.top().index))); } bool operator!=(const LeafIterator &other) const { return !(this->operator==(other)); } LeafIterator operator++(int) { LeafIterator result(*this); ++(*this); return result; } LeafIterator &operator++() { if (stack.empty()) { tree = nullptr; } else { stack.pop(); while (!stack.empty() && !tree->is_leaf(stack.top().depth, stack.top().index)) single_inc(); if (stack.empty()) tree = nullptr; } return *this; } inline OcTreeNode &operator*() const { return (*tree)[get_hash_key()]; } inline OcTreeNode &get_node() const { return operator*(); } inline OcTreeHashKey get_hash_key() const { OcTreeHashKey key = node_to_hash_key(stack.top().depth, stack.top().index); return key; } protected: void single_inc() { StackElement top(stack.top()); stack.pop(); for (int i = 0; i < 8; ++i) { stack.emplace(top.depth + 1, top.index * 8 + i); } } struct StackElement { unsigned short depth; unsigned long index; StackElement(unsigned short depth, unsigned long index) : depth(depth), index(index) { } }; const OcTree *tree; std::stack<StackElement, std::vector<StackElement> > stack; }; /// @return the beginning of leaf iterator inline LeafIterator begin_leaf() const { return LeafIterator(this); }; /// @return the end of leaf iterator inline LeafIterator end_leaf() const { return LeafIterator(nullptr); }; private: OcTreeNode **node_arr; static unsigned short max_depth; }; } #endif // LA3DM_BGKLV_OCTREE_H
5,281
31.604938
98
h
la3dm
la3dm-master/include/bgklvoctomap/bgklvoctree_node.h
#ifndef LA3DM_BGKLV_OCCUPANCY_H #define LA3DM_BGKLV_OCCUPANCY_H #include <iostream> #include <fstream> #include <cmath> namespace la3dm { /// Occupancy state: before pruning: FREE, OCCUPIED, UNKNOWN, UNCERTAIN; after pruning: PRUNED enum class State : char { FREE, OCCUPIED, UNKNOWN, UNCERTAIN, PRUNED }; /* * @brief Inference ouputs and occupancy state. * * Occupancy has member variables: m_A and m_B (kernel densities of positive * and negative class, respectively) and State. * Before using this class, set the static member variables first. */ class Occupancy { friend std::ostream &operator<<(std::ostream &os, const Occupancy &oc); friend std::ofstream &operator<<(std::ofstream &os, const Occupancy &oc); friend std::ifstream &operator>>(std::ifstream &is, Occupancy &oc); friend class BGKLVOctoMap; public: /* * @brief Constructors and destructor. */ Occupancy() : m_A(Occupancy::prior_A), m_B(Occupancy::prior_B), state(State::UNKNOWN) { classified = false; } Occupancy(float A, float B); Occupancy(const Occupancy &other) : m_A(other.m_A), m_B(other.m_B), state(other.state) { } Occupancy &operator=(const Occupancy &other) { m_A = other.m_A; m_B = other.m_B; state = other.state; return *this; } ~Occupancy() { } /* * @brief Exact updates for nonparametric Bayesian kernel inference * @param ybar kernel density estimate of positive class (occupied) * @param kbar kernel density of negative class (unoccupied) */ void update(float ybar, float kbar); /// Get probability of occupancy. float get_prob() const; /// Get variance of occupancy (uncertainty) float get_var() const; /* * @brief Get occupancy state of the node. * @return occupancy state (see State). */ inline State get_state() const { return state; } /// Prune current node; set state to PRUNED. inline void prune() { state = State::PRUNED; } /// Only FREE and OCCUPIED nodes can be equal. inline bool operator==(const Occupancy &rhs) const { return this->state != State::UNKNOWN && this->state != State::UNCERTAIN && this->state == rhs.state; } bool classified; private: float m_A; float m_B; State state; static float sf2; static float ell; // length-scale static float min_W; static float prior_A; // prior on alpha static float prior_B; // prior on beta static bool original_size; static float free_thresh; // FREE occupancy threshold static float occupied_thresh; // OCCUPIED occupancy threshold static float var_thresh; }; typedef Occupancy OcTreeNode; } #endif // LA3DM_BGKLV_OCCUPANCY_H
3,010
28.811881
117
h
la3dm
la3dm-master/include/bgkoctomap/bgkblock.h
#ifndef LA3DM_BGK_BLOCK_H #define LA3DM_BGK_BLOCK_H #include <unordered_map> #include <array> #include "point3f.h" #include "bgkoctree_node.h" #include "bgkoctree.h" namespace la3dm { /// Hask key to index Block given block's center. typedef int64_t BlockHashKey; /// Initialize Look-Up Table std::unordered_map<OcTreeHashKey, point3f> init_key_loc_map(float resolution, unsigned short max_depth); std::unordered_map<unsigned short, OcTreeHashKey> init_index_map(const std::unordered_map<OcTreeHashKey, point3f> &key_loc_map, unsigned short max_depth); /// Extended Block #ifdef PREDICT typedef std::array<BlockHashKey, 27> ExtendedBlock; #else typedef std::array<BlockHashKey, 7> ExtendedBlock; #endif /// Convert from block to hash key. BlockHashKey block_to_hash_key(point3f center); /// Convert from block to hash key. BlockHashKey block_to_hash_key(float x, float y, float z); /// Convert from hash key to block. point3f hash_key_to_block(BlockHashKey key); /// Get current block's extended block. ExtendedBlock get_extended_block(BlockHashKey key); /* * @brief Block is built on top of OcTree, providing the functions to locate nodes. * * Block stores the information needed to locate each OcTreeNode's position: * fixed resolution, fixed block_size, both of which must be initialized. * The localization is implemented using Loop-Up Table. */ class Block : public OcTree { friend BlockHashKey block_to_hash_key(point3f center); friend BlockHashKey block_to_hash_key(float x, float y, float z); friend point3f hash_key_to_block(BlockHashKey key); friend ExtendedBlock get_extended_block(BlockHashKey key); friend class BGKOctoMap; public: Block(); Block(point3f center); /// @return location of the OcTreeNode given OcTree's LeafIterator. inline point3f get_loc(const LeafIterator &it) const { return Block::key_loc_map[it.get_hash_key()] + center; } /// @return size of the OcTreeNode given OcTree's LeafIterator. inline float get_size(const LeafIterator &it) const { unsigned short depth, index; hash_key_to_node(it.get_hash_key(), depth, index); return float(size / pow(2, depth)); } /// @return center of current Block. inline point3f get_center() const { return center; } /// @return min lim of current Block. inline point3f get_lim_min() const { return center - point3f(size / 2.0f, size / 2.0f, size / 2.0f); } /// @return max lim of current Block. inline point3f get_lim_max() const { return center + point3f(size / 2.0f, size / 2.0f, size / 2.0f); } /// @return ExtendedBlock of current Block. ExtendedBlock get_extended_block() const; OcTreeHashKey get_node(unsigned short x, unsigned short y, unsigned short z) const; point3f get_point(unsigned short x, unsigned short y, unsigned short z) const; void get_index(const point3f &p, unsigned short &x, unsigned short &y, unsigned short &z) const; OcTreeNode &search(float x, float y, float z) const; OcTreeNode &search(point3f p) const; private: // Loop-Up Table static std::unordered_map<OcTreeHashKey, point3f> key_loc_map; static std::unordered_map<unsigned short, OcTreeHashKey> index_map; static float resolution; static float size; static unsigned short cell_num; point3f center; }; } #endif // LA3DM_BGK_BLOCK_H
3,709
32.727273
131
h
la3dm
la3dm-master/include/bgkoctomap/bgkinference.h
#ifndef LA3DM_BGK_H #define LA3DM_BGK_H namespace la3dm { /* * @brief Bayesian Generalized Kernel Inference on Bernoulli distribution * @param dim dimension of data (2, 3, etc.) * @param T data type (float, double, etc.) * @ref Nonparametric Bayesian inference on multivariate exponential families */ template<int dim, typename T> class BGKInference { public: /// Eigen matrix type for training and test data and kernel using MatrixXType = Eigen::Matrix<T, -1, dim, Eigen::RowMajor>; using MatrixKType = Eigen::Matrix<T, -1, -1, Eigen::RowMajor>; using MatrixDKType = Eigen::Matrix<T, -1, 1>; using MatrixYType = Eigen::Matrix<T, -1, 1>; BGKInference(T sf2, T ell) : sf2(sf2), ell(ell), trained(false) { } /* * @brief Fit BGK Model * @param x input vector (3N, row major) * @param y target vector (N) */ void train(const std::vector<T> &x, const std::vector<T> &y) { assert(x.size() % dim == 0 && (int) (x.size() / dim) == y.size()); MatrixXType _x = Eigen::Map<const MatrixXType>(x.data(), x.size() / dim, dim); MatrixYType _y = Eigen::Map<const MatrixYType>(y.data(), y.size(), 1); train(_x, _y); } /* * @brief Fit BGK Model * @param x input matrix (NX3) * @param y target matrix (NX1) */ void train(const MatrixXType &x, const MatrixYType &y) { this->x = MatrixXType(x); this->y = MatrixYType(y); trained = true; } /* * @brief Predict with BGK Model * @param xs input vector (3M, row major) * @param ybar positive class kernel density estimate (\bar{y}) * @param kbar kernel density estimate (\bar{k}) */ void predict(const std::vector<T> &xs, std::vector<T> &ybar, std::vector<T> &kbar) const { assert(xs.size() % dim == 0); MatrixXType _xs = Eigen::Map<const MatrixXType>(xs.data(), xs.size() / dim, dim); MatrixYType _ybar, _kbar; predict(_xs, _ybar, _kbar); ybar.resize(_ybar.rows()); kbar.resize(_kbar.rows()); for (int r = 0; r < _ybar.rows(); ++r) { ybar[r] = _ybar(r, 0); kbar[r] = _kbar(r, 0); } } /* * @brief Predict with nonparametric Bayesian generalized kernel inference * @param xs input vector (M x 3) * @param ybar positive class kernel density estimate (M x 1) * @param kbar kernel density estimate (M x 1) */ void predict(const MatrixXType &xs, MatrixYType &ybar, MatrixYType &kbar) const { assert(trained == true); MatrixKType Ks; covSparse(xs, x, Ks); ybar = (Ks * y).array(); kbar = Ks.rowwise().sum().array(); } private: /* * @brief Compute Euclid distances between two vectors. * @param x input vector * @param z input vecotr * @return d distance matrix */ void dist(const MatrixXType &x, const MatrixXType &z, MatrixKType &d) const { d = MatrixKType::Zero(x.rows(), z.rows()); for (int i = 0; i < x.rows(); ++i) { d.row(i) = (z.rowwise() - x.row(i)).rowwise().norm(); } } /* * @brief Matern3 kernel. * @param x input vector * @param z input vector * @return Kxz covariance matrix */ void covMaterniso3(const MatrixXType &x, const MatrixXType &z, MatrixKType &Kxz) const { dist(1.73205 / ell * x, 1.73205 / ell * z, Kxz); Kxz = ((1 + Kxz.array()) * exp(-Kxz.array())).matrix() * sf2; } /* * @brief Sparse kernel. * @param x input vector * @param z input vector * @return Kxz covariance matrix * @ref A sparse covariance function for exact gaussian process inference in large datasets. */ void covSparse(const MatrixXType &x, const MatrixXType &z, MatrixKType &Kxz) const { dist(x / ell, z / ell, Kxz); Kxz = (((2.0f + (Kxz * 2.0f * 3.1415926f).array().cos()) * (1.0f - Kxz.array()) / 3.0f) + (Kxz * 2.0f * 3.1415926f).array().sin() / (2.0f * 3.1415926f)).matrix() * sf2; // Clean up for values with distance outside length scale // Possible because Kxz <= 0 when dist >= ell for (int i = 0; i < Kxz.rows(); ++i) { for (int j = 0; j < Kxz.cols(); ++j) if (Kxz(i,j) < 0.0) Kxz(i,j) = 0.0f; } } T sf2; // signal variance T ell; // length-scale MatrixXType x; // temporary storage of training data MatrixYType y; // temporary storage of training labels bool trained; // true if bgkinference stored training data }; typedef BGKInference<3, float> BGK3f; } #endif // LA3DM_BGK_H
5,140
35.460993
101
h
la3dm
la3dm-master/include/bgkoctomap/bgkoctomap.h
#ifndef LA3DM_BGK_OCTOMAP_H #define LA3DM_BGK_OCTOMAP_H #include <unordered_map> #include <vector> #include <pcl/point_cloud.h> #include <pcl/point_types.h> #include "rtree.h" #include "bgkblock.h" #include "bgkoctree_node.h" namespace la3dm { /// PCL PointCloud types as input typedef pcl::PointXYZ PCLPointType; typedef pcl::PointCloud<PCLPointType> PCLPointCloud; /* * @brief BGKOctoMap * * Bayesian Generalized Kernel Inference for Occupancy Map Prediction * The space is partitioned by Blocks in which OcTrees with fixed * depth are rooted. Occupancy values in one Block is predicted by * its ExtendedBlock via Bayesian generalized kernel inference. */ class BGKOctoMap { public: /// Types used internally typedef std::vector<point3f> PointCloud; typedef std::pair<point3f, float> GPPointType; typedef std::vector<GPPointType> GPPointCloud; typedef RTree<GPPointType *, float, 3, float> MyRTree; public: BGKOctoMap(); /* * @param resolution (default 0.1m) * @param block_depth maximum depth of OcTree (default 4) * @param sf2 signal variance in GPs (default 1.0) * @param ell length-scale in GPs (default 1.0) * @param noise noise variance in GPs (default 0.01) * @param l length-scale in logistic regression function (default 100) * @param min_var minimum variance in Occupancy (default 0.001) * @param max_var maximum variance in Occupancy (default 1000) * @param max_known_var maximum variance for Occuapncy to be classified as KNOWN State (default 0.02) * @param free_thresh free threshold for Occupancy probability (default 0.3) * @param occupied_thresh occupied threshold for Occupancy probability (default 0.7) */ BGKOctoMap(float resolution, unsigned short block_depth, float sf2, float ell, float free_thresh, float occupied_thresh, float var_thresh, float prior_A, float prior_B); ~BGKOctoMap(); /// Set resolution. void set_resolution(float resolution); /// Set block max depth. void set_block_depth(unsigned short max_depth); /// Get resolution. inline float get_resolution() const { return resolution; } /// Get block max depth. inline float get_block_depth() const { return block_depth; } /* * @brief Insert PCL PointCloud into BGKOctoMaps. * @param cloud one scan in PCLPointCloud format * @param origin sensor origin in the scan * @param ds_resolution downsampling resolution for PCL VoxelGrid filtering (-1 if no downsampling) * @param free_res resolution for sampling free training points along sensor beams (default 2.0) * @param max_range maximum range for beams to be considered as valid measurements (-1 if no limitation) */ void insert_pointcloud(const PCLPointCloud &cloud, const point3f &origin, float ds_resolution, float free_res = 2.0f, float max_range = -1); void insert_training_data(const GPPointCloud &cloud); /// Get bounding box of the map. void get_bbox(point3f &lim_min, point3f &lim_max) const; class RayCaster { public: RayCaster(const BGKOctoMap *map, const point3f &start, const point3f &end) : map(map) { assert(map != nullptr); _block_key = block_to_hash_key(start); block = map->search(_block_key); lim = static_cast<unsigned short>(pow(2, map->block_depth - 1)); if (block != nullptr) { block->get_index(start, x, y, z); block_lim = block->get_center(); block_size = block->size; current_p = start; resolution = map->resolution; int x0 = static_cast<int>((start.x() / resolution)); int y0 = static_cast<int>((start.y() / resolution)); int z0 = static_cast<int>((start.z() / resolution)); int x1 = static_cast<int>((end.x() / resolution)); int y1 = static_cast<int>((end.y() / resolution)); int z1 = static_cast<int>((end.z() / resolution)); dx = abs(x1 - x0); dy = abs(y1 - y0); dz = abs(z1 - z0); n = 1 + dx + dy + dz; x_inc = x1 > x0 ? 1 : (x1 == x0 ? 0 : -1); y_inc = y1 > y0 ? 1 : (y1 == y0 ? 0 : -1); z_inc = z1 > z0 ? 1 : (z1 == z0 ? 0 : -1); xy_error = dx - dy; xz_error = dx - dz; yz_error = dy - dz; dx *= 2; dy *= 2; dz *= 2; } else { n = 0; } } inline bool end() const { return n <= 0; } bool next(point3f &p, OcTreeNode &node, BlockHashKey &block_key, OcTreeHashKey &node_key) { assert(!end()); bool valid = false; unsigned short index = x + y * lim + z * lim * lim; node_key = Block::index_map[index]; block_key = _block_key; if (block != nullptr) { valid = true; node = (*block)[node_key]; current_p = block->get_point(x, y, z); p = current_p; } else { p = current_p; } if (xy_error > 0 && xz_error > 0) { x += x_inc; current_p.x() += x_inc * resolution; xy_error -= dy; xz_error -= dz; if (x >= lim || x < 0) { block_lim.x() += x_inc * block_size; _block_key = block_to_hash_key(block_lim); block = map->search(_block_key); x = x_inc > 0 ? 0 : lim - 1; } } else if (xy_error < 0 && yz_error > 0) { y += y_inc; current_p.y() += y_inc * resolution; xy_error += dx; yz_error -= dz; if (y >= lim || y < 0) { block_lim.y() += y_inc * block_size; _block_key = block_to_hash_key(block_lim); block = map->search(_block_key); y = y_inc > 0 ? 0 : lim - 1; } } else if (yz_error < 0 && xz_error < 0) { z += z_inc; current_p.z() += z_inc * resolution; xz_error += dx; yz_error += dy; if (z >= lim || z < 0) { block_lim.z() += z_inc * block_size; _block_key = block_to_hash_key(block_lim); block = map->search(_block_key); z = z_inc > 0 ? 0 : lim - 1; } } else if (xy_error == 0) { x += x_inc; y += y_inc; n -= 2; current_p.x() += x_inc * resolution; current_p.y() += y_inc * resolution; if (x >= lim || x < 0) { block_lim.x() += x_inc * block_size; _block_key = block_to_hash_key(block_lim); block = map->search(_block_key); x = x_inc > 0 ? 0 : lim - 1; } if (y >= lim || y < 0) { block_lim.y() += y_inc * block_size; _block_key = block_to_hash_key(block_lim); block = map->search(_block_key); y = y_inc > 0 ? 0 : lim - 1; } } n--; return valid; } private: const BGKOctoMap *map; Block *block; point3f block_lim; float block_size, resolution; int dx, dy, dz, error, n; int x_inc, y_inc, z_inc, xy_error, xz_error, yz_error; unsigned short index, x, y, z, lim; BlockHashKey _block_key; point3f current_p; }; /// LeafIterator for iterating all leaf nodes in blocks class LeafIterator : public std::iterator<std::forward_iterator_tag, OcTreeNode> { public: LeafIterator(const BGKOctoMap *map) { assert(map != nullptr); block_it = map->block_arr.cbegin(); end_block = map->block_arr.cend(); if (map->block_arr.size() > 0) { leaf_it = block_it->second->begin_leaf(); end_leaf = block_it->second->end_leaf(); } else { leaf_it = OcTree::LeafIterator(); end_leaf = OcTree::LeafIterator(); } } // just for initializing end iterator LeafIterator(std::unordered_map<BlockHashKey, Block *>::const_iterator block_it, OcTree::LeafIterator leaf_it) : block_it(block_it), leaf_it(leaf_it), end_block(block_it), end_leaf(leaf_it) { } bool operator==(const LeafIterator &other) { return (block_it == other.block_it) && (leaf_it == other.leaf_it); } bool operator!=(const LeafIterator &other) { return !(this->operator==(other)); } LeafIterator operator++(int) { LeafIterator result(*this); ++(*this); return result; } LeafIterator &operator++() { ++leaf_it; if (leaf_it == end_leaf) { ++block_it; if (block_it != end_block) { leaf_it = block_it->second->begin_leaf(); end_leaf = block_it->second->end_leaf(); } } return *this; } OcTreeNode &operator*() const { return *leaf_it; } std::vector<point3f> get_pruned_locs() const { std::vector<point3f> pruned_locs; point3f center = get_loc(); float size = get_size(); float x0 = center.x() - size * 0.5 + Block::resolution * 0.5; float y0 = center.y() - size * 0.5 + Block::resolution * 0.5; float z0 = center.z() - size * 0.5 + Block::resolution * 0.5; float x1 = center.x() + size * 0.5; float y1 = center.y() + size * 0.5; float z1 = center.z() + size * 0.5; for (float x = x0; x < x1; x += Block::resolution) { for (float y = y0; y < y1; y += Block::resolution) { for (float z = z0; z < z1; z += Block::resolution) { pruned_locs.emplace_back(x, y, z); } } } return pruned_locs; } inline OcTreeNode &get_node() const { return operator*(); } inline point3f get_loc() const { return block_it->second->get_loc(leaf_it); } inline float get_size() const { return block_it->second->get_size(leaf_it); } private: std::unordered_map<BlockHashKey, Block *>::const_iterator block_it; std::unordered_map<BlockHashKey, Block *>::const_iterator end_block; OcTree::LeafIterator leaf_it; OcTree::LeafIterator end_leaf; }; /// @return the beginning of leaf iterator inline LeafIterator begin_leaf() const { return LeafIterator(this); } /// @return the end of leaf iterator inline LeafIterator end_leaf() const { return LeafIterator(block_arr.cend(), OcTree::LeafIterator()); } OcTreeNode search(point3f p) const; OcTreeNode search(float x, float y, float z) const; Block *search(BlockHashKey key) const; inline float get_block_size() const { return block_size; } private: /// @return true if point is inside a bounding box given min and max limits. inline bool gp_point_in_bbox(const GPPointType &p, const point3f &lim_min, const point3f &lim_max) const { return (p.first.x() > lim_min.x() && p.first.x() < lim_max.x() && p.first.y() > lim_min.y() && p.first.y() < lim_max.y() && p.first.z() > lim_min.z() && p.first.z() < lim_max.z()); } /// Get the bounding box of a pointcloud. void bbox(const GPPointCloud &cloud, point3f &lim_min, point3f &lim_max) const; /// Get all block indices inside a bounding box. void get_blocks_in_bbox(const point3f &lim_min, const point3f &lim_max, std::vector<BlockHashKey> &blocks) const; /// Get all points inside a bounding box assuming pointcloud has been inserted in rtree before. int get_gp_points_in_bbox(const point3f &lim_min, const point3f &lim_max, GPPointCloud &out); /// @return true if point exists inside a bounding box assuming pointcloud has been inserted in rtree before. int has_gp_points_in_bbox(const point3f &lim_min, const point3f &lim_max); /// Get all points inside a bounding box (block) assuming pointcloud has been inserted in rtree before. int get_gp_points_in_bbox(const BlockHashKey &key, GPPointCloud &out); /// @return true if point exists inside a bounding box (block) assuming pointcloud has been inserted in rtree before. int has_gp_points_in_bbox(const BlockHashKey &key); /// Get all points inside an extended block assuming pointcloud has been inserted in rtree before. int get_gp_points_in_bbox(const ExtendedBlock &block, GPPointCloud &out); /// @return true if point exists inside an extended block assuming pointcloud has been inserted in rtree before. int has_gp_points_in_bbox(const ExtendedBlock &block); /// RTree callback function static bool count_callback(GPPointType *p, void *arg); /// RTree callback function static bool search_callback(GPPointType *p, void *arg); /// Downsample PCLPointCloud using PCL VoxelGrid Filtering. void downsample(const PCLPointCloud &in, PCLPointCloud &out, float ds_resolution) const; /// Sample free training points along sensor beams. void beam_sample(const point3f &hits, const point3f &origin, PointCloud &frees, float free_resolution) const; /// Get training data from one sensor scan. void get_training_data(const PCLPointCloud &cloud, const point3f &origin, float ds_resolution, float free_resolution, float max_range, GPPointCloud &xy) const; float resolution; float block_size; unsigned short block_depth; std::unordered_map<BlockHashKey, Block *> block_arr; MyRTree rtree; }; } #endif // LA3DM_BGKOCTOMAP_H
15,848
40.273438
125
h
la3dm
la3dm-master/include/bgkoctomap/bgkoctree.h
#ifndef LA3DM_BGK_OCTREE_H #define LA3DM_BGK_OCTREE_H #include <stack> #include <vector> #include "point3f.h" #include "bgkoctree_node.h" namespace la3dm { /// Hash key to index OcTree nodes given depth and the index in that layer. typedef int OcTreeHashKey; /// Convert from node to hask key. OcTreeHashKey node_to_hash_key(unsigned short depth, unsigned short index); /// Convert from hash key to node. void hash_key_to_node(OcTreeHashKey key, unsigned short &depth, unsigned short &index); /* * @brief A simple OcTree to organize occupancy data in one block. * * OcTree doesn't store positions of nodes in order to reduce memory usage. * The nodes in OcTrees are indexed by OcTreeHashKey which can be used to * retrieve positions later (See Block). * For the purpose of mapping, this OcTree has fixed depth which should be * set before using OcTrees. */ class OcTree { friend class BGKOctoMap; public: OcTree(); ~OcTree(); OcTree(const OcTree &other); OcTree &operator=(const OcTree &other); /* * @brief Rursively pruning OcTreeNodes with the same state. * * Prune nodes by setting nodes to PRUNED. * Delete the layer if all nodes are pruned. */ bool prune(); /// @return true if this node is a leaf node. bool is_leaf(OcTreeHashKey key) const; /// @return true if this node is a leaf node. bool is_leaf(unsigned short depth, unsigned short index) const; /// @return true if this node exists and is not pruned. bool search(OcTreeHashKey key) const; /// @return Occupancy of the node (without checking if it exists!) OcTreeNode &operator[](OcTreeHashKey key) const; /// Leaf iterator for OcTrees: iterate all leaf nodes not pruned. class LeafIterator : public std::iterator<std::forward_iterator_tag, OcTreeNode> { public: LeafIterator() : tree(nullptr) { } LeafIterator(const OcTree *tree) : tree(tree != nullptr && tree->node_arr != nullptr ? tree : nullptr) { if (tree != nullptr) { stack.emplace(0, 0); stack.emplace(0, 0); ++(*this); } } LeafIterator(const LeafIterator &other) : tree(other.tree), stack(other.stack) { } LeafIterator &operator=(const LeafIterator &other) { tree = other.tree; stack = other.stack; return *this; } bool operator==(const LeafIterator &other) const { return (tree == other.tree) && (stack.size() == other.stack.size()) && (stack.size() == 0 || (stack.size() > 0 && (stack.top().depth == other.stack.top().depth) && (stack.top().index == other.stack.top().index))); } bool operator!=(const LeafIterator &other) const { return !(this->operator==(other)); } LeafIterator operator++(int) { LeafIterator result(*this); ++(*this); return result; } LeafIterator &operator++() { if (stack.empty()) { tree = nullptr; } else { stack.pop(); while (!stack.empty() && !tree->is_leaf(stack.top().depth, stack.top().index)) single_inc(); if (stack.empty()) tree = nullptr; } return *this; } inline OcTreeNode &operator*() const { return (*tree)[get_hash_key()]; } inline OcTreeNode &get_node() const { return operator*(); } inline OcTreeHashKey get_hash_key() const { OcTreeHashKey key = node_to_hash_key(stack.top().depth, stack.top().index); return key; } protected: void single_inc() { StackElement top(stack.top()); stack.pop(); for (int i = 0; i < 8; ++i) { stack.emplace(top.depth + 1, top.index * 8 + i); } } struct StackElement { unsigned short depth; unsigned short index; StackElement(unsigned short depth, unsigned short index) : depth(depth), index(index) { } }; const OcTree *tree; std::stack<StackElement, std::vector<StackElement> > stack; }; /// @return the beginning of leaf iterator inline LeafIterator begin_leaf() const { return LeafIterator(this); }; /// @return the end of leaf iterator inline LeafIterator end_leaf() const { return LeafIterator(nullptr); }; private: OcTreeNode **node_arr; static unsigned short max_depth; }; } #endif // LA3DM_BGK_OCTREE_H
5,276
31.574074
98
h
la3dm
la3dm-master/include/bgkoctomap/bgkoctree_node.h
#ifndef LA3DM_BGK_OCCUPANCY_H #define LA3DM_BGK_OCCUPANCY_H #include <iostream> #include <fstream> namespace la3dm { /// Occupancy state: before pruning: FREE, OCCUPIED, UNKNOWN; after pruning: PRUNED enum class State : char { FREE, OCCUPIED, UNKNOWN, PRUNED }; /* * @brief Inference ouputs and occupancy state. * * Occupancy has member variables: m_A and m_B (kernel densities of positive * and negative class, respectively) and State. * Before using this class, set the static member variables first. */ class Occupancy { friend std::ostream &operator<<(std::ostream &os, const Occupancy &oc); friend std::ofstream &operator<<(std::ofstream &os, const Occupancy &oc); friend std::ifstream &operator>>(std::ifstream &is, Occupancy &oc); friend class BGKOctoMap; public: /* * @brief Constructors and destructor. */ Occupancy() : m_A(Occupancy::prior_A), m_B(Occupancy::prior_B), state(State::UNKNOWN) { classified = false; } Occupancy(float A, float B); Occupancy(const Occupancy &other) : m_A(other.m_A), m_B(other.m_B), state(other.state) { } Occupancy &operator=(const Occupancy &other) { m_A = other.m_A; m_B = other.m_B; state = other.state; return *this; } ~Occupancy() { } /* * @brief Exact updates for nonparametric Bayesian kernel inference * @param ybar kernel density estimate of positive class (occupied) * @param kbar kernel density of negative class (unoccupied) */ void update(float ybar, float kbar); /// Get probability of occupancy. float get_prob() const; /// Get variance of occupancy (uncertainty) inline float get_var() const { return (m_A * m_B) / ( (m_A + m_B) * (m_A + m_B) * (m_A + m_B + 1.0f)); } /* * @brief Get occupancy state of the node. * @return occupancy state (see State). */ inline State get_state() const { return state; } /// Prune current node; set state to PRUNED. inline void prune() { state = State::PRUNED; } /// Only FREE and OCCUPIED nodes can be equal. inline bool operator==(const Occupancy &rhs) const { return this->state != State::UNKNOWN && this->state == rhs.state; } bool classified; private: float m_A; float m_B; State state; static float sf2; static float ell; // length-scale static float prior_A; // prior on alpha static float prior_B; // prior on beta static float free_thresh; // FREE occupancy threshold static float occupied_thresh; // OCCUPIED occupancy threshold static float var_thresh; }; typedef Occupancy OcTreeNode; } #endif // LA3DM_BGK_OCCUPANCY_H
2,946
29.071429
117
h
la3dm
la3dm-master/include/common/markerarray_pub.h
#include <pcl_ros/point_cloud.h> #include <geometry_msgs/Point.h> #include <visualization_msgs/MarkerArray.h> #include <visualization_msgs/Marker.h> #include <std_msgs/ColorRGBA.h> #include <cmath> #include <string> namespace la3dm { std_msgs::ColorRGBA heightMapColor(double h) { std_msgs::ColorRGBA color; color.a = 1.0; // blend over HSV-values (more colors) double s = 1.0; double v = 1.0; h -= floor(h); h *= 6; int i; double m, n, f; i = floor(h); f = h - i; if (!(i & 1)) f = 1 - f; // if i is even m = v * (1 - s); n = v * (1 - s * f); switch (i) { case 6: case 0: color.r = v; color.g = n; color.b = m; break; case 1: color.r = n; color.g = v; color.b = m; break; case 2: color.r = m; color.g = v; color.b = n; break; case 3: color.r = m; color.g = n; color.b = v; break; case 4: color.r = n; color.g = m; color.b = v; break; case 5: color.r = v; color.g = m; color.b = n; break; default: color.r = 1; color.g = 0.5; color.b = 0.5; break; } return color; } class MarkerArrayPub { typedef pcl::PointXYZ PointType; typedef pcl::PointCloud<PointType> PointCloud; public: MarkerArrayPub(ros::NodeHandle nh, std::string topic, float resolution) : nh(nh), msg(new visualization_msgs::MarkerArray), topic(topic), resolution(resolution), markerarray_frame_id("map") { pub = nh.advertise<visualization_msgs::MarkerArray>(topic, 1, true); msg->markers.resize(10); for (int i = 0; i < 10; ++i) { msg->markers[i].header.frame_id = markerarray_frame_id; msg->markers[i].ns = "map"; msg->markers[i].id = i; msg->markers[i].type = visualization_msgs::Marker::CUBE_LIST; msg->markers[i].scale.x = resolution * pow(2, i); msg->markers[i].scale.y = resolution * pow(2, i); msg->markers[i].scale.z = resolution * pow(2, i); std_msgs::ColorRGBA color; color.r = 0.0; color.g = 0.0; color.b = 1.0; color.a = 1.0; msg->markers[i].color = color; } } void insert_point3d(float x, float y, float z, float min_z, float max_z, float size) { geometry_msgs::Point center; center.x = x; center.y = y; center.z = z; int depth = 0; if (size > 0) depth = (int) log2(size /resolution); msg->markers[depth].points.push_back(center); if (min_z < max_z) { double h = (1.0 - std::min(std::max((z - min_z) / (max_z - min_z), 0.0f), 1.0f)) * 0.8; msg->markers[depth].colors.push_back(heightMapColor(h)); } } void insert_point3d(float x, float y, float z, float min_z, float max_z, float size, float prob) { geometry_msgs::Point center; center.x = x; center.y = y; center.z = z; int depth = 0; if (size > 0) depth = (int) log2(size / resolution); msg->markers[depth].points.push_back(center); std_msgs::ColorRGBA color; color.a = 1.0; if(prob < 0.5){ color.r = 0.8; color.g = 0.8; color.b = 0.8; } else{ color = heightMapColor(std::min(2.0-2.0*prob, 0.6)); } msg->markers[depth].colors.push_back(color); } void insert_point3d(float x, float y, float z, float min_z, float max_z) { insert_point3d(x, y, z, min_z, max_z, -1.0f); } void insert_point3d(float x, float y, float z) { insert_point3d(x, y, z, 1.0f, 0.0f, -1.0f); } void insert_color_point3d(float x, float y, float z, double min_v, double max_v, double v) { geometry_msgs::Point center; center.x = x; center.y = y; center.z = z; int depth = 0; msg->markers[depth].points.push_back(center); double h = (1.0 - std::min(std::max((v - min_v) / (max_v - min_v), 0.0), 1.0)) * 0.8; msg->markers[depth].colors.push_back(heightMapColor(h)); } void clear() { for (int i = 0; i < 10; ++i) { msg->markers[i].points.clear(); msg->markers[i].colors.clear(); } } void publish() const { msg->markers[0].header.stamp = ros::Time::now(); pub.publish(*msg); } private: ros::NodeHandle nh; ros::Publisher pub; visualization_msgs::MarkerArray::Ptr msg; std::string markerarray_frame_id; std::string topic; float resolution; }; }
5,869
29.572917
123
h
la3dm
la3dm-master/include/common/point3f.h
#ifndef LA3DM_VECTOR3_H #define LA3DM_VECTOR3_H #include <iostream> #include <math.h> namespace la3dm { /*! * \brief This class represents a three-dimensional vector * * The three-dimensional vector can be used to represent a * translation in three-dimensional space or to represent the * attitude of an object using Euler angle. */ class Vector3 { public: /*! * \brief Default constructor */ Vector3() { data[0] = data[1] = data[2] = 0.0; } /*! * \brief Copy constructor * * @param other a vector of dimension 3 */ Vector3(const Vector3 &other) { data[0] = other(0); data[1] = other(1); data[2] = other(2); } /*! * \brief Constructor * * Constructs a three-dimensional vector from * three single values x, y, z or roll, pitch, yaw */ Vector3(float x, float y, float z) { data[0] = x; data[1] = y; data[2] = z; } /* inline Eigen3::Vector3f getVector3f() const { return Eigen3::Vector3f(data[0], data[1], data[2]) ; } */ /* inline Eigen3::Vector4f& getVector4f() { return data; } */ /* inline Eigen3::Vector4f getVector4f() const { return data; } */ /*! * \brief Assignment operator * * @param other a vector of dimension 3 */ inline Vector3 &operator=(const Vector3 &other) { data[0] = other(0); data[1] = other(1); data[2] = other(2); return *this; } /*! * \brief Three-dimensional vector (cross) product * * Calculates the tree-dimensional cross product, which * represents the vector orthogonal to the plane defined * by this and other. * @return this x other */ inline Vector3 cross(const Vector3 &other) const { //return (data.start<3> ().cross (other.data.start<3> ())); // \note should this be renamed? return Vector3(y() * other.z() - z() * other.y(), z() * other.x() - x() * other.z(), x() * other.y() - y() * other.x()); } /// dot product inline double dot(const Vector3 &other) const { return x() * other.x() + y() * other.y() + z() * other.z(); } inline const float &operator()(unsigned int i) const { return data[i]; } inline float &operator()(unsigned int i) { return data[i]; } inline float &x() { return operator()(0); } inline float &y() { return operator()(1); } inline float &z() { return operator()(2); } inline const float &x() const { return operator()(0); } inline const float &y() const { return operator()(1); } inline const float &z() const { return operator()(2); } inline float &roll() { return operator()(0); } inline float &pitch() { return operator()(1); } inline float &yaw() { return operator()(2); } inline const float &roll() const { return operator()(0); } inline const float &pitch() const { return operator()(1); } inline const float &yaw() const { return operator()(2); } inline Vector3 operator-() const { Vector3 result; result(0) = -data[0]; result(1) = -data[1]; result(2) = -data[2]; return result; } inline Vector3 operator+(const Vector3 &other) const { Vector3 result(*this); result(0) += other(0); result(1) += other(1); result(2) += other(2); return result; } inline Vector3 operator*(float x) const { Vector3 result(*this); result(0) *= x; result(1) *= x; result(2) *= x; return result; } inline Vector3 operator-(const Vector3 &other) const { Vector3 result(*this); result(0) -= other(0); result(1) -= other(1); result(2) -= other(2); return result; } inline void operator+=(const Vector3 &other) { data[0] += other(0); data[1] += other(1); data[2] += other(2); } inline void operator-=(const Vector3 &other) { data[0] -= other(0); data[1] -= other(1); data[2] -= other(2); } inline void operator/=(float x) { data[0] /= x; data[1] /= x; data[2] /= x; } inline void operator*=(float x) { data[0] *= x; data[1] *= x; data[2] *= x; } inline bool operator==(const Vector3 &other) const { for (unsigned int i = 0; i < 3; i++) { if (operator()(i) != other(i)) return false; } return true; } /// @return length of the vector ("L2 norm") inline double norm() const { return sqrt(norm_sq()); } /// @return squared length ("L2 norm") of the vector inline double norm_sq() const { return (x() * x() + y() * y() + z() * z()); } /// normalizes this vector, so that it has norm=1.0 inline Vector3 &normalize() { double len = norm(); if (len > 0) *this /= (float) len; return *this; } /// @return normalized vector, this one remains unchanged inline Vector3 normalized() const { Vector3 result(*this); result.normalize(); return result; } inline double angleTo(const Vector3 &other) const { double dot_prod = this->dot(other); double len1 = this->norm(); double len2 = other.norm(); return acos(dot_prod / (len1 * len2)); } inline double distance(const Vector3 &other) const { double dist_x = x() - other.x(); double dist_y = y() - other.y(); double dist_z = z() - other.z(); return sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z); } inline double distanceXY(const Vector3 &other) const { double dist_x = x() - other.x(); double dist_y = y() - other.y(); return sqrt(dist_x * dist_x + dist_y * dist_y); } Vector3 &rotate_IP(double roll, double pitch, double yaw); // void read (unsigned char * src, unsigned int size); std::istream &read(std::istream &s); std::ostream &write(std::ostream &s) const; std::istream &readBinary(std::istream &s); std::ostream &writeBinary(std::ostream &s) const; protected: float data[3]; }; //! user friendly output in format (x y z) std::ostream &operator<<(std::ostream &out, la3dm::Vector3 const &v); typedef Vector3 point3f; } #endif // LA3DM_VECTOR3_H
7,471
25.974729
114
h
la3dm
la3dm-master/include/gpoctomap/gpblock.h
#ifndef LA3DM_GP_BLOCK_H #define LA3DM_GP_BLOCK_H #include <unordered_map> #include <array> #include "point3f.h" #include "gpoctree_node.h" #include "gpoctree.h" namespace la3dm { /// Hask key to index Block given block's center. typedef int64_t BlockHashKey; /// Initialize Look-Up Table std::unordered_map<OcTreeHashKey, point3f> init_key_loc_map(float resolution, unsigned short max_depth); std::unordered_map<unsigned short, OcTreeHashKey> init_index_map(const std::unordered_map<OcTreeHashKey, point3f> &key_loc_map, unsigned short max_depth); /// Extended Block #ifdef PREDICT typedef std::array<BlockHashKey, 27> ExtendedBlock; #else typedef std::array<BlockHashKey, 7> ExtendedBlock; #endif /// Convert from block to hash key. BlockHashKey block_to_hash_key(point3f center); /// Convert from block to hash key. BlockHashKey block_to_hash_key(float x, float y, float z); /// Convert from hash key to block. point3f hash_key_to_block(BlockHashKey key); /// Get current block's extended block. ExtendedBlock get_extended_block(BlockHashKey key); /* * @brief Block is built on top of OcTree, providing the functions to locate nodes. * * Block stores the information needed to locate each OcTreeNode's position: * fixed resolution, fixed block_size, both of which must be initialized. * The localization is implemented using Loop-Up Table. */ class Block : public OcTree { friend BlockHashKey block_to_hash_key(point3f center); friend BlockHashKey block_to_hash_key(float x, float y, float z); friend point3f hash_key_to_block(BlockHashKey key); friend ExtendedBlock get_extended_block(BlockHashKey key); friend class GPOctoMap; public: Block(); Block(point3f center); /// @return location of the OcTreeNode given OcTree's LeafIterator. inline point3f get_loc(const LeafIterator &it) const { return Block::key_loc_map[it.get_hash_key()] + center; } /// @return size of the OcTreeNode given OcTree's LeafIterator. inline float get_size(const LeafIterator &it) const { unsigned short depth, index; hash_key_to_node(it.get_hash_key(), depth, index); return float(size / pow(2, depth)); } /// @return center of current Block. inline point3f get_center() const { return center; } /// @return min lim of current Block. inline point3f get_lim_min() const { return center - point3f(size / 2.0f, size / 2.0f, size / 2.0f); } /// @return max lim of current Block. inline point3f get_lim_max() const { return center + point3f(size / 2.0f, size / 2.0f, size / 2.0f); } /// @return ExtendedBlock of current Block. ExtendedBlock get_extended_block() const; OcTreeHashKey get_node(unsigned short x, unsigned short y, unsigned short z) const; point3f get_point(unsigned short x, unsigned short y, unsigned short z) const; void get_index(const point3f &p, unsigned short &x, unsigned short &y, unsigned short &z) const; OcTreeNode &search(float x, float y, float z) const; OcTreeNode &search(point3f p) const; private: // Loop-Up Table static std::unordered_map<OcTreeHashKey, point3f> key_loc_map; static std::unordered_map<unsigned short, OcTreeHashKey> index_map; static float resolution; static float size; static unsigned short cell_num; point3f center; }; } #endif // LA3DM_GP_BLOCK_H
3,704
32.378378
131
h
la3dm
la3dm-master/include/gpoctomap/gpoctomap.h
#ifndef LA3DM_GP_OCTOMAP_H #define LA3DM_GP_OCTOMAP_H #include <unordered_map> #include <vector> #include <pcl/point_cloud.h> #include <pcl/point_types.h> #include "rtree.h" #include "gpblock.h" #include "gpoctree_node.h" namespace la3dm { /// PCL PointCloud types as input typedef pcl::PointXYZ PCLPointType; typedef pcl::PointCloud<PCLPointType> PCLPointCloud; /* * @brief GPOctoMap * * Fast, Accurate Gaussian Process Occupancy Maps via Test-Data Octrees * and Nested Bayesian Fusion. The space is partitioned by Blocks * in which OcTrees with fixed depth are rooted. The training part of GP * is performed Block by Block with training data inside each Block. * Occupancy values in one Block is predicted by its ExtendedBlock via BCM. */ class GPOctoMap { public: /// Types used internally typedef std::vector<point3f> PointCloud; typedef std::pair<point3f, float> GPPointType; typedef std::vector<GPPointType> GPPointCloud; typedef RTree<GPPointType *, float, 3, float> MyRTree; public: GPOctoMap(); /* * @param resolution (default 0.1m) * @param block_depth maximum depth of OcTree (default 4) * @param sf2 signal variance in GPs (default 1.0) * @param ell length-scale in GPs (default 1.0) * @param noise noise variance in GPs (default 0.01) * @param l length-scale in logistic regression function (default 100) * @param min_var minimum variance in Occupancy (default 0.001) * @param max_var maximum variance in Occupancy (default 1000) * @param max_known_var maximum variance for Occuapncy to be classified as KNOWN State (default 0.02) * @param free_thresh free threshold for Occupancy probability (default 0.3) * @param occupied_thresh occupied threshold for Occupancy probability (default 0.7) */ GPOctoMap(float resolution, unsigned short block_depth, float sf2, float ell, float noise, float l, float min_var, float max_var, float max_known_var, float free_thresh, float occupied_thresh); ~GPOctoMap(); /// Set resolution. void set_resolution(float resolution); /// Set block max depth. void set_block_depth(unsigned short max_depth); /// Get resolution. inline float get_resolution() const { return resolution; } /// Get block max depth. inline float get_block_depth() const { return block_depth; } /* * @brief Insert PCL PointCloud into GPOctoMaps. * @param cloud one scan in PCLPointCloud format * @param origin sensor origin in the scan * @param ds_resolution downsampling resolution for PCL VoxelGrid filtering (-1 if no downsampling) * @param free_res resolution for sampling free training points along sensor beams (default 2.0) * @param max_range maximum range for beams to be considered as valid measurements (-1 if no limitation) */ void insert_pointcloud(const PCLPointCloud &cloud, const point3f &origin, float ds_resolution, float free_res = 2.0f, float max_range = -1); void insert_training_data(const GPPointCloud &cloud); /// Get bounding box of the map. void get_bbox(point3f &lim_min, point3f &lim_max) const; class RayCaster { public: RayCaster(const GPOctoMap *map, const point3f &start, const point3f &end) : map(map) { assert(map != nullptr); _block_key = block_to_hash_key(start); block = map->search(_block_key); lim = static_cast<unsigned short>(pow(2, map->block_depth - 1)); if (block != nullptr) { block->get_index(start, x, y, z); block_lim = block->get_center(); block_size = block->size; current_p = start; resolution = map->resolution; int x0 = static_cast<int>((start.x() / resolution)); int y0 = static_cast<int>((start.y() / resolution)); int z0 = static_cast<int>((start.z() / resolution)); int x1 = static_cast<int>((end.x() / resolution)); int y1 = static_cast<int>((end.y() / resolution)); int z1 = static_cast<int>((end.z() / resolution)); dx = abs(x1 - x0); dy = abs(y1 - y0); dz = abs(z1 - z0); n = 1 + dx + dy + dz; x_inc = x1 > x0 ? 1 : (x1 == x0 ? 0 : -1); y_inc = y1 > y0 ? 1 : (y1 == y0 ? 0 : -1); z_inc = z1 > z0 ? 1 : (z1 == z0 ? 0 : -1); xy_error = dx - dy; xz_error = dx - dz; yz_error = dy - dz; dx *= 2; dy *= 2; dz *= 2; } else { n = 0; } } inline bool end() const { return n <= 0; } bool next(point3f &p, OcTreeNode &node, BlockHashKey &block_key, OcTreeHashKey &node_key) { assert(!end()); bool valid = false; unsigned short index = x + y * lim + z * lim * lim; node_key = Block::index_map[index]; block_key = _block_key; if (block != nullptr) { valid = true; node = (*block)[node_key]; current_p = block->get_point(x, y, z); p = current_p; } else { p = current_p; } if (xy_error > 0 && xz_error > 0) { x += x_inc; current_p.x() += x_inc * resolution; xy_error -= dy; xz_error -= dz; if (x >= lim || x < 0) { block_lim.x() += x_inc * block_size; _block_key = block_to_hash_key(block_lim); block = map->search(_block_key); x = x_inc > 0 ? 0 : lim - 1; } } else if (xy_error < 0 && yz_error > 0) { y += y_inc; current_p.y() += y_inc * resolution; xy_error += dx; yz_error -= dz; if (y >= lim || y < 0) { block_lim.y() += y_inc * block_size; _block_key = block_to_hash_key(block_lim); block = map->search(_block_key); y = y_inc > 0 ? 0 : lim - 1; } } else if (yz_error < 0 && xz_error < 0) { z += z_inc; current_p.z() += z_inc * resolution; xz_error += dx; yz_error += dy; if (z >= lim || z < 0) { block_lim.z() += z_inc * block_size; _block_key = block_to_hash_key(block_lim); block = map->search(_block_key); z = z_inc > 0 ? 0 : lim - 1; } } else if (xy_error == 0) { x += x_inc; y += y_inc; n -= 2; current_p.x() += x_inc * resolution; current_p.y() += y_inc * resolution; if (x >= lim || x < 0) { block_lim.x() += x_inc * block_size; _block_key = block_to_hash_key(block_lim); block = map->search(_block_key); x = x_inc > 0 ? 0 : lim - 1; } if (y >= lim || y < 0) { block_lim.y() += y_inc * block_size; _block_key = block_to_hash_key(block_lim); block = map->search(_block_key); y = y_inc > 0 ? 0 : lim - 1; } } n--; return valid; } private: const GPOctoMap *map; Block *block; point3f block_lim; float block_size, resolution; int dx, dy, dz, error, n; int x_inc, y_inc, z_inc, xy_error, xz_error, yz_error; unsigned short index, x, y, z, lim; BlockHashKey _block_key; point3f current_p; }; /// LeafIterator for iterating all leaf nodes in blocks class LeafIterator : public std::iterator<std::forward_iterator_tag, OcTreeNode> { public: LeafIterator(const GPOctoMap *map) { assert(map != nullptr); block_it = map->block_arr.cbegin(); end_block = map->block_arr.cend(); if (map->block_arr.size() > 0) { leaf_it = block_it->second->begin_leaf(); end_leaf = block_it->second->end_leaf(); } else { leaf_it = OcTree::LeafIterator(); end_leaf = OcTree::LeafIterator(); } } // just for initializing end iterator LeafIterator(std::unordered_map<BlockHashKey, Block *>::const_iterator block_it, OcTree::LeafIterator leaf_it) : block_it(block_it), leaf_it(leaf_it), end_block(block_it), end_leaf(leaf_it) { } bool operator==(const LeafIterator &other) { return (block_it == other.block_it) && (leaf_it == other.leaf_it); } bool operator!=(const LeafIterator &other) { return !(this->operator==(other)); } LeafIterator operator++(int) { LeafIterator result(*this); ++(*this); return result; } LeafIterator &operator++() { ++leaf_it; if (leaf_it == end_leaf) { ++block_it; if (block_it != end_block) { leaf_it = block_it->second->begin_leaf(); end_leaf = block_it->second->end_leaf(); } } return *this; } OcTreeNode &operator*() const { return *leaf_it; } std::vector<point3f> get_pruned_locs() const { std::vector<point3f> pruned_locs; point3f center = get_loc(); float size = get_size(); float x0 = center.x() - size * 0.5 + Block::resolution * 0.5; float y0 = center.y() - size * 0.5 + Block::resolution * 0.5; float z0 = center.z() - size * 0.5 + Block::resolution * 0.5; float x1 = center.x() + size * 0.5; float y1 = center.y() + size * 0.5; float z1 = center.z() + size * 0.5; for (float x = x0; x < x1; x += Block::resolution) { for (float y = y0; y < y1; y += Block::resolution) { for (float z = z0; z < z1; z += Block::resolution) { pruned_locs.emplace_back(x, y, z); } } } return pruned_locs; } inline OcTreeNode &get_node() const { return operator*(); } inline point3f get_loc() const { return block_it->second->get_loc(leaf_it); } inline float get_size() const { return block_it->second->get_size(leaf_it); } private: std::unordered_map<BlockHashKey, Block *>::const_iterator block_it; std::unordered_map<BlockHashKey, Block *>::const_iterator end_block; OcTree::LeafIterator leaf_it; OcTree::LeafIterator end_leaf; }; /// @return the beginning of leaf iterator inline LeafIterator begin_leaf() const { return LeafIterator(this); } /// @return the end of leaf iterator inline LeafIterator end_leaf() const { return LeafIterator(block_arr.cend(), OcTree::LeafIterator()); } OcTreeNode search(point3f p) const; OcTreeNode search(float x, float y, float z) const; Block *search(BlockHashKey key) const; inline float get_block_size() const { return block_size; } private: /// @return true if point is inside a bounding box given min and max limits. inline bool gp_point_in_bbox(const GPPointType &p, const point3f &lim_min, const point3f &lim_max) const { return (p.first.x() > lim_min.x() && p.first.x() < lim_max.x() && p.first.y() > lim_min.y() && p.first.y() < lim_max.y() && p.first.z() > lim_min.z() && p.first.z() < lim_max.z()); } /// Get the bounding box of a pointcloud. void bbox(const GPPointCloud &cloud, point3f &lim_min, point3f &lim_max) const; /// Get all block indices inside a bounding box. void get_blocks_in_bbox(const point3f &lim_min, const point3f &lim_max, std::vector<BlockHashKey> &blocks) const; /// Get all points inside a bounding box assuming pointcloud has been inserted in rtree before. int get_gp_points_in_bbox(const point3f &lim_min, const point3f &lim_max, GPPointCloud &out); /// @return true if point exists inside a bounding box assuming pointcloud has been inserted in rtree before. int has_gp_points_in_bbox(const point3f &lim_min, const point3f &lim_max); /// Get all points inside a bounding box (block) assuming pointcloud has been inserted in rtree before. int get_gp_points_in_bbox(const BlockHashKey &key, GPPointCloud &out); /// @return true if point exists inside a bounding box (block) assuming pointcloud has been inserted in rtree before. int has_gp_points_in_bbox(const BlockHashKey &key); /// Get all points inside an extended block assuming pointcloud has been inserted in rtree before. int get_gp_points_in_bbox(const ExtendedBlock &block, GPPointCloud &out); /// @return true if point exists inside an extended block assuming pointcloud has been inserted in rtree before. int has_gp_points_in_bbox(const ExtendedBlock &block); /// RTree callback function static bool count_callback(GPPointType *p, void *arg); /// RTree callback function static bool search_callback(GPPointType *p, void *arg); /// Downsample PCLPointCloud using PCL VoxelGrid Filtering. void downsample(const PCLPointCloud &in, PCLPointCloud &out, float ds_resolution) const; /// Sample free training points along sensor beams. void beam_sample(const point3f &hits, const point3f &origin, PointCloud &frees, float free_resolution) const; /// Get training data from one sensor scan. void get_training_data(const PCLPointCloud &cloud, const point3f &origin, float ds_resolution, float free_resolution, float max_range, GPPointCloud &xy) const; float resolution; float block_size; unsigned short block_depth; std::unordered_map<BlockHashKey, Block *> block_arr; MyRTree rtree; }; } #endif // LA3DM_GP_OCTOMAP_H
15,859
40.957672
125
h
la3dm
la3dm-master/include/gpoctomap/gpoctree.h
#ifndef LA3DM_GP_OCTREE_H #define LA3DM_GP_OCTREE_H #include <stack> #include <vector> #include "point3f.h" #include "gpoctree_node.h" namespace la3dm { /// Hash key to index OcTree nodes given depth and the index in that layer. typedef int OcTreeHashKey; /// Convert from node to hask key. OcTreeHashKey node_to_hash_key(unsigned short depth, unsigned short index); /// Convert from hash key to node. void hash_key_to_node(OcTreeHashKey key, unsigned short &depth, unsigned short &index); /* * @brief A simple OcTree to organize GP occupancy data in one block. * * OcTree doesn't store positions of nodes in order to reduce memory usage. * The nodes in OcTrees are indexed by OcTreeHashKey which can be used to * retrieve positions later (See Block). * For the purpose of mapping, this OcTree has fixed depth which should be * set before using OcTrees. */ class OcTree { friend class GPOctoMap; public: OcTree(); ~OcTree(); OcTree(const OcTree &other); OcTree &operator=(const OcTree &other); /* * @brief Rursively pruning OcTreeNodes with the same state. * * Prune nodes by setting nodes to PRUNED. * Delete the layer if all nodes are pruned. */ bool prune(); /// @return true if this node is a leaf node. bool is_leaf(OcTreeHashKey key) const; /// @return true if this node is a leaf node. bool is_leaf(unsigned short depth, unsigned short index) const; /// @return true if this node exists and is not pruned. bool search(OcTreeHashKey key) const; /// @return Occupancy of the node (without checking if it exists!) OcTreeNode &operator[](OcTreeHashKey key) const; /// Leaf iterator for OcTrees: iterate all leaf nodes not pruned. class LeafIterator : public std::iterator<std::forward_iterator_tag, OcTreeNode> { public: LeafIterator() : tree(nullptr) { } LeafIterator(const OcTree *tree) : tree(tree != nullptr && tree->node_arr != nullptr ? tree : nullptr) { if (tree != nullptr) { stack.emplace(0, 0); stack.emplace(0, 0); ++(*this); } } LeafIterator(const LeafIterator &other) : tree(other.tree), stack(other.stack) { } LeafIterator &operator=(const LeafIterator &other) { tree = other.tree; stack = other.stack; return *this; } bool operator==(const LeafIterator &other) const { return (tree == other.tree) && (stack.size() == other.stack.size()) && (stack.size() == 0 || (stack.size() > 0 && (stack.top().depth == other.stack.top().depth) && (stack.top().index == other.stack.top().index))); } bool operator!=(const LeafIterator &other) const { return !(this->operator==(other)); } LeafIterator operator++(int) { LeafIterator result(*this); ++(*this); return result; } LeafIterator &operator++() { if (stack.empty()) { tree = nullptr; } else { stack.pop(); while (!stack.empty() && !tree->is_leaf(stack.top().depth, stack.top().index)) single_inc(); if (stack.empty()) tree = nullptr; } return *this; } inline OcTreeNode &operator*() const { return (*tree)[get_hash_key()]; } inline OcTreeNode &get_node() const { return operator*(); } inline OcTreeHashKey get_hash_key() const { OcTreeHashKey key = node_to_hash_key(stack.top().depth, stack.top().index); return key; } protected: void single_inc() { StackElement top(stack.top()); stack.pop(); for (int i = 0; i < 8; ++i) { stack.emplace(top.depth + 1, top.index * 8 + i); } } struct StackElement { unsigned short depth; unsigned short index; StackElement(unsigned short depth, unsigned short index) : depth(depth), index(index) { } }; const OcTree *tree; std::stack<StackElement, std::vector<StackElement> > stack; }; /// @return the beginning of leaf iterator inline LeafIterator begin_leaf() const { return LeafIterator(this); }; /// @return the end of leaf iterator inline LeafIterator end_leaf() const { return LeafIterator(nullptr); }; private: OcTreeNode **node_arr; static unsigned short max_depth; }; } #endif // LA3DM_GP_OCTREE_H
5,274
31.561728
98
h
la3dm
la3dm-master/include/gpoctomap/gpoctree_node.h
#ifndef LA3DM_GP_OCCUPANCY_H #define LA3DM_GP_OCCUPANCY_H #include <iostream> #include <fstream> namespace la3dm { /// Occupancy state: before pruning: FREE, OCCUPIED, UNKNOWN; after pruning: PRUNED enum class State : char { FREE, OCCUPIED, UNKNOWN, PRUNED }; /* * @brief GP regression ouputs and occupancy state. * * Occupancy has member variables: m_ivar (m*ivar), ivar (1/var) and State. * This representation speeds up the updates via BCM. * Before using this class, set the static member variables first. */ class Occupancy { friend std::ostream &operator<<(std::ostream &os, const Occupancy &oc); friend std::ofstream &operator<<(std::ofstream &os, const Occupancy &oc); friend std::ifstream &operator>>(std::ifstream &is, Occupancy &oc); friend class GPOctoMap; public: /* * @brief Constructors and destructor. */ Occupancy() : m_ivar(0.0), ivar(Occupancy::min_ivar), state(State::UNKNOWN) { classified = false; } Occupancy(float m, float var); Occupancy(const Occupancy &other) : m_ivar(other.m_ivar), ivar(other.ivar), state(other.state) { } Occupancy &operator=(const Occupancy &other) { m_ivar = other.m_ivar; ivar = other.ivar; state = other.state; return *this; } ~Occupancy() { } /* * @brief Bayesian Committee Machine (BCM) update for Gaussian Process regression. * @param new_m mean resulted from GP regression * @param new_var variance resulted from GP regression */ void update(float new_m, float new_var); /// Get probability of occupancy. float get_prob() const; /// Get variance of occupancy (uncertainty) inline float get_var() const { return 1.0f / ivar; } /* * @brief Get occupancy state of the node. * @return occupancy state (see State). */ inline State get_state() const { return state; } /// Prune current node; set state to PRUNED. inline void prune() { state = State::PRUNED; } /// Only FREE and OCCUPIED nodes can be equal. inline bool operator==(const Occupancy &rhs) const { return this->state != State::UNKNOWN && this->state == rhs.state; } bool classified; private: float m_ivar; // m / var or m * ivar float ivar; // 1.0 / var State state; static float sf2; // signal variance static float ell; // length-scale static float noise; // noise variance static float l; // gamma in logistic functions static float max_ivar; // minimum variance static float min_ivar; // maximum variance static float min_known_ivar; // maximum variance for nodes to be considered as FREE or OCCUPIED static float free_thresh; // FREE occupancy threshold static float occupied_thresh; // OCCUPIED occupancy threshold }; typedef Occupancy OcTreeNode; } #endif // LA3DM_GP_OCCUPANCY_H
3,150
30.51
107
h
la3dm
la3dm-master/include/gpoctomap/gpregressor.h
#ifndef LA3DM_GP_REGRESSOR_H #define LA3DM_GP_REGRESSOR_H #include <Eigen/Dense> #include <vector> namespace la3dm { /* * @brief A Simple Gaussian Process Regressor * @param dim dimension of data (2, 3, etc.) * @param T data type (float, double, etc.) */ template<int dim, typename T> class GPRegressor { public: /// Eigen matrix type for training and test data and kernel using MatrixXType = Eigen::Matrix<T, -1, dim, Eigen::RowMajor>; using MatrixKType = Eigen::Matrix<T, -1, -1, Eigen::RowMajor>; using MatrixDKType = Eigen::Matrix<T, -1, 1>; using MatrixYType = Eigen::Matrix<T, -1, 1>; GPRegressor(T sf2, T ell, T noise) : sf2(sf2), ell(ell), noise(noise), trained(false) { } /* * @brief Train Gaussian Process * @param x input vector (3N, row major) * @param y target vector (N) */ void train(const std::vector<T> &x, const std::vector<T> &y) { assert(x.size() % dim == 0 && (int) (x.size() / dim) == y.size()); MatrixXType _x = Eigen::Map<const MatrixXType>(x.data(), x.size() / dim, dim); MatrixYType _y = Eigen::Map<const MatrixYType>(y.data(), y.size(), 1); train(_x, _y); } /* * @brief Train Gaussian Process * @param x input matrix (NX3) * @param y target matrix (NX1) */ void train(const MatrixXType &x, const MatrixYType &y) { this->x = MatrixXType(x); covMaterniso3(x, x, K); // covSparse(x, x, K); K = K + noise * MatrixKType::Identity(K.rows(), K.cols()); Eigen::LLT<MatrixKType> llt(K); alpha = llt.solve(y); L = llt.matrixL(); trained = true; } /* * @brief Predict with Gaussian Process * @param xs input vector (3M, row major) * @param m predicted mean vector (M) * @param var predicted variance vector (M) */ void predict(const std::vector<T> &xs, std::vector<T> &m, std::vector<T> &var) const { assert(xs.size() % dim == 0); MatrixXType _xs = Eigen::Map<const MatrixXType>(xs.data(), xs.size() / dim, dim); MatrixYType _m, _var; predict(_xs, _m, _var); m.resize(_m.rows()); var.resize(_var.rows()); for (int r = 0; r < _m.rows(); ++r) { m[r] = _m(r, 0); var[r] = _var(r, 0); } } /* * @brief Predict with Gaussian Process * @param xs input vector (MX3) * @param m predicted mean matrix (MX1) * @param var predicted variance matrix (MX1) */ void predict(const MatrixXType &xs, MatrixYType &m, MatrixYType &var) const { assert(trained == true); MatrixKType Ks; covMaterniso3(x, xs, Ks); // covSparse(x, xs, Ks); m = Ks.transpose() * alpha; MatrixKType v = L.template triangularView<Eigen::Lower>().solve(Ks); MatrixDKType Kss; covMaterniso3(xs, xs, Kss); // covSparse(xs, xs, Kss); var = Kss - (v.transpose() * v).diagonal(); } private: /* * @brief Compute Euclid distances between two vectors. * @param x input vector * @param z input vecotr * @return d distance matrix */ void dist(const MatrixXType &x, const MatrixXType &z, MatrixKType &d) const { d = MatrixKType::Zero(x.rows(), z.rows()); for (int i = 0; i < x.rows(); ++i) { d.row(i) = (z.rowwise() - x.row(i)).rowwise().norm(); } } /* * @brief Matern3 kernel. * @param x input vector * @param z input vector * @return Kxz covariance matrix */ void covMaterniso3(const MatrixXType &x, const MatrixXType &z, MatrixKType &Kxz) const { dist(1.73205 / ell * x, 1.73205 / ell * z, Kxz); Kxz = ((1 + Kxz.array()) * exp(-Kxz.array())).matrix() * sf2; } /* * @brief Diagonal of Matern3 kernel. * @return Kxz sf2 * I */ void covMaterniso3(const MatrixXType &x, const MatrixXType &z, MatrixDKType &Kxz) const { Kxz = MatrixDKType::Ones(x.rows()) * sf2; } /* * @brief Sparse kernel. * @param x input vector * @param z input vector * @return Kxz covariance matrix * @ref A sparse covariance function for exact gaussian process inference in large datasets. */ void covSparse(const MatrixXType &x, const MatrixXType &z, MatrixKType &Kxz) const { dist(x / ell, z / ell, Kxz); Kxz = ((2 + (Kxz * 2 * 3.1415926).array().cos()) * (1.0 - Kxz.array()) / 3.0 + (Kxz * 2 * 3.1415926).array().sin() / (2 * 3.1415926)).matrix() * sf2; for (int i = 0; i < Kxz.rows(); ++i) { for (int j = 0; j < Kxz.cols(); ++j) { if (Kxz(i,j) < 0.0) { Kxz(i,j) = 0.0f; } } } } /* * @brief Diagonal of sparse kernel. * @return Kxz sf2 * I */ void covSparse(const MatrixXType &x, const MatrixXType &z, MatrixDKType &Kxz) const { Kxz = MatrixDKType::Ones(x.rows()) * sf2; } T sf2; // signal variance T ell; // length-scale T noise; // noise variance MatrixXType x; // temporary storage of training data MatrixKType K; MatrixYType alpha; MatrixKType L; bool trained; // true if gpregressor has been trained }; typedef GPRegressor<3, float> GPR3f; } #endif // LA3DM_GP_REGRESSOR_H
5,931
33.894118
100
h
null
AICP-main/veins/src/veins/modules/analogueModel/NakagamiFading.h
// // Copyright (C) 2015 David Eckhoff <david.eckhoff@fau.de> // Christoph Sommer <sommer@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/base/phyLayer/AnalogueModel.h" #include "veins/base/modules/BaseWorldUtility.h" #include "veins/base/messages/AirFrame_m.h" namespace veins { /** * @brief * A simple model to account for fast fading using the Nakagami Distribution. * * See the Veins website <a href="http://veins.car2x.org/"> for a tutorial, documentation, and publications </a>. * * An in-depth description of the model is available at: * Todo: add paper * * @author David Eckhoff, Christoph Sommer * * @ingroup analogueModels */ class VEINS_API NakagamiFading : public AnalogueModel { public: NakagamiFading(cComponent* owner, bool constM, double m) : AnalogueModel(owner) , constM(constM) , m(m) { } ~NakagamiFading() override { } void filterSignal(Signal* signal) override; protected: /** @brief Whether to use a constant m or a m based on distance */ bool constM; /** @brief The value of the coefficient m */ double m; }; } // namespace veins
1,992
27.471429
113
h
null
AICP-main/veins/src/veins/modules/analogueModel/PERModel.h
// // Copyright (C) 2007 Technische Universitaet Berlin (TUB), Germany, Telecommunication Networks Group // Copyright (C) 2007 Technische Universiteit Delft (TUD), Netherlands // Copyright (C) 2007 Universitaet Paderborn (UPB), Germany // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/veins.h" #include "veins/base/phyLayer/AnalogueModel.h" using veins::AirFrame; namespace veins { /** * @brief This class applies a parameterized packet error rate * to incoming packets. This allows the user to easily * study the robustness of its system to packet loss. * * @ingroup analogueModels * * @author Jérôme Rousselot <jerome.rousselot@csem.ch> */ class VEINS_API PERModel : public AnalogueModel { protected: double packetErrorRate; public: /** @brief The PERModel constructor takes as argument the packet error rate to apply (must be between 0 and 1). */ PERModel(cComponent* owner, double per) : AnalogueModel(owner) , packetErrorRate(per) { ASSERT(per <= 1 && per >= 0); } void filterSignal(Signal*) override; }; } // namespace veins
1,911
30.344262
118
h
null
AICP-main/veins/src/veins/modules/analogueModel/SimpleObstacleShadowing.h
// // Copyright (C) 2006-2018 Christoph Sommer <sommer@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <cstdlib> #include "veins/base/phyLayer/AnalogueModel.h" #include "veins/base/modules/BaseWorldUtility.h" #include "veins/modules/obstacle/ObstacleControl.h" #include "veins/base/utils/Move.h" #include "veins/base/messages/AirFrame_m.h" using veins::AirFrame; using veins::ObstacleControl; namespace veins { class Signal; /** * @brief Basic implementation of a SimpleObstacleShadowing * * @ingroup analogueModels */ class VEINS_API SimpleObstacleShadowing : public AnalogueModel { protected: /** @brief reference to global ObstacleControl instance */ ObstacleControl& obstacleControl; /** @brief Information needed about the playground */ const bool useTorus; /** @brief The size of the playground.*/ const Coord& playgroundSize; public: /** * @brief Initializes the analogue model. myMove and playgroundSize * need to be valid as long as this instance exists. * * The constructor needs some specific knowledge in order to create * its mapping properly: * * @param owner pointer to the cComponent that owns this AnalogueModel * @param obstacleControl the parent module * @param useTorus information about the playground the host is moving in * @param playgroundSize information about the playground the host is moving in */ SimpleObstacleShadowing(cComponent* owner, ObstacleControl& obstacleControl, bool useTorus, const Coord& playgroundSize); /** * @brief Filters a specified Signal by adding an attenuation * over time to the Signal. */ void filterSignal(Signal* signal) override; bool neverIncreasesPower() override { return true; } }; } // namespace veins
2,635
30.380952
125
h
null
AICP-main/veins/src/veins/modules/analogueModel/SimplePathlossModel.h
// // Copyright (C) 2007 Technische Universitaet Berlin (TUB), Germany, Telecommunication Networks Group // Copyright (C) 2007 Technische Universiteit Delft (TUD), Netherlands // Copyright (C) 2007 Universitaet Paderborn (UPB), Germany // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <cstdlib> #include "veins/veins.h" #include "veins/base/phyLayer/AnalogueModel.h" #include "veins/base/modules/BaseWorldUtility.h" namespace veins { using veins::AirFrame; class SimplePathlossModel; /** * @brief Basic implementation of a SimplePathlossModel * * An example config.xml for this AnalogueModel can be the following: * @verbatim <AnalogueModel type="SimplePathlossModel"> <!-- Environment parameter of the pathloss formula If ommited default value is 3.5--> <parameter name="alpha" type="double" value="3.5"/> </AnalogueModel> @endverbatim * * @ingroup analogueModels */ class VEINS_API SimplePathlossModel : public AnalogueModel { protected: /** @brief Path loss coefficient. **/ double pathLossAlphaHalf; /** @brief Information needed about the playground */ const bool useTorus; /** @brief The size of the playground.*/ const Coord& playgroundSize; public: /** * @brief Initializes the analogue model. playgroundSize * need to be valid as long as this instance exists. * * The constructor needs some specific knowledge in order to create * its mapping properly: * * @param owner pointer to the cComponent that owns this AnalogueModel * @param alpha the coefficient alpha (specified e.g. in config.xml and * passed in constructor call) * @param useTorus information about the playground the host is moving in * @param playgroundSize information about the playground the host is * moving in */ SimplePathlossModel(cComponent* owner, double alpha, bool useTorus, const Coord& playgroundSize) : AnalogueModel(owner) , pathLossAlphaHalf(alpha * 0.5) , useTorus(useTorus) , playgroundSize(playgroundSize) { } /** * @brief Filters a specified AirFrame's Signal by adding an attenuation * over time to the Signal. */ void filterSignal(Signal*) override; bool neverIncreasesPower() override { return true; } }; } // namespace veins
3,213
30.821782
101
h
null
AICP-main/veins/src/veins/modules/application/ieee80211p/DemoBaseApplLayer.h
// // Copyright (C) 2016 David Eckhoff <eckhoff@cs.fau.de> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <map> #include "veins/base/modules/BaseApplLayer.h" #include "veins/modules/utility/Consts80211p.h" #include "veins/modules/messages/BaseFrame1609_4_m.h" #include "veins/modules/messages/DemoServiceAdvertisement_m.h" #include "veins/modules/messages/DemoSafetyMessage_m.h" #include "veins/base/connectionManager/ChannelAccess.h" #include "veins/modules/mac/ieee80211p/DemoBaseApplLayerToMac1609_4Interface.h" #include "veins/modules/mobility/traci/TraCIMobility.h" #include "veins/modules/mobility/traci/TraCICommandInterface.h" namespace veins { using veins::AnnotationManager; using veins::AnnotationManagerAccess; using veins::TraCICommandInterface; using veins::TraCIMobility; using veins::TraCIMobilityAccess; /** * @brief * Demo application layer base class. * * @author David Eckhoff * * @ingroup applLayer * * @see DemoBaseApplLayer * @see Mac1609_4 * @see PhyLayer80211p * @see Decider80211p */ class VEINS_API DemoBaseApplLayer : public BaseApplLayer { public: ~DemoBaseApplLayer() override; void initialize(int stage) override; void finish() override; void receiveSignal(cComponent* source, simsignal_t signalID, cObject* obj, cObject* details) override; enum DemoApplMessageKinds { SEND_BEACON_EVT, SEND_WSA_EVT }; protected: /** @brief handle messages from below and calls the onWSM, onBSM, and onWSA functions accordingly */ void handleLowerMsg(cMessage* msg) override; /** @brief handle self messages */ void handleSelfMsg(cMessage* msg) override; /** @brief sets all the necessary fields in the WSM, BSM, or WSA. */ virtual void populateWSM(BaseFrame1609_4* wsm, LAddress::L2Type rcvId = LAddress::L2BROADCAST(), int serial = 0); /** @brief this function is called upon receiving a BaseFrame1609_4 */ virtual void onWSM(BaseFrame1609_4* wsm){}; /** @brief this function is called upon receiving a DemoSafetyMessage, also referred to as a beacon */ virtual void onBSM(DemoSafetyMessage* bsm){}; /** @brief this function is called upon receiving a DemoServiceAdvertisement */ virtual void onWSA(DemoServiceAdvertisment* wsa){}; /** @brief this function is called every time the vehicle receives a position update signal */ virtual void handlePositionUpdate(cObject* obj); /** @brief this function is called every time the vehicle parks or starts moving again */ virtual void handleParkingUpdate(cObject* obj); /** @brief This will start the periodic advertising of the new service on the CCH * * @param channel the channel on which the service is provided * @param serviceId a service ID to be used with the service * @param serviceDescription a literal description of the service */ virtual void startService(Channel channel, int serviceId, std::string serviceDescription); /** @brief stopping the service and advertising for it */ virtual void stopService(); /** @brief compute a point in time that is guaranteed to be in the correct channel interval plus a random offset * * @param interval the interval length of the periodic message * @param chantype the type of channel, either type_CCH or type_SCH */ virtual simtime_t computeAsynchronousSendingTime(simtime_t interval, ChannelType chantype); /** * @brief overloaded for error handling and stats recording purposes * * @param msg the message to be sent. Must be a WSM/BSM/WSA */ virtual void sendDown(cMessage* msg); /** * @brief overloaded for error handling and stats recording purposes * * @param msg the message to be sent. Must be a WSM/BSM/WSA * @param delay the delay for the message */ virtual void sendDelayedDown(cMessage* msg, simtime_t delay); /** * @brief helper function for error handling and stats recording purposes * * @param msg the message to be checked and tracked */ virtual void checkAndTrackPacket(cMessage* msg); protected: /* pointers ill be set when used with TraCIMobility */ TraCIMobility* mobility; TraCICommandInterface* traci; TraCICommandInterface::Vehicle* traciVehicle; AnnotationManager* annotations; DemoBaseApplLayerToMac1609_4Interface* mac; /* support for parking currently only works with TraCI */ bool isParked; /* BSM (beacon) settings */ uint32_t beaconLengthBits; uint32_t beaconUserPriority; simtime_t beaconInterval; bool sendBeacons; /* WSM (data) settings */ uint32_t dataLengthBits; uint32_t dataUserPriority; bool dataOnSch; /* WSA settings */ int currentOfferedServiceId; std::string currentServiceDescription; Channel currentServiceChannel; simtime_t wsaInterval; /* state of the vehicle */ Coord curPosition; Coord curSpeed; LAddress::L2Type myId = 0; int mySCH; /* stats */ uint32_t generatedWSMs; uint32_t generatedWSAs; uint32_t generatedBSMs; uint32_t receivedWSMs; uint32_t receivedWSAs; uint32_t receivedBSMs; /* messages for periodic events such as beacon and WSA transmissions */ cMessage* sendBeaconEvt; cMessage* sendWSAEvt; }; } // namespace veins
6,159
32.11828
117
h
null
AICP-main/veins/src/veins/modules/application/traci/TraCIDemo11p.h
// // Copyright (C) 2006-2011 Christoph Sommer <christoph.sommer@uibk.ac.at> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/modules/application/ieee80211p/DemoBaseApplLayer.h" namespace veins { /** * @brief * A tutorial demo for TraCI. When the car is stopped for longer than 10 seconds * it will send a message out to other cars containing the blocked road id. * Receiving cars will then trigger a reroute via TraCI. * When channel switching between SCH and CCH is enabled on the MAC, the message is * instead send out on a service channel following a Service Advertisement * on the CCH. * * @author Christoph Sommer : initial DemoApp * @author David Eckhoff : rewriting, moving functionality to DemoBaseApplLayer, adding WSA * */ class VEINS_API TraCIDemo11p : public DemoBaseApplLayer { public: void initialize(int stage) override; protected: simtime_t lastDroveAt; bool sentMessage; int currentSubscribedServiceId; protected: void onBSM(DemoSafetyMessage* bsm) override; void onWSM(BaseFrame1609_4* wsm) override; void onWSA(DemoServiceAdvertisment* wsa) override; void handleSelfMsg(cMessage* msg) override; void handlePositionUpdate(cObject* obj) override; }; } // namespace veins
2,061
32.258065
91
h
null
AICP-main/veins/src/veins/modules/application/traci/TraCIDemo11pMessage_m.h
// // Generated file, do not edit! Created by nedtool 5.5 from veins/modules/application/traci/TraCIDemo11pMessage.msg. // #ifndef __VEINS_TRACIDEMO11PMESSAGE_M_H #define __VEINS_TRACIDEMO11PMESSAGE_M_H #if defined(__clang__) # pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #include <omnetpp.h> // nedtool version check #define MSGC_VERSION 0x0505 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. #endif // dll export symbol #ifndef VEINS_API # if defined(VEINS_EXPORT) # define VEINS_API OPP_DLLEXPORT # elif defined(VEINS_IMPORT) # define VEINS_API OPP_DLLIMPORT # else # define VEINS_API # endif #endif // cplusplus {{ #include "veins/base/utils/Coord.h" #include "veins/modules/messages/BaseFrame1609_4_m.h" #include "veins/base/utils/SimpleAddress.h" // }} namespace veins { /** * Class generated from <tt>veins/modules/application/traci/TraCIDemo11pMessage.msg:35</tt> by nedtool. * <pre> * packet TraCIDemo11pMessage extends BaseFrame1609_4 * { * string demoData; * LAddress::L2Type senderAddress = -1; * int serial = 0; * } * </pre> */ class VEINS_API TraCIDemo11pMessage : public ::veins::BaseFrame1609_4 { protected: ::omnetpp::opp_string demoData; LAddress::L2Type senderAddress; int serial; private: void copy(const TraCIDemo11pMessage& other); protected: // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const TraCIDemo11pMessage&); public: TraCIDemo11pMessage(const char *name=nullptr, short kind=0); TraCIDemo11pMessage(const TraCIDemo11pMessage& other); virtual ~TraCIDemo11pMessage(); TraCIDemo11pMessage& operator=(const TraCIDemo11pMessage& other); virtual TraCIDemo11pMessage *dup() const override {return new TraCIDemo11pMessage(*this);} virtual void parsimPack(omnetpp::cCommBuffer *b) const override; virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; // field getter/setter methods virtual const char * getDemoData() const; virtual void setDemoData(const char * demoData); virtual LAddress::L2Type& getSenderAddress(); virtual const LAddress::L2Type& getSenderAddress() const {return const_cast<TraCIDemo11pMessage*>(this)->getSenderAddress();} virtual void setSenderAddress(const LAddress::L2Type& senderAddress); virtual int getSerial() const; virtual void setSerial(int serial); }; inline void doParsimPacking(omnetpp::cCommBuffer *b, const TraCIDemo11pMessage& obj) {obj.parsimPack(b);} inline void doParsimUnpacking(omnetpp::cCommBuffer *b, TraCIDemo11pMessage& obj) {obj.parsimUnpack(b);} } // namespace veins #endif // ifndef __VEINS_TRACIDEMO11PMESSAGE_M_H
2,809
30.222222
129
h
null
AICP-main/veins/src/veins/modules/application/traci/TraCIDemoRSU11p.h
// // Copyright (C) 2016 David Eckhoff <david.eckhoff@fau.de> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/modules/application/ieee80211p/DemoBaseApplLayer.h" namespace veins { /** * Small RSU Demo using 11p */ class VEINS_API TraCIDemoRSU11p : public DemoBaseApplLayer { protected: void onWSM(BaseFrame1609_4* wsm) override; void onWSA(DemoServiceAdvertisment* wsa) override; }; } // namespace veins
1,235
30.692308
76
h
null
AICP-main/veins/src/veins/modules/mac/ieee80211p/DemoBaseApplLayerToMac1609_4Interface.h
// // Copyright (C) 2011 David Eckhoff <eckhoff@cs.fau.de> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/base/utils/NetwToMacControlInfo.h" #include "veins/modules/utility/Consts80211p.h" namespace veins { /** * @brief * Interface between DemoBaseApplLayer Layer and Mac1609_4 * * @author David Eckhoff * * @ingroup macLayer */ class VEINS_API DemoBaseApplLayerToMac1609_4Interface { public: virtual bool isChannelSwitchingActive() = 0; virtual simtime_t getSwitchingInterval() = 0; virtual bool isCurrentChannelCCH() = 0; virtual void changeServiceChannel(Channel channelNumber) = 0; virtual ~DemoBaseApplLayerToMac1609_4Interface(){}; /** * @brief Returns the MAC address of this MAC module. */ virtual const LAddress::L2Type& getMACAddress() = 0; }; } // namespace veins
1,647
27.912281
76
h
null
AICP-main/veins/src/veins/modules/mac/ieee80211p/Mac1609_4.h
// // Copyright (C) 2012 David Eckhoff <eckhoff@cs.fau.de> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <queue> #include <memory> #include <stdint.h> #include "veins/veins.h" #include "veins/base/modules/BaseLayer.h" #include "veins/modules/phy/PhyLayer80211p.h" #include "veins/modules/mac/ieee80211p/DemoBaseApplLayerToMac1609_4Interface.h" #include "veins/modules/utility/Consts80211p.h" #include "veins/modules/utility/MacToPhyControlInfo11p.h" #include "veins/base/utils/FindModule.h" #include "veins/modules/messages/Mac80211Pkt_m.h" #include "veins/modules/messages/BaseFrame1609_4_m.h" #include "veins/modules/messages/AckTimeOutMessage_m.h" #include "veins/modules/messages/Mac80211Ack_m.h" #include "veins/base/modules/BaseMacLayer.h" #include "veins/modules/utility/ConstsPhy.h" #include "veins/modules/utility/HasLogProxy.h" namespace veins { /** * @brief * Manages timeslots for CCH and SCH listening and sending. * * @author David Eckhoff : rewrote complete model * @author Christoph Sommer : features and bug fixes * @author Michele Segata : features and bug fixes * @author Stefan Joerer : features and bug fixes * @author Gurjashan Pannu: features (unicast model) * @author Christopher Saloman: initial version * * @ingroup macLayer * * @see DemoBaseApplLayer * @see Mac1609_4 * @see PhyLayer80211p * @see Decider80211p */ class DeciderResult80211; class VEINS_API Mac1609_4 : public BaseMacLayer, public DemoBaseApplLayerToMac1609_4Interface { public: // tell to anybody which is interested when the channel turns busy or idle static const simsignal_t sigChannelBusy; // tell to anybody which is interested when a collision occurred static const simsignal_t sigCollision; // Access categories in increasing order of priority (see IEEE Std 802.11-2012, Table 9-1) enum t_access_category { AC_BK = 0, AC_BE = 1, AC_VI = 2, AC_VO = 3 }; class VEINS_API EDCA : HasLogProxy { public: class VEINS_API EDCAQueue { public: std::queue<BaseFrame1609_4*> queue; int aifsn; // number of aifs slots for this queue int cwMin; // minimum contention window int cwMax; // maximum contention size int cwCur; // current contention window int64_t currentBackoff; // current Backoff value for this queue bool txOP; int ssrc; // station short retry count int slrc; // station long retry count bool waitForAck; // true if the queue is waiting for an acknowledgment for unicast unsigned long waitOnUnicastID; // unique id of unicast on which station is waiting AckTimeOutMessage* ackTimeOut; // timer for retransmission on receiving no ACK EDCAQueue() { } EDCAQueue(int aifsn, int cwMin, int cwMax, t_access_category ac); ~EDCAQueue(); }; EDCA(cSimpleModule* owner, ChannelType channelType, int maxQueueLength = 0); ~EDCA(); void createQueue(int aifsn, int cwMin, int cwMax, t_access_category); int queuePacket(t_access_category AC, BaseFrame1609_4* cmsg); void backoff(t_access_category ac); simtime_t startContent(simtime_t idleSince, bool guardActive); void stopContent(bool allowBackoff, bool generateTxOp); void postTransmit(t_access_category, BaseFrame1609_4* wsm, bool useAcks); void revokeTxOPs(); /** @brief return the next packet to send, send all lower Queues into backoff */ BaseFrame1609_4* initiateTransmit(simtime_t idleSince); public: cSimpleModule* owner; std::map<t_access_category, EDCAQueue> myQueues; uint32_t maxQueueSize; simtime_t lastStart; // when we started the last contention; ChannelType channelType; /** @brief Stats */ long statsNumInternalContention; long statsNumBackoff; long statsSlotsBackoff; /** @brief Id for debug messages */ std::string myId; }; public: Mac1609_4() : nextChannelSwitch(nullptr) , nextMacEvent(nullptr) { } ~Mac1609_4() override; /** * @brief return true if alternate access is enabled */ bool isChannelSwitchingActive() override; simtime_t getSwitchingInterval() override; bool isCurrentChannelCCH() override; void changeServiceChannel(Channel channelNumber) override; /** * @brief Change the default tx power the NIC card is using * * @param txPower_mW the tx power to be set in mW */ void setTxPower(double txPower_mW); /** * @brief Change the default MCS the NIC card is using * * @param mcs the default modulation and coding scheme * to use */ void setMCS(MCS mcs); /** * @brief Change the phy layer carrier sense threshold. * * @param ccaThreshold_dBm the cca threshold in dBm */ void setCCAThreshold(double ccaThreshold_dBm); protected: /** @brief States of the channel selecting operation.*/ protected: /** @brief Initialization of the module and some variables.*/ void initialize(int) override; /** @brief Delete all dynamically allocated objects of the module.*/ void finish() override; /** @brief Handle messages from lower layer.*/ void handleLowerMsg(cMessage*) override; /** @brief Handle messages from upper layer.*/ void handleUpperMsg(cMessage*) override; /** @brief Handle control messages from upper layer.*/ void handleUpperControl(cMessage* msg) override; /** @brief Handle self messages such as timers.*/ void handleSelfMsg(cMessage*) override; /** @brief Handle control messages from lower layer.*/ void handleLowerControl(cMessage* msg) override; /** @brief Handle received broadcast */ virtual void handleBroadcast(Mac80211Pkt* macPkt, DeciderResult80211* res); /** @brief Set a state for the channel selecting operation.*/ void setActiveChannel(ChannelType state); void sendFrame(Mac80211Pkt* frame, omnetpp::simtime_t delay, Channel channelNr, MCS mcs, double txPower_mW); simtime_t timeLeftInSlot() const; simtime_t timeLeftTillGuardOver() const; bool guardActive() const; void attachControlInfo(Mac80211Pkt* mac, Channel channelNr, MCS mcs, double txPower_mW); /** @brief maps a application layer priority (up) to an EDCA access category. */ t_access_category mapUserPriority(int prio); void channelBusy(); void channelBusySelf(bool generateTxOp); void channelIdle(bool afterSwitch = false); void setParametersForBitrate(uint64_t bitrate); void sendAck(LAddress::L2Type recpAddress, unsigned long wsmId); void handleUnicast(LAddress::L2Type srcAddr, std::unique_ptr<BaseFrame1609_4> wsm); void handleAck(const Mac80211Ack* ack); void handleAckTimeOut(AckTimeOutMessage* ackTimeOutMsg); void handleRetransmit(t_access_category ac); const LAddress::L2Type& getMACAddress() override { ASSERT(myMacAddr != LAddress::L2NULL()); return BaseMacLayer::getMACAddress(); } protected: /** @brief Self message to indicate that the current channel shall be switched.*/ cMessage* nextChannelSwitch; /** @brief Self message to wake up at next MacEvent */ cMessage* nextMacEvent; /** @brief Last time the channel went idle */ simtime_t lastIdle; simtime_t lastBusy; /** @brief Current state of the channel selecting operation.*/ ChannelType activeChannel; /** @brief access category of last sent packet */ t_access_category lastAC; /** @brief pointer to last sent packet */ BaseFrame1609_4* lastWSM; /** @brief pointer to last sent mac frame */ std::unique_ptr<Mac80211Pkt> lastMac; int headerLength; bool useSCH; Channel mySCH; std::map<ChannelType, std::unique_ptr<EDCA>> myEDCA; bool idleChannel; /** @brief stats */ long statsReceivedPackets; long statsReceivedBroadcasts; long statsSentPackets; long statsSentAcks; long statsTXRXLostPackets; long statsSNIRLostPackets; long statsDroppedPackets; long statsNumTooLittleTime; long statsNumInternalContention; long statsNumBackoff; long statsSlotsBackoff; simtime_t statsTotalBusyTime; /** @brief The power (in mW) to transmit with.*/ double txPower; MCS mcs; ///< Modulation and coding scheme to use unless explicitly specified. /** @brief Id for debug messages */ std::string myId; bool useAcks; double ackErrorRate; int dot11RTSThreshold; int dot11ShortRetryLimit; int dot11LongRetryLimit; int ackLength; // indicates rx start within the period of ACK timeout bool rxStartIndication; // An ack is sent after SIFS irrespective of the channel state cMessage* stopIgnoreChannelStateMsg; bool ignoreChannelState; // Dont start contention immediately after finishing unicast TX. Wait until ack timeout/ ack Rx bool waitUntilAckRXorTimeout; std::set<unsigned long> handledUnicastToApp; Mac80211pToPhy11pInterface* phy11p; }; } // namespace veins
10,064
30.851266
112
h
null
AICP-main/veins/src/veins/modules/mac/ieee80211p/Mac80211pToPhy11pInterface.h
// // Copyright (C) 2011 David Eckhoff <eckhoff@cs.fau.de> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/base/phyLayer/MacToPhyInterface.h" #include "veins/modules/utility/ConstsPhy.h" #include "veins/modules/utility/Consts80211p.h" namespace veins { /** * @brief * Interface of PhyLayer80211p exposed to Mac1609_4. * * @author Christopher Saloman * @author David Eckhoff * * @ingroup phyLayer */ class VEINS_API Mac80211pToPhy11pInterface { public: enum BasePhyMessageKinds { CHANNEL_IDLE, CHANNEL_BUSY, }; virtual ~Mac80211pToPhy11pInterface() = default; virtual void changeListeningChannel(Channel channel) = 0; virtual void setCCAThreshold(double ccaThreshold_dBm) = 0; virtual void notifyMacAboutRxStart(bool enable) = 0; virtual void requestChannelStatusIfIdle() = 0; virtual simtime_t getFrameDuration(int payloadLengthBits, MCS mcs) const = 0; }; } // namespace veins
1,757
29.842105
81
h
null
AICP-main/veins/src/veins/modules/messages/AckTimeOutMessage_m.h
// // Generated file, do not edit! Created by nedtool 5.5 from veins/modules/messages/AckTimeOutMessage.msg. // #ifndef __VEINS_ACKTIMEOUTMESSAGE_M_H #define __VEINS_ACKTIMEOUTMESSAGE_M_H #if defined(__clang__) # pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #include <omnetpp.h> // nedtool version check #define MSGC_VERSION 0x0505 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. #endif // dll export symbol #ifndef VEINS_API # if defined(VEINS_EXPORT) # define VEINS_API OPP_DLLEXPORT # elif defined(VEINS_IMPORT) # define VEINS_API OPP_DLLIMPORT # else # define VEINS_API # endif #endif namespace veins { /** * Class generated from <tt>veins/modules/messages/AckTimeOutMessage.msg:25</tt> by nedtool. * <pre> * message AckTimeOutMessage * { * // The corresponding WSM's tree id * unsigned long wsmId = -1; * // Access category on which the AckTimer is set * int ac = -1; * } * </pre> */ class VEINS_API AckTimeOutMessage : public ::omnetpp::cMessage { protected: unsigned long wsmId; int ac; private: void copy(const AckTimeOutMessage& other); protected: // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const AckTimeOutMessage&); public: AckTimeOutMessage(const char *name=nullptr, short kind=0); AckTimeOutMessage(const AckTimeOutMessage& other); virtual ~AckTimeOutMessage(); AckTimeOutMessage& operator=(const AckTimeOutMessage& other); virtual AckTimeOutMessage *dup() const override {return new AckTimeOutMessage(*this);} virtual void parsimPack(omnetpp::cCommBuffer *b) const override; virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; // field getter/setter methods virtual unsigned long getWsmId() const; virtual void setWsmId(unsigned long wsmId); virtual int getAc() const; virtual void setAc(int ac); }; inline void doParsimPacking(omnetpp::cCommBuffer *b, const AckTimeOutMessage& obj) {obj.parsimPack(b);} inline void doParsimUnpacking(omnetpp::cCommBuffer *b, AckTimeOutMessage& obj) {obj.parsimUnpack(b);} } // namespace veins #endif // ifndef __VEINS_ACKTIMEOUTMESSAGE_M_H
2,303
27.444444
121
h
null
AICP-main/veins/src/veins/modules/messages/AirFrame11p_m.h
// // Generated file, do not edit! Created by nedtool 5.5 from veins/modules/messages/AirFrame11p.msg. // #ifndef __VEINS_AIRFRAME11P_M_H #define __VEINS_AIRFRAME11P_M_H #if defined(__clang__) # pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #include <omnetpp.h> // nedtool version check #define MSGC_VERSION 0x0505 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. #endif // dll export symbol #ifndef VEINS_API # if defined(VEINS_EXPORT) # define VEINS_API OPP_DLLEXPORT # elif defined(VEINS_IMPORT) # define VEINS_API OPP_DLLIMPORT # else # define VEINS_API # endif #endif // cplusplus {{ #include "veins/base/messages/AirFrame_m.h" using veins::AirFrame; // }} namespace veins { /** * Class generated from <tt>veins/modules/messages/AirFrame11p.msg:35</tt> by nedtool. * <pre> * // * // Extension of base AirFrame message to have the underMinPowerLevel field * // * message AirFrame11p extends AirFrame * { * bool underMinPowerLevel = false; * bool wasTransmitting = false; * } * </pre> */ class VEINS_API AirFrame11p : public ::veins::AirFrame { protected: bool underMinPowerLevel; bool wasTransmitting; private: void copy(const AirFrame11p& other); protected: // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const AirFrame11p&); public: AirFrame11p(const char *name=nullptr, short kind=0); AirFrame11p(const AirFrame11p& other); virtual ~AirFrame11p(); AirFrame11p& operator=(const AirFrame11p& other); virtual AirFrame11p *dup() const override {return new AirFrame11p(*this);} virtual void parsimPack(omnetpp::cCommBuffer *b) const override; virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; // field getter/setter methods virtual bool getUnderMinPowerLevel() const; virtual void setUnderMinPowerLevel(bool underMinPowerLevel); virtual bool getWasTransmitting() const; virtual void setWasTransmitting(bool wasTransmitting); }; inline void doParsimPacking(omnetpp::cCommBuffer *b, const AirFrame11p& obj) {obj.parsimPack(b);} inline void doParsimUnpacking(omnetpp::cCommBuffer *b, AirFrame11p& obj) {obj.parsimUnpack(b);} } // namespace veins #endif // ifndef __VEINS_AIRFRAME11P_M_H
2,391
26.494253
121
h
null
AICP-main/veins/src/veins/modules/messages/BaseFrame1609_4_m.h
// // Generated file, do not edit! Created by nedtool 5.5 from veins/modules/messages/BaseFrame1609_4.msg. // #ifndef __VEINS_BASEFRAME1609_4_M_H #define __VEINS_BASEFRAME1609_4_M_H #if defined(__clang__) # pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #include <omnetpp.h> // nedtool version check #define MSGC_VERSION 0x0505 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. #endif // dll export symbol #ifndef VEINS_API # if defined(VEINS_EXPORT) # define VEINS_API OPP_DLLEXPORT # elif defined(VEINS_IMPORT) # define VEINS_API OPP_DLLIMPORT # else # define VEINS_API # endif #endif // cplusplus {{ #include "veins/base/utils/SimpleAddress.h" // }} namespace veins { /** * Class generated from <tt>veins/modules/messages/BaseFrame1609_4.msg:31</tt> by nedtool. * <pre> * packet BaseFrame1609_4 * { * //Channel Number on which this packet was sent * int channelNumber; * //User priority with which this packet was sent (note the AC mapping rules in Mac1609_4::mapUserPriority) * int userPriority = 7; * //Unique number to identify the service * int psid = 0; * //Recipient of frame (-1 for any) * LAddress::L2Type recipientAddress = -1; * } * </pre> */ class VEINS_API BaseFrame1609_4 : public ::omnetpp::cPacket { protected: int channelNumber; int userPriority; int psid; LAddress::L2Type recipientAddress; private: void copy(const BaseFrame1609_4& other); protected: // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const BaseFrame1609_4&); public: BaseFrame1609_4(const char *name=nullptr, short kind=0); BaseFrame1609_4(const BaseFrame1609_4& other); virtual ~BaseFrame1609_4(); BaseFrame1609_4& operator=(const BaseFrame1609_4& other); virtual BaseFrame1609_4 *dup() const override {return new BaseFrame1609_4(*this);} virtual void parsimPack(omnetpp::cCommBuffer *b) const override; virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; // field getter/setter methods virtual int getChannelNumber() const; virtual void setChannelNumber(int channelNumber); virtual int getUserPriority() const; virtual void setUserPriority(int userPriority); virtual int getPsid() const; virtual void setPsid(int psid); virtual LAddress::L2Type& getRecipientAddress(); virtual const LAddress::L2Type& getRecipientAddress() const {return const_cast<BaseFrame1609_4*>(this)->getRecipientAddress();} virtual void setRecipientAddress(const LAddress::L2Type& recipientAddress); }; inline void doParsimPacking(omnetpp::cCommBuffer *b, const BaseFrame1609_4& obj) {obj.parsimPack(b);} inline void doParsimUnpacking(omnetpp::cCommBuffer *b, BaseFrame1609_4& obj) {obj.parsimUnpack(b);} } // namespace veins #endif // ifndef __VEINS_BASEFRAME1609_4_M_H
2,987
30.125
131
h
null
AICP-main/veins/src/veins/modules/messages/DemoSafetyMessage_m.h
// // Generated file, do not edit! Created by nedtool 5.5 from veins/modules/messages/DemoSafetyMessage.msg. // #ifndef __VEINS_DEMOSAFETYMESSAGE_M_H #define __VEINS_DEMOSAFETYMESSAGE_M_H #if defined(__clang__) # pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #include <omnetpp.h> // nedtool version check #define MSGC_VERSION 0x0505 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. #endif // dll export symbol #ifndef VEINS_API # if defined(VEINS_EXPORT) # define VEINS_API OPP_DLLEXPORT # elif defined(VEINS_IMPORT) # define VEINS_API OPP_DLLIMPORT # else # define VEINS_API # endif #endif // cplusplus {{ #include "veins/base/utils/Coord.h" #include "veins/modules/messages/BaseFrame1609_4_m.h" #include "veins/base/utils/SimpleAddress.h" // }} namespace veins { /** * Class generated from <tt>veins/modules/messages/DemoSafetyMessage.msg:35</tt> by nedtool. * <pre> * packet DemoSafetyMessage extends BaseFrame1609_4 * { * Coord senderPos; * Coord senderSpeed; * int serial = 0; * double angle = 0; * } * </pre> */ class VEINS_API DemoSafetyMessage : public ::veins::BaseFrame1609_4 { protected: Coord senderPos; Coord senderSpeed; int serial; double angle; private: void copy(const DemoSafetyMessage& other); protected: // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const DemoSafetyMessage&); public: DemoSafetyMessage(const char *name=nullptr, short kind=0); DemoSafetyMessage(const DemoSafetyMessage& other); virtual ~DemoSafetyMessage(); DemoSafetyMessage& operator=(const DemoSafetyMessage& other); virtual DemoSafetyMessage *dup() const override {return new DemoSafetyMessage(*this);} virtual void parsimPack(omnetpp::cCommBuffer *b) const override; virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; // field getter/setter methods virtual Coord& getSenderPos(); virtual const Coord& getSenderPos() const {return const_cast<DemoSafetyMessage*>(this)->getSenderPos();} virtual void setSenderPos(const Coord& senderPos); virtual Coord& getSenderSpeed(); virtual const Coord& getSenderSpeed() const {return const_cast<DemoSafetyMessage*>(this)->getSenderSpeed();} virtual void setSenderSpeed(const Coord& senderSpeed); virtual int getSerial() const; virtual void setSerial(int serial); virtual double getAngle() const; virtual void setAngle(double angle); }; inline void doParsimPacking(omnetpp::cCommBuffer *b, const DemoSafetyMessage& obj) {obj.parsimPack(b);} inline void doParsimUnpacking(omnetpp::cCommBuffer *b, DemoSafetyMessage& obj) {obj.parsimUnpack(b);} } // namespace veins #endif // ifndef __VEINS_DEMOSAFETYMESSAGE_M_H
2,883
29.357895
121
h
null
AICP-main/veins/src/veins/modules/messages/DemoServiceAdvertisement_m.h
// // Generated file, do not edit! Created by nedtool 5.5 from veins/modules/messages/DemoServiceAdvertisement.msg. // #ifndef __VEINS_DEMOSERVICEADVERTISEMENT_M_H #define __VEINS_DEMOSERVICEADVERTISEMENT_M_H #if defined(__clang__) # pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #include <omnetpp.h> // nedtool version check #define MSGC_VERSION 0x0505 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. #endif // dll export symbol #ifndef VEINS_API # if defined(VEINS_EXPORT) # define VEINS_API OPP_DLLEXPORT # elif defined(VEINS_IMPORT) # define VEINS_API OPP_DLLIMPORT # else # define VEINS_API # endif #endif // cplusplus {{ #include "veins/base/utils/Coord.h" #include "veins/modules/messages/BaseFrame1609_4_m.h" // }} namespace veins { /** * Class generated from <tt>veins/modules/messages/DemoServiceAdvertisement.msg:33</tt> by nedtool. * <pre> * packet DemoServiceAdvertisment extends BaseFrame1609_4 * { * int targetChannel; * string serviceDescription; * } * </pre> */ class VEINS_API DemoServiceAdvertisment : public ::veins::BaseFrame1609_4 { protected: int targetChannel; ::omnetpp::opp_string serviceDescription; private: void copy(const DemoServiceAdvertisment& other); protected: // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const DemoServiceAdvertisment&); public: DemoServiceAdvertisment(const char *name=nullptr, short kind=0); DemoServiceAdvertisment(const DemoServiceAdvertisment& other); virtual ~DemoServiceAdvertisment(); DemoServiceAdvertisment& operator=(const DemoServiceAdvertisment& other); virtual DemoServiceAdvertisment *dup() const override {return new DemoServiceAdvertisment(*this);} virtual void parsimPack(omnetpp::cCommBuffer *b) const override; virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; // field getter/setter methods virtual int getTargetChannel() const; virtual void setTargetChannel(int targetChannel); virtual const char * getServiceDescription() const; virtual void setServiceDescription(const char * serviceDescription); }; inline void doParsimPacking(omnetpp::cCommBuffer *b, const DemoServiceAdvertisment& obj) {obj.parsimPack(b);} inline void doParsimUnpacking(omnetpp::cCommBuffer *b, DemoServiceAdvertisment& obj) {obj.parsimUnpack(b);} } // namespace veins #endif // ifndef __VEINS_DEMOSERVICEADVERTISEMENT_M_H
2,575
29.666667
121
h
null
AICP-main/veins/src/veins/modules/messages/Mac80211Ack_m.h
// // Generated file, do not edit! Created by nedtool 5.5 from veins/modules/messages/Mac80211Ack.msg. // #ifndef __VEINS_MAC80211ACK_M_H #define __VEINS_MAC80211ACK_M_H #if defined(__clang__) # pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #include <omnetpp.h> // nedtool version check #define MSGC_VERSION 0x0505 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. #endif // dll export symbol #ifndef VEINS_API # if defined(VEINS_EXPORT) # define VEINS_API OPP_DLLEXPORT # elif defined(VEINS_IMPORT) # define VEINS_API OPP_DLLIMPORT # else # define VEINS_API # endif #endif // cplusplus {{ #include "veins/modules/messages/Mac80211Pkt_m.h" // }} namespace veins { /** * Class generated from <tt>veins/modules/messages/Mac80211Ack.msg:31</tt> by nedtool. * <pre> * packet Mac80211Ack extends Mac80211Pkt * { * unsigned long messageId; // The ID of the aknowledged packet * } * </pre> */ class VEINS_API Mac80211Ack : public ::veins::Mac80211Pkt { protected: unsigned long messageId; private: void copy(const Mac80211Ack& other); protected: // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const Mac80211Ack&); public: Mac80211Ack(const char *name=nullptr, short kind=0); Mac80211Ack(const Mac80211Ack& other); virtual ~Mac80211Ack(); Mac80211Ack& operator=(const Mac80211Ack& other); virtual Mac80211Ack *dup() const override {return new Mac80211Ack(*this);} virtual void parsimPack(omnetpp::cCommBuffer *b) const override; virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; // field getter/setter methods virtual unsigned long getMessageId() const; virtual void setMessageId(unsigned long messageId); }; inline void doParsimPacking(omnetpp::cCommBuffer *b, const Mac80211Ack& obj) {obj.parsimPack(b);} inline void doParsimUnpacking(omnetpp::cCommBuffer *b, Mac80211Ack& obj) {obj.parsimUnpack(b);} } // namespace veins #endif // ifndef __VEINS_MAC80211ACK_M_H
2,145
26.164557
121
h
null
AICP-main/veins/src/veins/modules/messages/Mac80211Pkt_m.h
// // Generated file, do not edit! Created by nedtool 5.5 from veins/modules/messages/Mac80211Pkt.msg. // #ifndef __VEINS_MAC80211PKT_M_H #define __VEINS_MAC80211PKT_M_H #if defined(__clang__) # pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #include <omnetpp.h> // nedtool version check #define MSGC_VERSION 0x0505 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. #endif // dll export symbol #ifndef VEINS_API # if defined(VEINS_EXPORT) # define VEINS_API OPP_DLLEXPORT # elif defined(VEINS_IMPORT) # define VEINS_API OPP_DLLIMPORT # else # define VEINS_API # endif #endif // cplusplus {{ #include "veins/base/messages/MacPkt_m.h" // }} namespace veins { /** * Class generated from <tt>veins/modules/messages/Mac80211Pkt.msg:39</tt> by nedtool. * <pre> * // * // Defines all fields of an 802.11 MAC frame * // * packet Mac80211Pkt extends MacPkt * { * int address3; * int address4; * int fragmentation; //part of the Frame Control field * int informationDS; //part of the Frame Control field * int sequenceControl; * bool retry; * simtime_t duration; //the expected remaining duration the current transaction * } * </pre> */ class VEINS_API Mac80211Pkt : public ::veins::MacPkt { protected: int address3; int address4; int fragmentation; int informationDS; int sequenceControl; bool retry; ::omnetpp::simtime_t duration; private: void copy(const Mac80211Pkt& other); protected: // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const Mac80211Pkt&); public: Mac80211Pkt(const char *name=nullptr, short kind=0); Mac80211Pkt(const Mac80211Pkt& other); virtual ~Mac80211Pkt(); Mac80211Pkt& operator=(const Mac80211Pkt& other); virtual Mac80211Pkt *dup() const override {return new Mac80211Pkt(*this);} virtual void parsimPack(omnetpp::cCommBuffer *b) const override; virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; // field getter/setter methods virtual int getAddress3() const; virtual void setAddress3(int address3); virtual int getAddress4() const; virtual void setAddress4(int address4); virtual int getFragmentation() const; virtual void setFragmentation(int fragmentation); virtual int getInformationDS() const; virtual void setInformationDS(int informationDS); virtual int getSequenceControl() const; virtual void setSequenceControl(int sequenceControl); virtual bool getRetry() const; virtual void setRetry(bool retry); virtual ::omnetpp::simtime_t getDuration() const; virtual void setDuration(::omnetpp::simtime_t duration); }; inline void doParsimPacking(omnetpp::cCommBuffer *b, const Mac80211Pkt& obj) {obj.parsimPack(b);} inline void doParsimUnpacking(omnetpp::cCommBuffer *b, Mac80211Pkt& obj) {obj.parsimUnpack(b);} } // namespace veins #endif // ifndef __VEINS_MAC80211PKT_M_H
3,084
28.103774
121
h
null
AICP-main/veins/src/veins/modules/messages/PhyControlMessage_m.h
// // Generated file, do not edit! Created by nedtool 5.5 from veins/modules/messages/PhyControlMessage.msg. // #ifndef __VEINS_PHYCONTROLMESSAGE_M_H #define __VEINS_PHYCONTROLMESSAGE_M_H #if defined(__clang__) # pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #include <omnetpp.h> // nedtool version check #define MSGC_VERSION 0x0505 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. #endif // dll export symbol #ifndef VEINS_API # if defined(VEINS_EXPORT) # define VEINS_API OPP_DLLEXPORT # elif defined(VEINS_IMPORT) # define VEINS_API OPP_DLLIMPORT # else # define VEINS_API # endif #endif namespace veins { /** * Class generated from <tt>veins/modules/messages/PhyControlMessage.msg:29</tt> by nedtool. * <pre> * // * // Defines a control message that can be associated with a MAC frame to set * // transmission power and datarate on a per packet basis * // * message PhyControlMessage * { * //modulation and coding scheme to be used (see enum TxMCS in ConstsPhy.h) * int mcs = -1; * //transmission power to be used in mW * double txPower_mW = -1; * } * </pre> */ class VEINS_API PhyControlMessage : public ::omnetpp::cMessage { protected: int mcs; double txPower_mW; private: void copy(const PhyControlMessage& other); protected: // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const PhyControlMessage&); public: PhyControlMessage(const char *name=nullptr, short kind=0); PhyControlMessage(const PhyControlMessage& other); virtual ~PhyControlMessage(); PhyControlMessage& operator=(const PhyControlMessage& other); virtual PhyControlMessage *dup() const override {return new PhyControlMessage(*this);} virtual void parsimPack(omnetpp::cCommBuffer *b) const override; virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; // field getter/setter methods virtual int getMcs() const; virtual void setMcs(int mcs); virtual double getTxPower_mW() const; virtual void setTxPower_mW(double txPower_mW); }; inline void doParsimPacking(omnetpp::cCommBuffer *b, const PhyControlMessage& obj) {obj.parsimPack(b);} inline void doParsimUnpacking(omnetpp::cCommBuffer *b, PhyControlMessage& obj) {obj.parsimUnpack(b);} } // namespace veins #endif // ifndef __VEINS_PHYCONTROLMESSAGE_M_H
2,485
28.247059
121
h
null
AICP-main/veins/src/veins/modules/messages/TraCITrafficLightMessage_m.h
// // Generated file, do not edit! Created by nedtool 5.5 from veins/modules/messages/TraCITrafficLightMessage.msg. // #ifndef __VEINS_TRACITRAFFICLIGHTMESSAGE_M_H #define __VEINS_TRACITRAFFICLIGHTMESSAGE_M_H #if defined(__clang__) # pragma clang diagnostic ignored "-Wreserved-id-macro" #endif #include <omnetpp.h> // nedtool version check #define MSGC_VERSION 0x0505 #if (MSGC_VERSION!=OMNETPP_VERSION) # error Version mismatch! Probably this file was generated by an earlier version of nedtool: 'make clean' should help. #endif // dll export symbol #ifndef VEINS_API # if defined(VEINS_EXPORT) # define VEINS_API OPP_DLLEXPORT # elif defined(VEINS_IMPORT) # define VEINS_API OPP_DLLIMPORT # else # define VEINS_API # endif #endif namespace veins { /** * Enum generated from <tt>veins/modules/messages/TraCITrafficLightMessage.msg:26</tt> by nedtool. * <pre> * enum TrafficLightAtrributeType * { * NONE = 0; * LOGICID = 1; * PHASEID = 2; * SWITCHTIME = 3; * STATE = 4; * } * </pre> */ enum TrafficLightAtrributeType { NONE = 0, LOGICID = 1, PHASEID = 2, SWITCHTIME = 3, STATE = 4 }; /** * Enum generated from <tt>veins/modules/messages/TraCITrafficLightMessage.msg:34</tt> by nedtool. * <pre> * enum TrafficLightChangeSource * { * UNKNOWN = 0; * SUMO = 1; * LOGIC = 2; * RSU = 3;//If an RSU tries to change the values * } * </pre> */ enum TrafficLightChangeSource { UNKNOWN = 0, SUMO = 1, LOGIC = 2, RSU = 3 }; /** * Class generated from <tt>veins/modules/messages/TraCITrafficLightMessage.msg:42</tt> by nedtool. * <pre> * // NOTE: Currently only supports changes of the IDs (due to variation in field types) * message TraCITrafficLightMessage * { * // traffic light id * string tlId; * // what field/attrbute of the traffic light changed? * int changedAttribute \@enum(TrafficLightAtrributeType); * // value before the change * string oldValue; * // value that is to be set / was newly set * string newValue; * // where did the change originate * int changeSource \@enum(TrafficLightChangeSource); * } * </pre> */ class VEINS_API TraCITrafficLightMessage : public ::omnetpp::cMessage { protected: ::omnetpp::opp_string tlId; int changedAttribute; ::omnetpp::opp_string oldValue; ::omnetpp::opp_string newValue; int changeSource; private: void copy(const TraCITrafficLightMessage& other); protected: // protected and unimplemented operator==(), to prevent accidental usage bool operator==(const TraCITrafficLightMessage&); public: TraCITrafficLightMessage(const char *name=nullptr, short kind=0); TraCITrafficLightMessage(const TraCITrafficLightMessage& other); virtual ~TraCITrafficLightMessage(); TraCITrafficLightMessage& operator=(const TraCITrafficLightMessage& other); virtual TraCITrafficLightMessage *dup() const override {return new TraCITrafficLightMessage(*this);} virtual void parsimPack(omnetpp::cCommBuffer *b) const override; virtual void parsimUnpack(omnetpp::cCommBuffer *b) override; // field getter/setter methods virtual const char * getTlId() const; virtual void setTlId(const char * tlId); virtual int getChangedAttribute() const; virtual void setChangedAttribute(int changedAttribute); virtual const char * getOldValue() const; virtual void setOldValue(const char * oldValue); virtual const char * getNewValue() const; virtual void setNewValue(const char * newValue); virtual int getChangeSource() const; virtual void setChangeSource(int changeSource); }; inline void doParsimPacking(omnetpp::cCommBuffer *b, const TraCITrafficLightMessage& obj) {obj.parsimPack(b);} inline void doParsimUnpacking(omnetpp::cCommBuffer *b, TraCITrafficLightMessage& obj) {obj.parsimUnpack(b);} } // namespace veins #endif // ifndef __VEINS_TRACITRAFFICLIGHTMESSAGE_M_H
3,978
28.043796
121
h
null
AICP-main/veins/src/veins/modules/mobility/LinearMobility.h
// // Copyright (C) 2005 Emin Ilker Cetinbas // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // author: Emin Ilker Cetinbas (niw3_at_yahoo_d0t_com) // part of: framework implementation developed by tkn #pragma once #include "veins/base/modules/BaseMobility.h" namespace veins { /** * @brief Linear movement model. See NED file for more info. * * This mobility module expects a torus as playground ("useTorus" * Parameter of BaseWorldUtility module). * * NOTE: Does not yet support 3-dimensional movement. * @ingroup mobility * @author Emin Ilker Cetinbas */ class VEINS_API LinearMobility : public BaseMobility { protected: double angle; ///< angle of linear motion double acceleration; ///< acceleration of linear motion /** @brief always stores the last step for position display update */ Coord stepTarget; public: /** @brief Initializes mobility model parameters.*/ void initialize(int) override; protected: /** @brief Move the host*/ void makeMove() override; void fixIfHostGetsOutside() override; }; } // namespace veins
1,878
29.306452
76
h
null
AICP-main/veins/src/veins/modules/mobility/traci/ParBuffer.h
// // Copyright (C) 2019 Michele Segata <segata@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <cstddef> #include <string> #include <sstream> namespace veins { class VEINS_API ParBuffer { public: ParBuffer() : SEP(':') { } ParBuffer(std::string buf) : SEP(':') { inBuffer = buf; } template <typename T> ParBuffer& operator<<(const T& v) { if (outBuffer.str().length() == 0) outBuffer << v; else outBuffer << SEP << v; return *this; } std::string next() { std::string value; size_t sep; if (inBuffer.size() == 0) return ""; sep = inBuffer.find(SEP); if (sep == std::string::npos) { value = inBuffer; inBuffer = ""; } else { value = inBuffer.substr(0, sep); inBuffer = inBuffer.substr(sep + 1); } return value; } ParBuffer& operator>>(double& v) { std::string value = next(); sscanf(value.c_str(), "%lf", &v); return *this; } ParBuffer& operator>>(int& v) { std::string value = next(); sscanf(value.c_str(), "%d", &v); return *this; } ParBuffer& operator>>(std::string& v) { v = next(); return *this; } void set(std::string buf) { inBuffer = buf; } void clear() { outBuffer.clear(); } std::string str() const { return outBuffer.str(); } private: const char SEP; std::stringstream outBuffer; std::string inBuffer; }; } // namespace veins
2,488
21.423423
76
h
null
AICP-main/veins/src/veins/modules/mobility/traci/TraCIBuffer.h
// // Copyright (C) 2006 Christoph Sommer <sommer@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <cstddef> #include <string> #include "veins/veins.h" #include "veins/modules/mobility/traci/TraCIConstants.h" namespace veins { struct TraCICoord; bool VEINS_API isBigEndian(); /** * Byte-buffer that stores values in TraCI byte-order */ class VEINS_API TraCIBuffer { public: TraCIBuffer(); TraCIBuffer(std::string buf); template <typename T> T read() { T buf_to_return; unsigned char* p_buf_to_return = reinterpret_cast<unsigned char*>(&buf_to_return); if (isBigEndian()) { for (size_t i = 0; i < sizeof(buf_to_return); ++i) { if (eof()) throw cRuntimeError("Attempted to read past end of byte buffer"); p_buf_to_return[i] = buf[buf_index++]; } } else { for (size_t i = 0; i < sizeof(buf_to_return); ++i) { if (eof()) throw cRuntimeError("Attempted to read past end of byte buffer"); p_buf_to_return[sizeof(buf_to_return) - 1 - i] = buf[buf_index++]; } } return buf_to_return; } template <typename T> void write(T inv) { unsigned char* p_buf_to_send = reinterpret_cast<unsigned char*>(&inv); if (isBigEndian()) { for (size_t i = 0; i < sizeof(inv); ++i) { buf += p_buf_to_send[i]; } } else { for (size_t i = 0; i < sizeof(inv); ++i) { buf += p_buf_to_send[sizeof(inv) - 1 - i]; } } } void readBuffer(unsigned char* buffer, size_t size) { if (isBigEndian()) { for (size_t i = 0; i < size; ++i) { if (eof()) throw cRuntimeError("Attempted to read past end of byte buffer"); buffer[i] = buf[buf_index++]; } } else { for (size_t i = 0; i < size; ++i) { if (eof()) throw cRuntimeError("Attempted to read past end of byte buffer"); buffer[size - 1 - i] = buf[buf_index++]; } } } template <typename T> T read(T& out) { out = read<T>(); return out; } template <typename T> TraCIBuffer& operator>>(T& out) { out = read<T>(); return *this; } template <typename T> TraCIBuffer& operator<<(const T& inv) { write(inv); return *this; } /** * @brief * read and check type, then read and return an item from the buffer */ template <typename T> T readTypeChecked(int expectedTraCIType) { uint8_t read_type(read<uint8_t>()); ASSERT(read_type == static_cast<uint8_t>(expectedTraCIType)); return read<T>(); } bool eof() const; void set(std::string buf); void clear(); std::string str() const; std::string hexStr() const; static void setTimeType(uint8_t val) { if (val != TraCIConstants::TYPE_INTEGER && val != TraCIConstants::TYPE_DOUBLE) { throw cRuntimeError("Invalid time data type"); } timeAsDouble = val == TraCIConstants::TYPE_DOUBLE; } private: std::string buf; size_t buf_index; static bool timeAsDouble; }; template <> std::vector<std::string> TraCIBuffer::readTypeChecked(int expectedTraCIType); template <> void VEINS_API TraCIBuffer::write(std::string inv); template <> void TraCIBuffer::write(TraCICoord inv); template <> std::string VEINS_API TraCIBuffer::read(); template <> TraCICoord TraCIBuffer::read(); template <> void TraCIBuffer::write(simtime_t o); template <> simtime_t TraCIBuffer::read(); } // namespace veins
4,581
25.952941
92
h
null
AICP-main/veins/src/veins/modules/mobility/traci/TraCIColor.h
// // Copyright (C) 2006-2011 Christoph Sommer <christoph.sommer@uibk.ac.at> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/veins.h" namespace veins { /** * TraCI compatible color container */ class VEINS_API TraCIColor { public: TraCIColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha); static TraCIColor fromTkColor(std::string tkColorName); public: uint8_t red; uint8_t green; uint8_t blue; uint8_t alpha; }; } // namespace veins
1,293
27.755556
76
h
null
AICP-main/veins/src/veins/modules/mobility/traci/TraCIConnection.h
// // Copyright (C) 2006 Christoph Sommer <sommer@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <stdint.h> #include <memory> #include "veins/modules/mobility/traci/TraCIBuffer.h" #include "veins/modules/mobility/traci/TraCICoord.h" #include "veins/modules/mobility/traci/TraCICoordinateTransformation.h" #include "veins/base/utils/Coord.h" #include "veins/base/utils/Heading.h" #include "veins/modules/utility/HasLogProxy.h" namespace veins { class VEINS_API TraCIConnection : public HasLogProxy { public: class VEINS_API Result { public: Result(); Result(bool success, bool not_impl, std::string message); bool success; bool not_impl; std::string message; }; static TraCIConnection* connect(cComponent* owner, const char* host, int port); void setNetbounds(TraCICoord netbounds1, TraCICoord netbounds2, int margin); ~TraCIConnection(); /** * sends a single command via TraCI, checks status response, returns additional responses. * @param commandId: command to send * @param buf: additional parameters to send * @param result: where to store return value (if set to nullptr, any return value other than RTYPE_OK will trigger an exception). */ TraCIBuffer query(uint8_t commandId, const TraCIBuffer& buf = TraCIBuffer(), Result* result = nullptr); /** * sends a message via TraCI (after adding the header) */ void sendMessage(std::string buf); /** * receives a message via TraCI (and strips the header) */ std::string receiveMessage(); /** * convert TraCI heading to OMNeT++ heading (in rad) */ Heading traci2omnetHeading(double heading) const; /** * convert OMNeT++ heading (in rad) to TraCI heading */ double omnet2traciHeading(Heading heading) const; /** * convert TraCI coordinates to OMNeT++ coordinates */ Coord traci2omnet(TraCICoord coord) const; std::list<Coord> traci2omnet(const std::list<TraCICoord>&) const; /** * convert OMNeT++ coordinates to TraCI coordinates */ TraCICoord omnet2traci(Coord coord) const; std::list<TraCICoord> omnet2traci(const std::list<Coord>&) const; private: TraCIConnection(cComponent* owner, void* ptr); void* socketPtr; std::unique_ptr<TraCICoordinateTransformation> coordinateTransformation; }; /** * returns byte-buffer containing a TraCI command with optional parameters */ std::string makeTraCICommand(uint8_t commandId, const TraCIBuffer& buf = TraCIBuffer()); } // namespace veins
3,398
31.066038
134
h
null
AICP-main/veins/src/veins/modules/mobility/traci/TraCIConstants.h
// // Copyright (C) 2019 Universidad Nacional de Colombia, Politecnico Jaime Isaza Cadavid. // Copyright (C) 2019 Andres Acosta, Jorge Espinosa, Jairo Espinosa // Copyright (C) 2009 Rodney Thomson // Copyright (C) 2008 Rodney Thomson // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: BSD-3-Clause // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution // * Neither the name of Universidad Nacional de Colombia, Politécnico Jaime Isaza Cadavid nor the names of its // contributors may be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // TraCI4Matlab 3.0.0.0 // $Id: constants.m 53 2019-01-03 15:18:31Z afacostag $ // The SUMO hexadecimal constants. // Authors: Andres Acosta, Jairo Espinosa, Jorge Espinosa. #pragma once namespace veins { namespace TraCIConstants { const uint32_t TRACI_VERSION = 19; const double INVALID_DOUBLE_VALUE = -1073741824; const int32_t INVALID_INT_VALUE = -1073741824; const uint8_t ADD = 0x80; const uint8_t ADD_FULL = 0x85; const uint8_t APPEND_STAGE = 0xc4; const int8_t ARRIVALFLAG_LANE_CURRENT = -0x02; const int8_t ARRIVALFLAG_POS_MAX = -0x03; const int8_t ARRIVALFLAG_POS_RANDOM = -0x02; const int8_t ARRIVALFLAG_SPEED_CURRENT = -0x02; const uint8_t AUTOMATIC_CONTEXT_SUBSCRIPTION = 0x03; const uint8_t AUTOMATIC_VARIABLES_SUBSCRIPTION = 0x02; const uint8_t CMD_ADD_SUBSCRIPTION_FILTER = 0x7e; const uint8_t CMD_CHANGELANE = 0x13; const uint8_t CMD_CHANGESUBLANE = 0x15; const uint8_t CMD_CHANGETARGET = 0x31; const uint8_t CMD_CLEAR_PENDING_VEHICLES = 0x94; const uint8_t CMD_CLOSE = 0x7F; const uint8_t CMD_GETVERSION = 0x00; const uint8_t CMD_GET_EDGE_VARIABLE = 0xaa; const uint8_t CMD_GET_GUI_VARIABLE = 0xac; const uint8_t CMD_GET_INDUCTIONLOOP_VARIABLE = 0xa0; const uint8_t CMD_GET_JUNCTION_VARIABLE = 0xa9; const uint8_t CMD_GET_LANEAREA_VARIABLE = 0xad; const uint8_t CMD_GET_LANE_VARIABLE = 0xa3; const uint8_t CMD_GET_MULTIENTRYEXIT_VARIABLE = 0xa1; // renamed for compatibility const uint8_t CMD_GET_PERSON_VARIABLE = 0xae; const uint8_t CMD_GET_POI_VARIABLE = 0xa7; const uint8_t CMD_GET_POLYGON_VARIABLE = 0xa8; const uint8_t CMD_GET_ROUTE_VARIABLE = 0xa6; const uint8_t CMD_GET_SIM_VARIABLE = 0xab; const uint8_t CMD_GET_TL_VARIABLE = 0xa2; const uint8_t CMD_GET_VEHICLETYPE_VARIABLE = 0xa5; const uint8_t CMD_GET_VEHICLE_VARIABLE = 0xa4; const uint8_t CMD_LOAD = 0x01; const uint8_t CMD_OPENGAP = 0x16; const uint8_t CMD_REROUTE_EFFORT = 0x91; const uint8_t CMD_REROUTE_TO_PARKING = 0xc2; const uint8_t CMD_REROUTE_TRAVELTIME = 0x90; const uint8_t CMD_RESUME = 0x19; const uint8_t CMD_SAVE_SIMSTATE = 0x95; const uint8_t CMD_SETORDER = 0x03; const uint8_t CMD_SET_EDGE_VARIABLE = 0xca; const uint8_t CMD_SET_GUI_VARIABLE = 0xcc; const uint8_t CMD_SET_JUNCTION_VARIABLE = 0xc9; const uint8_t CMD_SET_LANE_VARIABLE = 0xc3; const uint8_t CMD_SET_PERSON_VARIABLE = 0xce; const uint8_t CMD_SET_POI_VARIABLE = 0xc7; const uint8_t CMD_SET_POLYGON_VARIABLE = 0xc8; const uint8_t CMD_SET_ROUTE_VARIABLE = 0xc6; const uint8_t CMD_SET_SIM_VARIABLE = 0xcb; const uint8_t CMD_SET_TL_VARIABLE = 0xc2; const uint8_t CMD_SET_VEHICLETYPE_VARIABLE = 0xc5; const uint8_t CMD_SET_VEHICLE_VARIABLE = 0xc4; const uint8_t CMD_SIMSTEP = 0x02; const uint8_t CMD_SIMSTEP2 = 0x02; // Veins specific (called CMD_SIMSTEP in TraCI) const uint8_t CMD_SLOWDOWN = 0x14; const uint8_t CMD_STOP = 0x12; const uint8_t CMD_SUBSCRIBE_EDGE_CONTEXT = 0x8a; const uint8_t CMD_SUBSCRIBE_EDGE_VARIABLE = 0xda; const uint8_t CMD_SUBSCRIBE_GUI_CONTEXT = 0x8c; const uint8_t CMD_SUBSCRIBE_GUI_VARIABLE = 0xdc; const uint8_t CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT = 0x80; const uint8_t CMD_SUBSCRIBE_INDUCTIONLOOP_VARIABLE = 0xd0; const uint8_t CMD_SUBSCRIBE_JUNCTION_CONTEXT = 0x89; const uint8_t CMD_SUBSCRIBE_JUNCTION_VARIABLE = 0xd9; const uint8_t CMD_SUBSCRIBE_LANEAREA_CONTEXT = 0x8d; const uint8_t CMD_SUBSCRIBE_LANEAREA_VARIABLE = 0xdd; const uint8_t CMD_SUBSCRIBE_LANE_CONTEXT = 0x83; const uint8_t CMD_SUBSCRIBE_LANE_VARIABLE = 0xd3; const uint8_t CMD_SUBSCRIBE_MULTIENTRYEXIT_CONTEXT = 0x81; // renamed for compatibility const uint8_t CMD_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE = 0xd1; // renamed for compatibility const uint8_t CMD_SUBSCRIBE_PERSON_CONTEXT = 0x8e; const uint8_t CMD_SUBSCRIBE_PERSON_VARIABLE = 0xde; const uint8_t CMD_SUBSCRIBE_POI_CONTEXT = 0x87; const uint8_t CMD_SUBSCRIBE_POI_VARIABLE = 0xd7; const uint8_t CMD_SUBSCRIBE_POLYGON_CONTEXT = 0x88; const uint8_t CMD_SUBSCRIBE_POLYGON_VARIABLE = 0xd8; const uint8_t CMD_SUBSCRIBE_ROUTE_CONTEXT = 0x86; const uint8_t CMD_SUBSCRIBE_ROUTE_VARIABLE = 0xd6; const uint8_t CMD_SUBSCRIBE_SIM_CONTEXT = 0x8b; const uint8_t CMD_SUBSCRIBE_SIM_VARIABLE = 0xdb; const uint8_t CMD_SUBSCRIBE_TL_CONTEXT = 0x82; const uint8_t CMD_SUBSCRIBE_TL_VARIABLE = 0xd2; const uint8_t CMD_SUBSCRIBE_VEHICLETYPE_CONTEXT = 0x85; const uint8_t CMD_SUBSCRIBE_VEHICLETYPE_VARIABLE = 0xd5; const uint8_t CMD_SUBSCRIBE_VEHICLE_CONTEXT = 0x84; const uint8_t CMD_SUBSCRIBE_VEHICLE_VARIABLE = 0xd4; const uint8_t COPY = 0x88; const int8_t DEPARTFLAG_CONTAINER_TRIGGERED = -0x02; const int8_t DEPARTFLAG_LANE_ALLOWED_FREE = -0x04; const int8_t DEPARTFLAG_LANE_BEST_FREE = -0x05; const int8_t DEPARTFLAG_LANE_FIRST_ALLOWED = -0x06; const int8_t DEPARTFLAG_LANE_FREE = -0x03; const int8_t DEPARTFLAG_LANE_RANDOM = -0x02; const int8_t DEPARTFLAG_NOW = -0x03; const int8_t DEPARTFLAG_POS_BASE = -0x04; const int8_t DEPARTFLAG_POS_FREE = -0x03; const int8_t DEPARTFLAG_POS_LAST = -0x05; const int8_t DEPARTFLAG_POS_RANDOM = -0x02; const int8_t DEPARTFLAG_POS_RANDOM_FREE = -0x06; const int8_t DEPARTFLAG_SPEED_MAX = -0x03; const int8_t DEPARTFLAG_SPEED_RANDOM = -0x02; const int8_t DEPARTFLAG_TRIGGERED = -0x01; const uint8_t DISTANCE_REQUEST = 0x83; const uint8_t FILTER_TYPE_DOWNSTREAM_DIST = 0x03; const uint8_t FILTER_TYPE_LANES = 0x01; const uint8_t FILTER_TYPE_LEAD_FOLLOW = 0x05; const uint8_t FILTER_TYPE_NONE = 0x00; const uint8_t FILTER_TYPE_NOOPPOSITE = 0x02; const uint8_t FILTER_TYPE_TURN = 0x07; const uint8_t FILTER_TYPE_UPSTREAM_DIST = 0x04; const uint8_t FILTER_TYPE_VCLASS = 0x08; const uint8_t FILTER_TYPE_VTYPE = 0x09; const uint8_t FIND_INTERMODAL_ROUTE = 0x87; const uint8_t FIND_ROUTE = 0x86; const uint8_t GENERIC_ATTRIBUTE = 0x03; const uint8_t ID_COUNT = 0x01; const uint8_t ID_LIST = 0x00; const uint8_t JAM_LENGTH_METERS = 0x19; const uint8_t JAM_LENGTH_VEHICLE = 0x18; const uint8_t LANE_ALLOWED = 0x34; const uint8_t LANE_DISALLOWED = 0x35; const uint8_t LANE_EDGE_ID = 0x31; const uint8_t LANE_LINKS = 0x33; const uint8_t LANE_LINK_NUMBER = 0x30; const uint8_t LAST_STEP_LENGTH = 0x15; const uint8_t LAST_STEP_MEAN_SPEED = 0x11; const uint8_t LAST_STEP_OCCUPANCY = 0x13; const uint8_t LAST_STEP_PERSON_ID_LIST = 0x1a; const uint8_t LAST_STEP_TIME_SINCE_DETECTION = 0x16; const uint8_t LAST_STEP_VEHICLE_DATA = 0x17; const uint8_t LAST_STEP_VEHICLE_HALTING_NUMBER = 0x14; const uint8_t LAST_STEP_VEHICLE_ID_LIST = 0x12; const uint8_t LAST_STEP_VEHICLE_NUMBER = 0x10; const int32_t MAX_ORDER = 1073741824; const uint8_t MOVE_TO_XY = 0xb4; const uint8_t OBJECT_VARIABLES_SUBSCRIPTION = 0x02; // Veins specific (called AUTOMATIC_VARIABLES_SUBSCRIPTION in TraCI) const uint8_t POSITION_2D = 0x01; const uint8_t POSITION_3D = 0x03; const uint8_t POSITION_CONVERSION = 0x82; const uint8_t POSITION_LON_LAT = 0x00; const uint8_t POSITION_LON_LAT_ALT = 0x02; const uint8_t POSITION_ROADMAP = 0x04; const uint8_t REMOVE = 0x81; const uint8_t REMOVE_ARRIVED = 0x02; const uint8_t REMOVE_PARKING = 0x01; const uint8_t REMOVE_STAGE = 0xc5; const uint8_t REMOVE_TELEPORT = 0x00; const uint8_t REMOVE_TELEPORT_ARRIVED = 0x04; const uint8_t REMOVE_VAPORIZED = 0x03; const uint8_t REQUEST_AIRDIST = 0x00; const uint8_t REQUEST_DRIVINGDIST = 0x01; const uint8_t RESPONSE_GET_EDGE_VARIABLE = 0xba; const uint8_t RESPONSE_GET_GUI_VARIABLE = 0xbc; const uint8_t RESPONSE_GET_INDUCTIONLOOP_VARIABLE = 0xb0; const uint8_t RESPONSE_GET_JUNCTION_VARIABLE = 0xb9; const uint8_t RESPONSE_GET_LANEAREA_VARIABLE = 0xbd; const uint8_t RESPONSE_GET_LANE_VARIABLE = 0xb3; const uint8_t RESPONSE_GET_MULTIENTRYEXIT_VARIABLE = 0xb1; // renamed for compatibility const uint8_t RESPONSE_GET_PERSON_VARIABLE = 0xbe; const uint8_t RESPONSE_GET_POI_VARIABLE = 0xb7; const uint8_t RESPONSE_GET_POLYGON_VARIABLE = 0xb8; const uint8_t RESPONSE_GET_ROUTE_VARIABLE = 0xb6; const uint8_t RESPONSE_GET_SIM_VARIABLE = 0xbb; const uint8_t RESPONSE_GET_TL_VARIABLE = 0xb2; const uint8_t RESPONSE_GET_VEHICLETYPE_VARIABLE = 0xb5; const uint8_t RESPONSE_GET_VEHICLE_VARIABLE = 0xb4; const uint8_t RESPONSE_SUBSCRIBE_EDGE_CONTEXT = 0x9a; const uint8_t RESPONSE_SUBSCRIBE_EDGE_VARIABLE = 0xea; const uint8_t RESPONSE_SUBSCRIBE_GUI_CONTEXT = 0x9c; const uint8_t RESPONSE_SUBSCRIBE_GUI_VARIABLE = 0xec; const uint8_t RESPONSE_SUBSCRIBE_INDUCTIONLOOP_CONTEXT = 0x90; const uint8_t RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE = 0xe0; const uint8_t RESPONSE_SUBSCRIBE_JUNCTION_CONTEXT = 0x99; const uint8_t RESPONSE_SUBSCRIBE_JUNCTION_VARIABLE = 0xe9; const uint8_t RESPONSE_SUBSCRIBE_LANEAREA_CONTEXT = 0x9d; const uint8_t RESPONSE_SUBSCRIBE_LANEAREA_VARIABLE = 0xed; const uint8_t RESPONSE_SUBSCRIBE_LANE_CONTEXT = 0x93; const uint8_t RESPONSE_SUBSCRIBE_LANE_VARIABLE = 0xe3; const uint8_t RESPONSE_SUBSCRIBE_MULTIENTRYEXIT_CONTEXT = 0x91; // renamed for compatibility const uint8_t RESPONSE_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE = 0xe1; // renamed for compatibility const uint8_t RESPONSE_SUBSCRIBE_PERSON_CONTEXT = 0x9e; const uint8_t RESPONSE_SUBSCRIBE_PERSON_VARIABLE = 0xee; const uint8_t RESPONSE_SUBSCRIBE_POI_CONTEXT = 0x97; const uint8_t RESPONSE_SUBSCRIBE_POI_VARIABLE = 0xe7; const uint8_t RESPONSE_SUBSCRIBE_POLYGON_CONTEXT = 0x98; const uint8_t RESPONSE_SUBSCRIBE_POLYGON_VARIABLE = 0xe8; const uint8_t RESPONSE_SUBSCRIBE_ROUTE_CONTEXT = 0x96; const uint8_t RESPONSE_SUBSCRIBE_ROUTE_VARIABLE = 0xe6; const uint8_t RESPONSE_SUBSCRIBE_SIM_CONTEXT = 0x9b; const uint8_t RESPONSE_SUBSCRIBE_SIM_VARIABLE = 0xeb; const uint8_t RESPONSE_SUBSCRIBE_TL_CONTEXT = 0x92; const uint8_t RESPONSE_SUBSCRIBE_TL_VARIABLE = 0xe2; const uint8_t RESPONSE_SUBSCRIBE_VEHICLETYPE_CONTEXT = 0x95; const uint8_t RESPONSE_SUBSCRIBE_VEHICLETYPE_VARIABLE = 0xe5; const uint8_t RESPONSE_SUBSCRIBE_VEHICLE_CONTEXT = 0x94; const uint8_t RESPONSE_SUBSCRIBE_VEHICLE_VARIABLE = 0xe4; const uint8_t ROUTING_MODE_AGGREGATED = 0x01; const uint8_t ROUTING_MODE_COMBINED = 0x03; const uint8_t ROUTING_MODE_DEFAULT = 0x00; const uint8_t ROUTING_MODE_EFFORT = 0x02; const uint8_t RTYPE_ERR = 0xFF; const uint8_t RTYPE_NOTIMPLEMENTED = 0x01; const uint8_t RTYPE_OK = 0x00; const uint8_t STAGE_DRIVING = 0x03; const uint8_t STAGE_WAITING = 0x01; const uint8_t STAGE_WAITING_FOR_DEPART = 0x00; const uint8_t STAGE_WALKING = 0x02; const uint8_t STOP_BUS_STOP = 0x08; const uint8_t STOP_CHARGING_STATION = 0x20; const uint8_t STOP_CONTAINER_STOP = 0x10; const uint8_t STOP_CONTAINER_TRIGGERED = 0x04; const uint8_t STOP_DEFAULT = 0x00; const uint8_t STOP_PARKING = 0x01; const uint8_t STOP_PARKING_AREA = 0x40; const uint8_t STOP_TRIGGERED = 0x02; const uint8_t SURROUNDING_VARIABLES_SUBSCRIPTION = 0x03; // Veins specific (called AUTOMATIC_CONTEXT_SUBSCRIPTION in TraCI) const uint8_t TL_COMPLETE_DEFINITION_RYG = 0x2b; const uint8_t TL_COMPLETE_PROGRAM_RYG = 0x2c; const uint8_t TL_CONTROLLED_JUNCTIONS = 0x2a; const uint8_t TL_CONTROLLED_LANES = 0x26; const uint8_t TL_CONTROLLED_LINKS = 0x27; const uint8_t TL_CURRENT_PHASE = 0x28; const uint8_t TL_CURRENT_PROGRAM = 0x29; const uint8_t TL_EXTERNAL_STATE = 0x2e; const uint8_t TL_NEXT_SWITCH = 0x2d; const uint8_t TL_PHASE_DURATION = 0x24; const uint8_t TL_PHASE_INDEX = 0x22; const uint8_t TL_PROGRAM = 0x23; const uint8_t TL_RED_YELLOW_GREEN_STATE = 0x20; const uint8_t TYPE_BOUNDINGBOX = 0x05; // Retained for backwards compatibility const uint8_t TYPE_BYTE = 0x08; const uint8_t TYPE_COLOR = 0x11; const uint8_t TYPE_COMPOUND = 0x0F; const uint8_t TYPE_DOUBLE = 0x0B; const uint8_t TYPE_INTEGER = 0x09; const uint8_t TYPE_POLYGON = 0x06; const uint8_t TYPE_STRING = 0x0C; const uint8_t TYPE_STRINGLIST = 0x0E; const uint8_t TYPE_UBYTE = 0x07; const uint8_t VAR_ACCEL = 0x46; const uint8_t VAR_ACCELERATION = 0x72; const uint8_t VAR_ACCUMULATED_WAITING_TIME = 0x87; const uint8_t VAR_ACTIONSTEPLENGTH = 0x7d; const uint8_t VAR_ALLOWED_SPEED = 0xb7; const uint8_t VAR_ANGLE = 0x43; const uint8_t VAR_APPARENT_DECEL = 0x7c; const uint8_t VAR_ARRIVED_VEHICLES_IDS = 0x7a; const uint8_t VAR_ARRIVED_VEHICLES_NUMBER = 0x79; const uint8_t VAR_BEST_LANES = 0xb2; const uint8_t VAR_BUS_STOP_WAITING = 0x67; const uint8_t VAR_CO2EMISSION = 0x60; const uint8_t VAR_COEMISSION = 0x61; const uint8_t VAR_COLLIDING_VEHICLES_IDS = 0x81; const uint8_t VAR_COLLIDING_VEHICLES_NUMBER = 0x80; const uint8_t VAR_COLOR = 0x45; const uint8_t VAR_CURRENT_TRAVELTIME = 0x5a; const uint8_t VAR_DECEL = 0x47; const uint8_t VAR_DELTA_T = 0x7b; const uint8_t VAR_DEPARTED_VEHICLES_IDS = 0x74; const uint8_t VAR_DEPARTED_VEHICLES_NUMBER = 0x73; const uint8_t VAR_DISTANCE = 0x84; const uint8_t VAR_EDGES = 0x54; const uint8_t VAR_EDGE_EFFORT = 0x59; const uint8_t VAR_EDGE_TRAVELTIME = 0x58; const uint8_t VAR_ELECTRICITYCONSUMPTION = 0x71; const uint8_t VAR_EMERGENCYSTOPPING_VEHICLES_IDS = 0x8a; const uint8_t VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER = 0x89; const uint8_t VAR_EMERGENCY_DECEL = 0x7b; const uint8_t VAR_EMISSIONCLASS = 0x4a; const uint8_t VAR_FILL = 0x55; const uint8_t VAR_FOES = 0x37; const uint8_t VAR_FUELCONSUMPTION = 0x65; const uint8_t VAR_HAS_VIEW = 0xa7; const uint8_t VAR_HCEMISSION = 0x62; const uint8_t VAR_HEIGHT = 0xbc; const uint8_t VAR_IMPERFECTION = 0x5d; const uint8_t VAR_LANECHANGE_MODE = 0xb6; const uint8_t VAR_LANEPOSITION = 0x56; const uint8_t VAR_LANEPOSITION_LAT = 0xb8; const uint8_t VAR_LANE_ID = 0x51; const uint8_t VAR_LANE_INDEX = 0x52; const uint8_t VAR_LASTACTIONTIME = 0x7f; const uint8_t VAR_LATALIGNMENT = 0xb9; const uint8_t VAR_LEADER = 0x68; const uint8_t VAR_LENGTH = 0x44; const uint8_t VAR_LINE = 0xbd; const uint8_t VAR_LOADED_VEHICLES_IDS = 0x72; const uint8_t VAR_LOADED_VEHICLES_NUMBER = 0x71; const uint8_t VAR_MAXSPEED = 0x41; const uint8_t VAR_MAXSPEED_LAT = 0xba; const uint8_t VAR_MINGAP = 0x4c; const uint8_t VAR_MINGAP_LAT = 0xbb; const uint8_t VAR_MIN_EXPECTED_VEHICLES = 0x7d; const uint8_t VAR_MOVE_TO = 0x5c; const uint8_t VAR_MOVE_TO_VTD = 0xb4; // Veins specific (called MOVE_TO_XY in TraCI) const uint8_t VAR_NAME = 0x1b; const uint8_t VAR_NET_BOUNDING_BOX = 0x7c; const uint8_t VAR_NEXT_EDGE = 0xc1; const uint8_t VAR_NEXT_STOPS = 0x73; const uint8_t VAR_NEXT_TLS = 0x70; const uint8_t VAR_NOISEEMISSION = 0x66; const uint8_t VAR_NOXEMISSION = 0x64; const uint8_t VAR_PARAMETER = 0x7e; const uint8_t VAR_PARKING_ENDING_VEHICLES_IDS = 0x6f; const uint8_t VAR_PARKING_ENDING_VEHICLES_NUMBER = 0x6e; const uint8_t VAR_PARKING_STARTING_VEHICLES_IDS = 0x6d; const uint8_t VAR_PARKING_STARTING_VEHICLES_NUMBER = 0x6c; const uint8_t VAR_PERSON_NUMBER = 0x67; const uint8_t VAR_PMXEMISSION = 0x63; const uint8_t VAR_POSITION = 0x42; const uint8_t VAR_POSITION3D = 0x39; const uint8_t VAR_ROAD_ID = 0x50; const uint8_t VAR_ROUTE = 0x57; const uint8_t VAR_ROUTE_ID = 0x53; const uint8_t VAR_ROUTE_INDEX = 0x69; const uint8_t VAR_ROUTE_VALID = 0x92; const uint8_t VAR_ROUTING_MODE = 0x89; const uint8_t VAR_SCREENSHOT = 0xa5; const uint8_t VAR_SHAPE = 0x4e; const uint8_t VAR_SHAPECLASS = 0x4b; const uint8_t VAR_SIGNALS = 0x5b; const uint8_t VAR_SLOPE = 0x36; const uint8_t VAR_SPEED = 0x40; const uint8_t VAR_SPEEDSETMODE = 0xb3; const uint8_t VAR_SPEED_DEVIATION = 0x5f; const uint8_t VAR_SPEED_FACTOR = 0x5e; const uint8_t VAR_SPEED_WITHOUT_TRACI = 0xb1; const uint8_t VAR_STAGE = 0xc0; const uint8_t VAR_STAGES_REMAINING = 0xc2; const uint8_t VAR_STOPSTATE = 0xb5; const uint8_t VAR_STOP_ENDING_VEHICLES_IDS = 0x6b; const uint8_t VAR_STOP_ENDING_VEHICLES_NUMBER = 0x6a; const uint8_t VAR_STOP_STARTING_VEHICLES_IDS = 0x69; const uint8_t VAR_STOP_STARTING_VEHICLES_NUMBER = 0x68; const uint8_t VAR_TAU = 0x48; const uint8_t VAR_TELEPORT_ENDING_VEHICLES_IDS = 0x78; const uint8_t VAR_TELEPORT_ENDING_VEHICLES_NUMBER = 0x77; const uint8_t VAR_TELEPORT_STARTING_VEHICLES_IDS = 0x76; const uint8_t VAR_TELEPORT_STARTING_VEHICLES_NUMBER = 0x75; const uint8_t VAR_TIME = 0x66; const uint8_t VAR_TIME_STEP = 0x70; const uint8_t VAR_TRACK_VEHICLE = 0xa6; const uint8_t VAR_TYPE = 0x4f; const uint8_t VAR_UPDATE_BESTLANES = 0x6a; const uint8_t VAR_VEHICLE = 0xc3; const uint8_t VAR_VEHICLECLASS = 0x49; const uint8_t VAR_VIA = 0xbe; const uint8_t VAR_VIEW_BOUNDARY = 0xa3; const uint8_t VAR_VIEW_OFFSET = 0xa1; const uint8_t VAR_VIEW_SCHEMA = 0xa2; const uint8_t VAR_VIEW_ZOOM = 0xa0; const uint8_t VAR_WAITING_TIME = 0x7a; const uint8_t VAR_WAITING_TIME_ACCUMULATED = 0x87; // Veins specific (called VAR_ACCUMULATED_WAITING_TIME in TraCI) const uint8_t VAR_WIDTH = 0x4d; } // namespace TraCIConstants } // namespace veins
18,274
43.791667
123
h
null
AICP-main/veins/src/veins/modules/mobility/traci/TraCICoord.h
// // Copyright (C) 2006 Christoph Sommer <sommer@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/veins.h" namespace veins { /** * Coord equivalent for storing TraCI coordinates */ struct VEINS_API TraCICoord { TraCICoord() : x(0.0) , y(0.0) { } TraCICoord(double x, double y) : x(x) , y(y) { } double x; double y; }; } // namespace veins
1,240
24.854167
76
h
null
AICP-main/veins/src/veins/modules/mobility/traci/TraCICoordinateTransformation.h
// // Copyright (C) 2018 Dominik S. Buse <buse@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/modules/mobility/traci/TraCICoord.h" #include "veins/base/utils/Coord.h" #include "veins/base/utils/Heading.h" #include <list> namespace veins { /** * Helper class for converting SUMO coordinates to OMNeT++ Coordinates for a given network. */ class VEINS_API TraCICoordinateTransformation { public: using OmnetCoord = Coord; using OmnetCoordList = std::list<OmnetCoord>; using TraCICoordList = std::list<TraCICoord>; using TraCIHeading = double; using OmnetHeading = Heading; TraCICoordinateTransformation(TraCICoord topleft, TraCICoord bottomright, float margin); TraCICoord omnet2traci(const OmnetCoord& coord) const; TraCICoordList omnet2traci(const OmnetCoordList& coords) const; TraCIHeading omnet2traciHeading(OmnetHeading heading) const; /**< TraCI's heading interpretation: 0 is north, 90 is east */ OmnetCoord traci2omnet(const TraCICoord& coord) const; OmnetCoordList traci2omnet(const TraCICoordList& coords) const; OmnetHeading traci2omnetHeading(TraCIHeading heading) const; /**< OMNeT++'s heading interpretation: 0 is east, pi/2 is north */ private: TraCICoord dimensions; TraCICoord topleft; TraCICoord bottomright; float margin; }; // end class NetworkCoordinateTranslator } // end namespace veins
2,214
35.916667
132
h
null
AICP-main/veins/src/veins/modules/mobility/traci/TraCILauncher.h
// // Copyright (C) 2006-2016 Christoph Sommer <christoph.sommer@uibk.ac.at> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once namespace veins { /** * @brief * Launches a program (the TraCI server) when instantiated. * * See the Veins website <a href="http://veins.car2x.org/"> for a tutorial, documentation, and publications </a>. * * @author Christoph Sommer * * @see TraCIMobility * @see TraCIScenarioManager * */ class VEINS_API TraCILauncher { public: TraCILauncher(std::string commandLine); ~TraCILauncher(); protected: #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__) || defined(_WIN64) #else pid_t pid; #endif }; } // namespace veins
1,502
27.903846
113
h
null
AICP-main/veins/src/veins/modules/mobility/traci/TraCIScenarioManagerForker.h
// // Copyright (C) 2006-2016 Christoph Sommer <christoph.sommer@uibk.ac.at> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/veins.h" #include "veins/modules/mobility/traci/TraCIScenarioManager.h" #include "veins/modules/mobility/traci/TraCILauncher.h" namespace veins { /** * @brief * * Extends the TraCIScenarioManager to automatically fork an instance of SUMO when needed. * * All other functionality is provided by the TraCIScenarioManager. * * See the Veins website <a href="http://veins.car2x.org/"> for a tutorial, documentation, and publications </a>. * * @author Christoph Sommer, Florian Hagenauer * * @see TraCIMobility * @see TraCIScenarioManager * */ class VEINS_API TraCIScenarioManagerForker : public TraCIScenarioManager { public: TraCIScenarioManagerForker(); ~TraCIScenarioManagerForker() override; void initialize(int stage) override; void finish() override; protected: std::string commandLine; /**< command line for running TraCI server (substituting $configFile, $seed, $port) */ std::string command; /**< substitution for $command parameter */ std::string configFile; /**< substitution for $configFile parameter */ int seed; /**< substitution for $seed parameter (-1: current run number) */ TraCILauncher* server; virtual void startServer(); virtual void killServer(); int getPortNumber() const override; }; class VEINS_API TraCIScenarioManagerForkerAccess { public: TraCIScenarioManagerForker* get() { return FindModule<TraCIScenarioManagerForker*>::findGlobalModule(); }; }; } // namespace veins
2,427
31.373333
115
h
null
AICP-main/veins/src/veins/modules/mobility/traci/TraCIScenarioManagerLaunchd.h
// // Copyright (C) 2006-2012 Christoph Sommer <christoph.sommer@uibk.ac.at> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/veins.h" #include "veins/modules/mobility/traci/TraCIScenarioManager.h" namespace veins { /** * @brief * Extends the TraCIScenarioManager for use with sumo-launchd.py and SUMO. * * Connects to a running instance of the sumo-launchd.py script * to automatically launch/kill SUMO when the simulation starts/ends. * * All other functionality is provided by the TraCIScenarioManager. * * See the Veins website <a href="http://veins.car2x.org/"> for a tutorial, documentation, and publications </a>. * * @author Christoph Sommer, David Eckhoff * * @see TraCIMobility * @see TraCIScenarioManager * */ class VEINS_API TraCIScenarioManagerLaunchd : public TraCIScenarioManager { public: ~TraCIScenarioManagerLaunchd() override; void initialize(int stage) override; void finish() override; protected: cXMLElement* launchConfig; /**< launch configuration to send to sumo-launchd */ int seed; /**< seed value to set in launch configuration, if missing (-1: current run number) */ void init_traci() override; }; class VEINS_API TraCIScenarioManagerLaunchdAccess { public: TraCIScenarioManagerLaunchd* get() { return FindModule<TraCIScenarioManagerLaunchd*>::findGlobalModule(); }; }; } // namespace veins
2,203
30.485714
113
h
null
AICP-main/veins/src/veins/modules/mobility/traci/TraCIVehicleInserter.h
// // Copyright (C) 2006-2018 Christoph Sommer <sommer@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <queue> #include "veins/veins.h" #include "veins/modules/mobility/traci/TraCIScenarioManager.h" namespace veins { /** * @brief * Uses the TraCIScenarioManager to programmatically insert new vehicles at the TraCI server. * * This is done whenever the total number of active vehicles drops below a given number. * * See the Veins website <a href="http://veins.car2x.org/"> for a tutorial, documentation, and publications </a>. * * @author Christoph Sommer, David Eckhoff, Falko Dressler, Zheng Yao, Tobias Mayer, Alvaro Torres Cortes, Luca Bedogni * * @see TraCIScenarioManager * */ class VEINS_API TraCIVehicleInserter : public cSimpleModule, public cListener { public: TraCIVehicleInserter(); ~TraCIVehicleInserter() override; int numInitStages() const override; void initialize(int stage) override; void finish() override; void finish(cComponent* component, simsignal_t signalID) override; void handleMessage(cMessage* msg) override; void receiveSignal(cComponent* source, simsignal_t signalID, cObject* obj, cObject* details) override; void receiveSignal(cComponent* source, simsignal_t signalID, const SimTime& t, cObject* details) override; protected: /** * adds a new vehicle to the queue which are tried to be inserted at the next SUMO time step; */ void insertNewVehicle(); /** * tries to add all vehicles in the vehicle queue to SUMO; */ void insertVehicles(); // parameters int vehicleRngIndex; int numVehicles; // internal TraCIScenarioManager* manager; cRNG* mobRng; std::map<int, std::queue<std::string>> vehicleInsertQueue; std::set<std::string> queuedVehicles; std::vector<std::string> routeIds; uint32_t vehicleNameCounter; std::vector<std::string> vehicleTypeIds; }; } // namespace veins
2,768
32.361446
119
h
null
AICP-main/veins/src/veins/modules/mobility/traci/VehicleSignal.h
// // Copyright (C) 2018 Dominik S. Buse <buse@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/veins.h" #include "veins/base/utils/EnumBitset.h" namespace veins { enum class VehicleSignal : uint32_t { blinker_right, blinker_left, blinker_emergency, brakelight, frontlight, foglight, highbeam, backdrive, wiper, door_open_left, door_open_right, emergency_blue, emergency_red, emergency_yellow, undefined }; template <> struct VEINS_API EnumTraits<VehicleSignal> { static const VehicleSignal max = VehicleSignal::undefined; }; using VehicleSignalSet = EnumBitset<VehicleSignal>; } // namespace veins
1,500
25.333333
76
h
null
AICP-main/veins/src/veins/modules/obstacle/Obstacle.h
// // Copyright (C) 2006-2018 Christoph Sommer <sommer@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <vector> #include "veins/veins.h" #include "veins/base/utils/Coord.h" #include "veins/modules/world/annotations/AnnotationManager.h" namespace veins { /** * stores information about an Obstacle for ObstacleControl */ class VEINS_API Obstacle { public: using Coords = std::vector<Coord>; Obstacle(std::string id, std::string type, double attenuationPerCut, double attenuationPerMeter); void setShape(Coords shape); const Coords& getShape() const; const Coord getBboxP1() const; const Coord getBboxP2() const; bool containsPoint(Coord Point) const; std::string getType() const; std::string getId() const; double getAttenuationPerCut() const; double getAttenuationPerMeter() const; /** * get a list of points (in [0, 1]) along the line between sender and receiver where the beam intersects with this obstacle */ std::vector<double> getIntersections(const Coord& senderPos, const Coord& receiverPos) const; AnnotationManager::Annotation* visualRepresentation; protected: std::string id; std::string type; double attenuationPerCut; /**< in dB. attenuation per exterior border of obstacle */ double attenuationPerMeter; /**< in dB / m. to account for attenuation caused by interior of obstacle */ Coords coords; Coord bboxP1; Coord bboxP2; }; } // namespace veins
2,293
30.861111
127
h
null
AICP-main/veins/src/veins/modules/phy/Decider80211pToPhy80211pInterface.h
// // Copyright (C) 2011 David Eckhoff <eckhoff@cs.fau.de> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once namespace veins { /** * @brief * Interface of PhyLayer80211p exposed to Decider80211p. * * @author David Eckhoff * * @ingroup phyLayer */ class VEINS_API Decider80211pToPhy80211pInterface { public: virtual ~Decider80211pToPhy80211pInterface(){}; virtual int getRadioState() = 0; }; } // namespace veins
1,229
28.285714
76
h
null
AICP-main/veins/src/veins/modules/phy/DeciderResult80211.h
// // Copyright (C) 2007 Technische Universitaet Berlin (TUB), Germany, Telecommunication Networks Group // Copyright (C) 2007 Technische Universiteit Delft (TUD), Netherlands // Copyright (C) 2007 Universitaet Paderborn (UPB), Germany // Copyright (C) 2014 Michele Segata <segata@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // /* * DeciderResult80211.h * * Created on: 04.02.2009 * Author: karl * * Modified by Michele Segata (segata@ccs-labs.org) */ #pragma once #include "veins/veins.h" #include "veins/base/phyLayer/Decider.h" namespace veins { /** * @brief Defines an extended DeciderResult for the 80211 protocol * which stores the bit-rate of the transmission. * * @ingroup decider * @ingroup ieee80211 */ class VEINS_API DeciderResult80211 : public DeciderResult { protected: /** @brief Stores the bit-rate of the transmission of the packet */ double bitrate; /** @brief Stores the signal to noise ratio of the transmission */ double snr; /** @brief Stores the received power in dBm * Please note that this is NOT the RSSI. The RSSI is an indicator * of the quality of the signal which is not standardized, and * different vendors can define different indicators. This value * indicates the power that the frame had when received by the * NIC card, WITHOUT noise floor and WITHOUT interference */ double recvPower_dBm; /** @brief Stores whether the uncorrect decoding was due to low power or collision */ bool collision; public: /** * @brief Initialises with the passed values. * * "bitrate" defines the bit-rate of the transmission of the packet. */ DeciderResult80211(bool isCorrect, double bitrate, double snr, double recvPower_dBm = 0, bool collision = false) : DeciderResult(isCorrect) , bitrate(bitrate) , snr(snr) , recvPower_dBm(recvPower_dBm) , collision(collision) { } /** * @brief Returns the bit-rate of the transmission of the packet. */ double getBitrate() const { return bitrate; } /** * @brief Returns the signal to noise ratio of the transmission. */ double getSnr() const { return snr; } /** * @brief Returns whether drop was due to collision, if isCorrect is false */ bool isCollision() const { return collision; } /** * @brief Returns the signal power in dBm. */ double getRecvPower_dBm() const { return recvPower_dBm; } }; } // namespace veins
3,384
27.445378
116
h
null
AICP-main/veins/src/veins/modules/phy/NistErrorRate.h
/* * Copyright (c) 2010 The Boeing Company * Copyright (c) 2014 Michele Segata <segata@ccs-labs.org> * * SPDX-License-Identifier: GPL-2.0-only * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Gary Pei <guangyu.pei@boeing.com> */ #pragma once #include <stdint.h> #include <cmath> #include "veins/modules/utility/ConstsPhy.h" namespace veins { /** * Model the error rate for different modulations and coding schemes. * Taken from the nist wifi model of ns-3 */ class VEINS_API NistErrorRate { public: NistErrorRate(); static double getChunkSuccessRate(unsigned int datarate, enum Bandwidth bw, double snr_mW, uint32_t nbits); private: /** * Return the coded BER for the given p and b. * * \param p * \param bValue * \return BER */ static double calculatePe(double p, uint32_t bValue); /** * Return BER of BPSK at the given SNR. * * \param snr snr value * \return BER of BPSK at the given SNR */ static double getBpskBer(double snr); /** * Return BER of QPSK at the given SNR. * * \param snr snr value * \return BER of QPSK at the given SNR */ static double getQpskBer(double snr); /** * Return BER of QAM16 at the given SNR. * * \param snr snr value * \return BER of QAM16 at the given SNR */ static double get16QamBer(double snr); /** * Return BER of QAM64 at the given SNR. * * \param snr snr value * \return BER of QAM64 at the given SNR */ static double get64QamBer(double snr); /** * Return BER of BPSK at the given SNR after applying FEC. * * \param snr snr value * \param nbits the number of bits in the chunk * \param bValue * \return BER of BPSK at the given SNR after applying FEC */ static double getFecBpskBer(double snr, uint32_t nbits, uint32_t bValue); /** * Return BER of QPSK at the given SNR after applying FEC. * * \param snr snr value * \param nbits the number of bits in the chunk * \param bValue * \return BER of QPSK at the given SNR after applying FEC */ static double getFecQpskBer(double snr, uint32_t nbits, uint32_t bValue); /** * Return BER of QAM16 at the given SNR after applying FEC. * * \param snr snr value * \param nbits the number of bits in the chunk * \param bValue * \return BER of QAM16 at the given SNR after applying FEC */ static double getFec16QamBer(double snr, uint32_t nbits, uint32_t bValue); /** * Return BER of QAM64 at the given SNR after applying FEC. * * \param snr snr value * \param nbits the number of bits in the chunk * \param bValue * \return BER of QAM64 at the given SNR after applying FEC */ static double getFec64QamBer(double snr, uint32_t nbits, uint32_t bValue); }; } // namespace veins
3,531
29.448276
111
h
null
AICP-main/veins/src/veins/modules/phy/PhyLayer80211p.h
// // Copyright (C) 2011 David Eckhoff <eckhoff@cs.fau.de> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/base/phyLayer/BasePhyLayer.h" #include "veins/base/toolbox/Spectrum.h" #include "veins/modules/mac/ieee80211p/Mac80211pToPhy11pInterface.h" #include "veins/modules/phy/Decider80211p.h" #include "veins/modules/analogueModel/SimplePathlossModel.h" #include "veins/base/connectionManager/BaseConnectionManager.h" #include "veins/modules/phy/Decider80211pToPhy80211pInterface.h" #include "veins/base/utils/Move.h" namespace veins { /** * @brief * Adaptation of the PhyLayer class for 802.11p. * * @ingroup phyLayer * * @see DemoBaseApplLayer * @see Mac1609_4 * @see PhyLayer80211p * @see Decider80211p */ class VEINS_API PhyLayer80211p : public BasePhyLayer, public Mac80211pToPhy11pInterface, public Decider80211pToPhy80211pInterface { public: void initialize(int stage) override; /** * @brief Set the carrier sense threshold * @param ccaThreshold_dBm the cca threshold in dBm */ void setCCAThreshold(double ccaThreshold_dBm) override; /** * @brief Return the cca threshold in dBm */ double getCCAThreshold(); /** * @brief Enable notifications about PHY-RXSTART.indication in MAC * @param enable true if Mac needs to be notified about it */ void notifyMacAboutRxStart(bool enable) override; /** * @brief Explicit request to PHY for the channel status */ void requestChannelStatusIfIdle() override; protected: /** @brief CCA threshold. See Decider80211p for details */ double ccaThreshold; /** @brief enable/disable detection of packet collisions */ bool collectCollisionStatistics; /** @brief allows/disallows interruption of current reception for txing * * See detailed description in Decider80211p */ bool allowTxDuringRx; enum ProtocolIds { IEEE_80211 = 12123 }; /** * @brief Creates and returns an instance of the AnalogueModel with the * specified name. * * Is able to initialize the following AnalogueModels: */ virtual std::unique_ptr<AnalogueModel> getAnalogueModelFromName(std::string name, ParameterMap& params) override; /** * @brief Creates and initializes a SimplePathlossModel with the * passed parameter values. */ std::unique_ptr<AnalogueModel> initializeSimplePathlossModel(ParameterMap& params); /** * @brief Creates and initializes an AntennaModel with the * passed parameter values. */ std::unique_ptr<AnalogueModel> initializeAntennaModel(ParameterMap& params); /** * @brief Creates and initializes a BreakpointPathlossModel with the * passed parameter values. */ virtual std::unique_ptr<AnalogueModel> initializeBreakpointPathlossModel(ParameterMap& params); /** * @brief Creates and initializes a SimpleObstacleShadowing with the * passed parameter values. */ std::unique_ptr<AnalogueModel> initializeSimpleObstacleShadowing(ParameterMap& params); /** * @brief Creates and initializes a VehicleObstacleShadowing with the * passed parameter values. */ std::unique_ptr<AnalogueModel> initializeVehicleObstacleShadowing(ParameterMap& params); /** * @brief Creates a simple Packet Error Rate model that attenuates a percentage * of the packets to zero, and does not attenuate the other packets. * */ virtual std::unique_ptr<AnalogueModel> initializePERModel(ParameterMap& params); /** * @brief Creates and initializes a TwoRayInterferenceModel with the * passed parameter values. */ std::unique_ptr<AnalogueModel> initializeTwoRayInterferenceModel(ParameterMap& params); /** * @brief Creates and initializes a NakagamiFading with the * passed parameter values. */ std::unique_ptr<AnalogueModel> initializeNakagamiFading(ParameterMap& params); /** * @brief Creates and returns an instance of the Decider with the specified * name. * * Is able to initialize the following Deciders: * * - Decider80211p */ virtual std::unique_ptr<Decider> getDeciderFromName(std::string name, ParameterMap& params) override; /** * @brief Initializes a new Decider80211 from the passed parameter map. */ virtual std::unique_ptr<Decider> initializeDecider80211p(ParameterMap& params); /** * Create a protocol-specific AirFrame * Overloaded to create a specialize AirFrame11p. */ std::unique_ptr<AirFrame> createAirFrame(cPacket* macPkt) override; /** * Attach a signal to the given AirFrame. * * The attached Signal corresponds to the IEEE 802.11p standard. * Parameters for the signal are passed in the control info. * The indicated power levels are set up on the specified center frequency, as well as the neighboring 5MHz. * * @note The control info must be of type MacToPhyControlInfo11p */ void attachSignal(AirFrame* airFrame, cObject* ctrlInfo) override; void changeListeningChannel(Channel channel) override; virtual simtime_t getFrameDuration(int payloadLengthBits, MCS mcs) const override; void handleSelfMessage(cMessage* msg) override; int getRadioState() override; simtime_t setRadioState(int rs) override; }; } // namespace veins
6,210
32.755435
131
h
null
AICP-main/veins/src/veins/modules/utility/Consts80211p.h
// // Copyright (C) 2011 David Eckhoff <eckhoff@cs.fau.de> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <stdint.h> #include "veins/veins.h" #include "veins/modules/utility/ConstsPhy.h" using omnetpp::SimTime; namespace veins { /** @brief Bit rates for 802.11p * * as defined in Table 17-14 MIB attribute default values/ranges in the IEEE 802.11-2007 standard */ const uint64_t NUM_BITRATES_80211P = 8; const uint64_t BITRATES_80211P[] = {3000000, 4500000, 6000000, 9000000, 12000000, 18000000, 24000000, 27000000}; /** @brief Number of Data Bits Per Symbol (N_NBPS) corresponding to bitrates in BITRATES_80211P * * as defined in Table 17-3 in the IEEE 802.11-2007 standard */ const uint32_t N_DBPS_80211P[] = {24, 36, 48, 72, 96, 144, 192, 216}; /** @brief Symbol interval * * as defined in Table 17-4 in the IEEE 802.11-2007 standard */ const double T_SYM_80211P = 8e-6; /** @brief Length (in bits) of SERVICE field in PHY HEADER * * as defined in 17.3.2 PLCP frame format in the IEEE 802.11-2007 standard */ const int PHY_HDR_SERVICE_LENGTH = 16; /** @brief Length (in bits) of Tail field in PHY PPDU * * as defined in 17.3.2 PLCP frame format in the IEEE 802.11-2007 standard */ const int PHY_TAIL_LENGTH = 6; /** @brief Duration of the PLCP Preamble * * as defined in Table 17.4 Timing-related parameters in the IEEE 802.11-2007 standard */ const double PHY_HDR_PREAMBLE_DURATION = 32e-6; /** @brief Duration of the PLCP Signal * * as defined in Table 17.4 Timing-related parameters in the IEEE 802.11-2007 standard */ const double PHY_HDR_PLCPSIGNAL_DURATION = 8e-6; /** @brief Length of the PLCP Signal * * as defined in Figure 17.1 PPDU frame format in the IEEE 802.11-2007 standard */ const int PHY_HDR_PLCPSIGNAL_LENGTH = 24; /** @brief Bitrate of the PLCP Signal * * as defined in Table 17.4 Timing-related parameters in the IEEE 802.11-2007 standard * 24 bits in 8e-6 seconds */ const uint64_t PHY_HDR_BITRATE = 3000000; /** @brief Slot Time for 10 MHz channel spacing * * as defined in Table 17-15 OFDM PHY characteristics in the IEEE 802.11-2007 standard */ const SimTime SLOTLENGTH_11P = SimTime().setRaw(13000000UL); /** @brief Short interframe space * * as defined in Table 17-15 OFDM PHY characteristics in the IEEE 802.11-2007 standard */ const SimTime SIFS_11P = SimTime().setRaw(32000000UL); /** @brief Time it takes to switch from Rx to Tx Mode * * as defined in Table 17-15 OFDM PHY characteristics in the IEEE 802.11-2007 standard */ const SimTime RADIODELAY_11P = SimTime().setRaw(1000000UL); /** @brief Contention Window minimal size * * as defined in Table 17-15 OFDM PHY characteristics in the IEEE 802.11-2007 standard */ const unsigned CWMIN_11P = 15; /** @brief Contention Window maximal size * * as defined in Table 17-15 OFDM PHY characteristics in the IEEE 802.11-2007 standard */ const unsigned CWMAX_11P = 1023; /** @brief 1609.4 slot length * * as defined in Table H.1 in the IEEE 1609.4-2010 standard */ const SimTime SWITCHING_INTERVAL_11P = SimTime().setRaw(50000000000UL); /** @brief 1609.4 slot length * * as defined in Table H.1 in the IEEE 1609.4-2010 standard * It is the sum of SyncTolerance and MaxChSwitchTime as defined in 6.2.5 in the IEEE 1609.4-2010 Standard */ const SimTime GUARD_INTERVAL_11P = SimTime().setRaw(4000000000UL); const Bandwidth BANDWIDTH_11P = Bandwidth::ofdm_10_mhz; /** @brief Channels as reserved by the FCC * */ enum class Channel { crit_sol = 172, sch1 = 174, sch2 = 176, cch = 178, sch3 = 180, sch4 = 182, hpps = 184 }; /** * Maps channel identifier to the corresponding center frequency. * * @note Not all entries are defined. */ const std::map<Channel, double> IEEE80211ChannelFrequencies = { {Channel::crit_sol, 5.86e9}, {Channel::sch1, 5.87e9}, {Channel::sch2, 5.88e9}, {Channel::cch, 5.89e9}, {Channel::sch3, 5.90e9}, {Channel::sch4, 5.91e9}, {Channel::hpps, 5.92e9}, }; enum class ChannelType { control = 0, service, }; } // namespace veins
4,879
27.87574
112
h
null
AICP-main/veins/src/veins/modules/utility/ConstsPhy.h
// // Copyright (C) 2014 Michele Segata <segata@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <cmath> #include <stdint.h> #include "veins/veins.h" namespace veins { /** @brief Modulation and coding scheme to be used for transmission */ enum class MCS { // use the default MCS undefined = -1, ofdm_bpsk_r_1_2, ofdm_bpsk_r_3_4, ofdm_qpsk_r_1_2, ofdm_qpsk_r_3_4, ofdm_qam16_r_1_2, ofdm_qam16_r_3_4, ofdm_qam64_r_2_3, ofdm_qam64_r_3_4 }; /** @brief Available bandwidths */ enum class Bandwidth { ofdm_5_mhz, ofdm_10_mhz, ofdm_20_mhz }; /** @brief Given bandwidth and MCS returns datarate in bits per second */ inline uint64_t getOfdmDatarate(MCS mcs, Bandwidth bw) { // divide datarate by div, depending on bandwidth uint64_t div; // datarate to be returned uint64_t dr; switch (bw) { case Bandwidth::ofdm_5_mhz: div = 4; break; case Bandwidth::ofdm_10_mhz: div = 2; break; case Bandwidth::ofdm_20_mhz: default: div = 1; break; } switch (mcs) { case MCS::ofdm_bpsk_r_1_2: dr = 6000000; break; case MCS::ofdm_bpsk_r_3_4: dr = 9000000; break; case MCS::ofdm_qpsk_r_1_2: dr = 12000000; break; case MCS::ofdm_qpsk_r_3_4: dr = 18000000; break; case MCS::ofdm_qam16_r_1_2: dr = 24000000; break; case MCS::ofdm_qam16_r_3_4: dr = 36000000; break; case MCS::ofdm_qam64_r_2_3: dr = 48000000; break; case MCS::ofdm_qam64_r_3_4: dr = 54000000; break; default: dr = 6000000; break; } return (dr / div); } /** @brief returns the number of databits per ofdm symbol */ inline uint32_t getNDBPS(MCS mcs) { uint32_t ndbps; switch (mcs) { case MCS::ofdm_bpsk_r_1_2: ndbps = 24; break; case MCS::ofdm_bpsk_r_3_4: ndbps = 36; break; case MCS::ofdm_qpsk_r_1_2: ndbps = 48; break; case MCS::ofdm_qpsk_r_3_4: ndbps = 72; break; case MCS::ofdm_qam16_r_1_2: ndbps = 96; break; case MCS::ofdm_qam16_r_3_4: ndbps = 144; break; case MCS::ofdm_qam64_r_2_3: ndbps = 192; break; case MCS::ofdm_qam64_r_3_4: ndbps = 216; break; default: ndbps = 24; break; } return ndbps; } /** @brief returns the bandwidth in Hz */ inline uint64_t getBandwidth(Bandwidth bw) { switch (bw) { case Bandwidth::ofdm_5_mhz: return 5000000; break; case Bandwidth::ofdm_10_mhz: return 10000000; break; case Bandwidth::ofdm_20_mhz: return 20000000; break; default: ASSERT2(false, "Invalid datarate for required bandwidth"); return -1; } } /** @brief returns encoding given datarate */ inline MCS getMCS(uint64_t datarate, Bandwidth bw) { if (bw == Bandwidth::ofdm_10_mhz) { if (datarate == 3000000) { return MCS::ofdm_bpsk_r_1_2; } if (datarate == 4500000) { return MCS::ofdm_bpsk_r_3_4; } if (datarate == 6000000) { return MCS::ofdm_qpsk_r_1_2; } if (datarate == 9000000) { return MCS::ofdm_qpsk_r_3_4; } if (datarate == 12000000) { return MCS::ofdm_qam16_r_1_2; } if (datarate == 18000000) { return MCS::ofdm_qam16_r_3_4; } if (datarate == 24000000) { return MCS::ofdm_qam64_r_2_3; } if (datarate == 27000000) { return MCS::ofdm_qam64_r_3_4; } } if (bw == Bandwidth::ofdm_20_mhz) { if (datarate == 6000000) { return MCS::ofdm_bpsk_r_1_2; } if (datarate == 9000000) { return MCS::ofdm_bpsk_r_3_4; } if (datarate == 12000000) { return MCS::ofdm_qpsk_r_1_2; } if (datarate == 18000000) { return MCS::ofdm_qpsk_r_3_4; } if (datarate == 24000000) { return MCS::ofdm_qam16_r_1_2; } if (datarate == 36000000) { return MCS::ofdm_qam16_r_3_4; } if (datarate == 48000000) { return MCS::ofdm_qam64_r_2_3; } if (datarate == 54000000) { return MCS::ofdm_qam64_r_3_4; } } if (bw == Bandwidth::ofdm_5_mhz) { if (datarate == 1500000) { return MCS::ofdm_bpsk_r_1_2; } if (datarate == 2250000) { return MCS::ofdm_bpsk_r_3_4; } if (datarate == 3000000) { return MCS::ofdm_qpsk_r_1_2; } if (datarate == 4500000) { return MCS::ofdm_qpsk_r_3_4; } if (datarate == 6000000) { return MCS::ofdm_qam16_r_1_2; } if (datarate == 9000000) { return MCS::ofdm_qam16_r_3_4; } if (datarate == 12000000) { return MCS::ofdm_qam64_r_2_3; } if (datarate == 13500000) { return MCS::ofdm_qam64_r_3_4; } } ASSERT2(false, "Invalid datarate for required bandwidth"); return MCS::undefined; } } // namespace veins
6,167
24.17551
76
h
null
AICP-main/veins/src/veins/modules/utility/HasLogProxy.h
// // Copyright (C) 2018 Christoph Sommer <sommer@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include <string> #include "veins/veins.h" namespace veins { /** * Helper class for logging from classes not derived from cComponent */ class VEINS_API HasLogProxy { public: HasLogProxy(cComponent* owner); const cComponent* getThisPtr() const; protected: cComponent* owner; }; } // namespace veins
1,230
27.627907
76
h
null
AICP-main/veins/src/veins/modules/utility/MacToPhyControlInfo11p.h
// // Copyright (C) 2018-2019 Dominik S. Buse <buse@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/veins.h" #include "veins/modules/utility/ConstsPhy.h" #include "veins/modules/utility/Consts80211p.h" namespace veins { /** * Stores information which is needed by the physical layer * when sending a MacPkt. * * @ingroup phyLayer * @ingroup macLayer */ struct VEINS_API MacToPhyControlInfo11p : public cObject { Channel channelNr; ///< Channel number/index used to select frequency. MCS mcs; ///< The modulation and coding scheme to employ for the associated frame. double txPower_mW; ///< Transmission power in milliwatts. MacToPhyControlInfo11p(Channel channelNr, MCS mcs, double txPower_mW) : channelNr(channelNr) , mcs(mcs) , txPower_mW(txPower_mW) { } }; } // namespace veins
1,672
30.566038
86
h
null
AICP-main/veins/src/veins/modules/utility/SignalManager.h
// // Copyright (C) 2019-2019 Dominik S. Buse <buse@ccs-labs.org> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #pragma once #include "veins/veins.h" #include <functional> #include <memory> namespace veins { template <typename Payload> struct VEINS_API SignalPayload { cComponent* source; simsignal_t signalID; Payload p; cObject* details; }; template <typename Payload> class VEINS_API SignalCallbackListener : public cListener { public: using Callback = std::function<void (SignalPayload<Payload>)>; SignalCallbackListener(Callback callback, cModule* receptor, simsignal_t signal) : callback(callback) , receptor(receptor) , signal(signal) { receptor->subscribe(signal, this); } ~SignalCallbackListener() { if (getSubscribeCount() > 0) { receptor->unsubscribe(signal, this); } } void receiveSignal(cComponent* source, simsignal_t signalID, Payload p, cObject* details) override { ASSERT(signalID == signal); callback({source, signalID, p, details}); } private: const Callback callback; cModule* const receptor; const simsignal_t signal; }; class VEINS_API SignalManager { public: void subscribeCallback(cModule* receptor, simsignal_t signal, const std::function<void(SignalPayload<bool>)> callback) { auto callbackListener = make_unique<SignalCallbackListener<bool>>(callback, receptor, signal); callbacks.emplace_back(std::move(callbackListener)); } void subscribeCallback(cModule* receptor, simsignal_t signal, const std::function<void(SignalPayload<long>)> callback) { auto callbackListener = make_unique<SignalCallbackListener<long>>(callback, receptor, signal); callbacks.emplace_back(std::move(callbackListener)); } void subscribeCallback(cModule* receptor, simsignal_t signal, const std::function<void(SignalPayload<unsigned long>)> callback) { auto callbackListener = make_unique<SignalCallbackListener<unsigned long>>(callback, receptor, signal); callbacks.emplace_back(std::move(callbackListener)); } void subscribeCallback(cModule* receptor, simsignal_t signal, const std::function<void(SignalPayload<double>)> callback) { auto callbackListener = make_unique<SignalCallbackListener<double>>(callback, receptor, signal); callbacks.emplace_back(std::move(callbackListener)); } void subscribeCallback(cModule* receptor, simsignal_t signal, const std::function<void(SignalPayload<const SimTime&>)> callback) { auto callbackListener = make_unique<SignalCallbackListener<const SimTime&>>(callback, receptor, signal); callbacks.emplace_back(std::move(callbackListener)); } void subscribeCallback(cModule* receptor, simsignal_t signal, const std::function<void(SignalPayload<const char*>)> callback) { auto callbackListener = make_unique<SignalCallbackListener<const char*>>(callback, receptor, signal); callbacks.emplace_back(std::move(callbackListener)); } void subscribeCallback(cModule* receptor, simsignal_t signal, const std::function<void(SignalPayload<cObject*>)> callback) { auto callbackListener = make_unique<SignalCallbackListener<cObject*>>(callback, receptor, signal); callbacks.emplace_back(std::move(callbackListener)); } private: std::vector<std::unique_ptr<cListener>> callbacks; }; } // namespace veins
4,271
36.80531
132
h
null
AICP-main/veins/src/veins/modules/world/annotations/AnnotationDummy.h
// // Copyright (C) 2010 Christoph Sommer <christoph.sommer@informatik.uni-erlangen.de> // // Documentation for these modules is at http://veins.car2x.org/ // // SPDX-License-Identifier: GPL-2.0-or-later // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // AnnotationDummy - workaround to visualize annotations #pragma once #include "veins/veins.h" namespace veins { /** * AnnotationDummy is just a workaround to visualize annotations * * @author Christoph Sommer */ class VEINS_API AnnotationDummy : public cSimpleModule { public: ~AnnotationDummy() override; protected: }; } // namespace veins
1,280
28.113636
84
h