Link.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00028 #ifndef LINK_H_
00029 #define LINK_H_
00030 
00031 #include <rtabmap/core/Transform.h>
00032 #include <rtabmap/utilite/ULogger.h>
00033 #include <rtabmap/utilite/UMath.h>
00034 
00035 namespace rtabmap {
00036 
00037 class Link
00038 {
00039 public:
00040         enum Type {kNeighbor, kGlobalClosure, kLocalSpaceClosure, kLocalTimeClosure, kUserClosure, kVirtualClosure, kUndef};
00041         Link() :
00042                 from_(0),
00043                 to_(0),
00044                 type_(kUndef),
00045                 rotVariance_(1.0f),
00046                 transVariance_(1.0f)
00047         {
00048         }
00049         Link(int from, int to, Type type, const Transform & transform, float rotVariance, float transVariance) :
00050                 from_(from),
00051                 to_(to),
00052                 transform_(transform),
00053                 type_(type),
00054                 rotVariance_(rotVariance),
00055                 transVariance_(transVariance)
00056         {
00057                 UASSERT_MSG(uIsFinite(rotVariance) && rotVariance>0 && uIsFinite(transVariance) && transVariance>0, "Rotational and transitional variances should not be null! (set to 1 if unknown)");
00058         }
00059 
00060         bool isValid() const {return from_ > 0 && to_ > 0 && !transform_.isNull() && type_!=kUndef;}
00061 
00062         int from() const {return from_;}
00063         int to() const {return to_;}
00064         const Transform & transform() const {return transform_;}
00065         Type type() const {return type_;}
00066         float rotVariance() const {return rotVariance_;}
00067         float transVariance() const {return transVariance_;}
00068 
00069         void setFrom(int from) {from_ = from;}
00070         void setTo(int to) {to_ = to;}
00071         void setTransform(const Transform & transform) {transform_ = transform;}
00072         void setType(Type type) {type_ = type;}
00073         void setVariance(float rotVariance, float transVariance) {
00074                 UASSERT_MSG(uIsFinite(rotVariance) && rotVariance>0 && uIsFinite(transVariance) && transVariance>0, "Rotational and transitional variances should not be null! (set to 1 if unknown)");
00075                 rotVariance_ = rotVariance;
00076                 transVariance_ = transVariance;
00077         }
00078 
00079 private:
00080         int from_;
00081         int to_;
00082         Transform transform_;
00083         Type type_;
00084         float rotVariance_;
00085         float transVariance_;
00086 };
00087 
00088 }
00089 
00090 
00091 #endif /* LINK_H_ */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Fri Aug 28 2015 12:51:31