PMPositionError.cpp
Go to the documentation of this file.
00001 /*
00002  * PositionError.cpp
00003  *
00004  *  Created on: Dec 13, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #include <trajmodules/PMPositionError.hpp>
00009 
00010 #include <tk_trajprocessor/TrajectoryProcessorController.hpp>
00011 
00012 // Declare
00013 PLUGINLIB_DECLARE_CLASS(tk_trajprocessor, PMPositionError, telekyb_traj::PMPositionError, TELEKYB_NAMESPACE::TrajectoryModule);
00014 
00015 namespace telekyb_traj {
00016 
00017 PMPositionErrorOptions::PMPositionErrorOptions()
00018         : OptionContainer("PMPositionError")
00019 {
00020         tMaxPositionError = addOption("tMaxPositionError", "Maximal Position Error", 0.5, false, true);
00021 }
00022 
00023 PMPositionError::PMPositionError()
00024         : TrajectoryModule("tk_trajprocessor/PMPositionError", TrajModulePosType::Position, 110) // after obs avoid
00025 {
00026 
00027 }
00028 
00029 void PMPositionError::initialize()
00030 {
00031 
00032 }
00033 
00034 void PMPositionError::destroy()
00035 {
00036 
00037 }
00038 
00039 // set back to intial conditions
00040 void PMPositionError::willTurnActive()
00041 {
00042         //ROS_ERROR("PMPositionError did turn active!");
00043 }
00044 
00045 // called after turning inactive
00046 void PMPositionError::didTurnInactive()
00047 {
00048         //ROS_ERROR("PMPositionError did turn inactive!");
00049 }
00050 
00051 bool PMPositionError::trajectoryStep(const TKState& currentState, TKTrajectory& trajInput)
00052 {
00053         //ROS_INFO_STREAM("TKState cur: " << std::endl << currentState.position);
00054         //ROS_INFO_STREAM("TKState tra: " << std::endl << trajInput.position);
00055         //ROS_INFO("Called PMPositionError");
00056         // check error
00057         //ROS_ERROR("PMPositionError trajectoryStep!");
00058         double posError = (currentState.position - trajInput.position).norm();
00059         if (posError > options.tMaxPositionError->getValue()) {
00060                 // switch to normalBrake
00061                 ROS_ERROR_STREAM("Trajectory Module " << getName() << ": Position error too big. "
00062                                 << posError << ">" << options.tMaxPositionError->getValue());
00063                 tpController.getBehaviorSwitcher()->switchToNormalBrake();
00064                 trajInput.setVelocity( Velocity3D::Zero() );
00065                 return false; // skip other
00066         }
00067 
00068 
00069         return true;
00070 }
00071 
00072 } /* namespace telekyb_traj */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


tk_trajprocessor
Author(s): Martin Riedel
autogenerated on Mon Nov 11 2013 11:13:29