edge_via_point.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  *
00003  * Software License Agreement (BSD License)
00004  *
00005  *  Copyright (c) 2016,
00006  *  TU Dortmund - Institute of Control Theory and Systems Engineering.
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of the institute nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  * 
00036  * Notes:
00037  * The following class is derived from a class defined by the
00038  * g2o-framework. g2o is licensed under the terms of the BSD License.
00039  * Refer to the base class source for detailed licensing information.
00040  *
00041  * Author: Christoph Rösmann
00042  *********************************************************************/
00043 #ifndef EDGE_VIA_POINT_H_
00044 #define EDGE_VIA_POINT_H_
00045 
00046 #include <teb_local_planner/g2o_types/vertex_pose.h>
00047 #include <teb_local_planner/teb_config.h>
00048 
00049 #include "g2o/core/base_unary_edge.h"
00050 
00051 
00052 namespace teb_local_planner
00053 {
00054 
00066 class EdgeViaPoint : public g2o::BaseUnaryEdge<1, const Eigen::Vector2d*, VertexPose>
00067 {
00068 public:
00069     
00073   EdgeViaPoint() 
00074   {
00075     _measurement = NULL;
00076     _vertices[0] = NULL;
00077   }
00078  
00085   virtual ~EdgeViaPoint() 
00086   {
00087     if(_vertices[0]) 
00088       _vertices[0]->edges().erase(this);
00089   }
00090 
00094   void computeError()
00095   {
00096     ROS_ASSERT_MSG(cfg_ && _measurement, "You must call setTebConfig(), setViaPoint() on EdgeViaPoint()");
00097     const VertexPose* bandpt = static_cast<const VertexPose*>(_vertices[0]);
00098 
00099     _error[0] = (bandpt->position() - *_measurement).norm();
00100 
00101     ROS_ASSERT_MSG(std::isfinite(_error[0]), "EdgeViaPoint::computeError() _error[0]=%f\n",_error[0]);
00102   }
00103 
00104   
00111   ErrorVector& getError()
00112   {
00113     computeError();
00114     return _error;
00115   }
00116   
00120   virtual bool read(std::istream& is)
00121   {
00122   // is >> _measurement[0] >> _measurement[1];
00123     return true;
00124   }
00125 
00129   virtual bool write(std::ostream& os) const
00130   {
00131   // os << information()(0,0) << " Error: " << _error[0] << ", Measurement X: " << _measurement[0] << ", Measurement Y: " << _measurement[1];
00132     return os.good();
00133   }
00134   
00139   void setViaPoint(const Eigen::Vector2d* via_point)
00140   {
00141     _measurement = via_point;
00142   }
00143     
00144     
00149   void setTebConfig(const TebConfig& cfg)
00150   {
00151       cfg_ = &cfg;
00152   }
00153 
00159   void setParameters(const TebConfig& cfg, const Eigen::Vector2d* via_point)
00160   {
00161     cfg_ = &cfg;
00162     _measurement = via_point;
00163   }
00164   
00165 protected:
00166 
00167   const TebConfig* cfg_; 
00168   
00169 public:         
00170   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00171 
00172 };
00173   
00174     
00175 
00176 } // end namespace
00177 
00178 #endif


teb_local_planner
Author(s): Christoph Rösmann
autogenerated on Mon Oct 24 2016 05:31:15