00001 #ifndef YOUBOT_JOINTLIMITMONITOR_H 00002 #define YOUBOT_JOINTLIMITMONITOR_H 00003 00004 /**************************************************************** 00005 * 00006 * Copyright (c) 2011 00007 * All rights reserved. 00008 * 00009 * Hochschule Bonn-Rhein-Sieg 00010 * University of Applied Sciences 00011 * Computer Science Department 00012 * 00013 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00014 * 00015 * Author: 00016 * Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov 00017 * Supervised by: 00018 * Gerhard K. Kraetzschmar 00019 * 00020 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00021 * 00022 * This sofware is published under a dual-license: GNU Lesser General Public 00023 * License LGPL 2.1 and BSD license. The dual-license implies that users of this 00024 * code may choose which terms they prefer. 00025 * 00026 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00027 * 00028 * Redistribution and use in source and binary forms, with or without 00029 * modification, are permitted provided that the following conditions are met: 00030 * 00031 * * Redistributions of source code must retain the above copyright 00032 * notice, this list of conditions and the following disclaimer. 00033 * * Redistributions in binary form must reproduce the above copyright 00034 * notice, this list of conditions and the following disclaimer in the 00035 * documentation and/or other materials provided with the distribution. 00036 * * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its 00037 * contributors may be used to endorse or promote products derived from 00038 * this software without specific prior written permission. 00039 * 00040 * This program is free software: you can redistribute it and/or modify 00041 * it under the terms of the GNU Lesser General Public License LGPL as 00042 * published by the Free Software Foundation, either version 2.1 of the 00043 * License, or (at your option) any later version or the BSD license. 00044 * 00045 * This program is distributed in the hope that it will be useful, 00046 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00047 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00048 * GNU Lesser General Public License LGPL and the BSD license for more details. 00049 * 00050 * You should have received a copy of the GNU Lesser General Public 00051 * License LGPL and BSD license along with this program. 00052 * 00053 ****************************************************************/ 00054 00055 #include <vector> 00056 #include <sstream> 00057 #include <cmath> 00058 #include <boost/thread.hpp> 00059 #include <youbot_driver/generic/Logger.hpp> 00060 #include <youbot_driver/generic/Units.hpp> 00061 #include <youbot_driver/generic/Time.hpp> 00062 #include <youbot_driver/generic/Exceptions.hpp> 00063 #include <youbot_driver/youbot/ProtocolDefinitions.hpp> 00064 #include <youbot_driver/youbot/YouBotJointStorage.hpp> 00065 #include <youbot_driver/youbot/YouBotSlaveMsg.hpp> 00066 00067 namespace youbot 00068 { 00069 00073 class JointLimitMonitor 00074 { 00075 public: 00076 JointLimitMonitor(const YouBotJointStorage& jointParameters, const quantity<angular_acceleration>& jointAcceleration); 00077 00078 virtual ~JointLimitMonitor(); 00079 00080 JointLimitMonitor(const JointLimitMonitor & source); 00081 00082 JointLimitMonitor & operator=(const JointLimitMonitor & source); 00083 00084 void checkLimitsPositionControl(const quantity<plane_angle>& setpoint); 00085 00086 void checkLimitsEncoderPosition(const signed int& setpoint); 00087 00088 void checkLimitsProcessData(const SlaveMessageInput& messageInput, SlaveMessageOutput& messageOutput); 00089 00090 private: 00091 double calculateDamping(const int actualPosition); 00092 00093 void calculateBrakingDistance(const SlaveMessageInput& messageInput); 00094 00095 int calculateBrakingVelocity(const int actualPosition); 00096 00097 YouBotJointStorage storage; 00098 00099 double acceleration; 00100 00101 int bevorLowerLimit; 00102 00103 int bevorUpperLimit; 00104 00105 int brakingDistance; 00106 00107 double actualVelocityRPS; 00108 00109 bool isbraking; 00110 00111 int velocityWhenReachedLimit; 00112 00113 double distanceToLimit; 00114 00115 double newVelocity; 00116 00117 }; 00118 00119 } // namespace youbot 00120 #endif