YouBotBase.hpp

Go to the documentation of this file.
00001 #ifndef YOUBOT_YOUBOTBASE_H
00002 #define YOUBOT_YOUBOTBASE_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 #include <vector>
00055 #include <sstream>
00056 #include <string>
00057 #include "generic/Logger.hpp"
00058 #include "generic/Units.hpp"
00059 #include "generic/Time.hpp"
00060 #include "generic/ConfigFile.hpp"
00061 #include "generic/Exceptions.hpp"
00062 #include "youbot/YouBotJoint.hpp"
00063 #include "youbot/YouBotJointParameter.hpp"
00064 #include "base-kinematic/FourSwedishWheelOmniBaseKinematic.hpp"
00065 #include "base-kinematic/FourSwedishWheelOmniBaseKinematicConfiguration.hpp"
00066 #include "youbot/EthercatMaster.hpp"
00067 #include "youbot/EthercatMasterInterface.hpp"
00068 #include "youbot/EthercatMasterWithThread.hpp"
00069 #include "youbot/EthercatMasterWithoutThread.hpp"
00070 #include <boost/ptr_container/ptr_vector.hpp>
00071 #include <boost/scoped_ptr.hpp>
00072 namespace youbot {
00073 
00074 /// The number of base joints
00075 #define BASEJOINTS 4
00076 ///////////////////////////////////////////////////////////////////////////////
00077 /// It groups the base joints together
00078 ///////////////////////////////////////////////////////////////////////////////
00079 class YouBotBase {
00080   public:
00081     YouBotBase(const std::string name, const std::string configFilePath = "../config/");
00082 
00083     virtual ~YouBotBase();
00084 
00085     ///does the sine commutation of the base joints
00086     void doJointCommutation();
00087 
00088     ///return a joint form the base
00089     ///@param baseJointNumber 1-4 for the base joints
00090     YouBotJoint& getBaseJoint(const unsigned int baseJointNumber);
00091 
00092     ///gets the cartesien base position which is calculated from the odometry
00093     ///@param longitudinalPosition is the forward or backward position
00094     ///@param transversalPosition is the sideway position
00095     ///@param orientation is the rotation around the center of the YouBot
00096     void getBasePosition(quantity<si::length>& longitudinalPosition, quantity<si::length>& transversalPosition, quantity<plane_angle>& orientation);
00097 
00098     ///sets the cartesien base position
00099     ///@param longitudinalPosition is the forward or backward position
00100     ///@param transversalPosition is the sideway position
00101     ///@param orientation is the rotation around the center of the YouBot
00102     void setBasePosition(const quantity<si::length>& longitudinalPosition, const quantity<si::length>& transversalPosition, const quantity<plane_angle>& orientation);
00103 
00104     ///gets the cartesien base velocity
00105     ///@param longitudinalVelocity is the forward or backward velocity
00106     ///@param transversalVelocity is the sideway velocity
00107     ///@param angularVelocity is the rotational velocity around the center of the YouBot
00108     void getBaseVelocity(quantity<si::velocity>& longitudinalVelocity, quantity<si::velocity>& transversalVelocity, quantity<si::angular_velocity>& angularVelocity);
00109 
00110     ///commands the base in cartesien velocities
00111     ///@param longitudinalVelocity is the forward or backward velocity
00112     ///@param transversalVelocity is the sideway velocity
00113     ///@param angularVelocity is the rotational velocity around the center of the YouBot
00114     void setBaseVelocity(const quantity<si::velocity>& longitudinalVelocity, const quantity<si::velocity>& transversalVelocity, const quantity<si::angular_velocity>& angularVelocity);
00115 
00116     ///This class represents the kinematic of the YouBot 
00117     FourSwedishWheelOmniBaseKinematic youBotBaseKinematic;
00118 
00119     ///commands positions or angles to all base joints
00120     ///all positions will be set at the same time
00121     ///@param JointData the to command positions
00122     virtual void setJointData(const std::vector<JointAngleSetpoint>& JointData);
00123 
00124     ///gets the position or angle of all base joints which have been calculated from the actual encoder value
00125     ///These values are all read at the same time from the different joints 
00126     ///@param data returns the angles by reference
00127     virtual void getJointData(std::vector<JointSensedAngle>& data);
00128 
00129     ///commands velocities to all base joints
00130     ///all velocities will be set at the same time
00131     ///@param JointData the to command velocities
00132     virtual void setJointData(const std::vector<JointVelocitySetpoint>& JointData);
00133 
00134     ///gets the velocities of all base joints which have been calculated from the actual encoder values
00135     ///These values are all read at the same time from the different joints 
00136     ///@param data returns the velocities by reference
00137     virtual void getJointData(std::vector<JointSensedVelocity>& data);
00138 
00139     ///commands current to all base joints
00140     ///all current values will be set at the same time
00141     ///@param JointData the to command current
00142     virtual void setJointData(const std::vector<JointCurrentSetpoint>& JointData);
00143 
00144     ///gets the motor currents of all base joints which have been measured by a hal sensor
00145     ///These values are all read at the same time from the different joints 
00146     ///@param data returns the actual motor currents by reference
00147     virtual void getJointData(std::vector<JointSensedCurrent>& data);
00148 
00149     ///commands torque to all base joints
00150     ///all torque values will be set at the same time
00151     ///@param JointData the to command torque 
00152     virtual void setJointData(const std::vector<JointTorqueSetpoint>& JointData);
00153 
00154     ///gets the joint torque of all base joints which have been calculated from the current
00155     ///These values are all read at the same time from the different joints 
00156     ///@param data returns the actual joint torque by reference
00157     virtual void getJointData(std::vector<JointSensedTorque>& data);
00158 
00159 
00160   private:
00161     YouBotBase(const YouBotBase & source);
00162 
00163     YouBotBase & operator=(const YouBotBase & source);
00164 
00165     ///does the commutation of the arm joints with firmware 2.0
00166     void commutationFirmware200();
00167 
00168     ///does the commutation of the arm joints with firmware 1.48 and below
00169     void commutationFirmware148();
00170 
00171     void initializeJoints();
00172 
00173     void initializeKinematic();
00174 
00175     boost::scoped_ptr<ConfigFile> configfile;
00176 
00177     boost::ptr_vector<YouBotJoint> joints;
00178 
00179     int controllerType;
00180 
00181     int alternativeControllerType;
00182 
00183     EthercatMasterInterface& ethercatMaster;
00184 
00185     EthercatMasterWithThread* ethercatMasterWithThread;
00186 
00187     std::vector<std::string> supportedFirmwareVersions;
00188 
00189     std::string actualFirmwareVersionAllJoints;
00190 
00191 };
00192 
00193 } // namespace youbot
00194 #endif
Generated by  doxygen 1.6.3