diff --git a/source/RobotAPI/interface/CMakeLists.txt b/source/RobotAPI/interface/CMakeLists.txt index 11dd79e238d44df1f6911128ced13b5f1d1ca43e..38347386c56c9c7709a52fc1c1f5384ff84b64b5 100644 --- a/source/RobotAPI/interface/CMakeLists.txt +++ b/source/RobotAPI/interface/CMakeLists.txt @@ -35,10 +35,11 @@ set(SLICE_FILES units/UnitInterface.ice units/ATINetFTUnit.ice - components/ViewSelectionInterface.ice visualization/DebugDrawerInterface.ice + + libraries/Controllers/LVL1Controller.ice ) #core/RobotIK.ice diff --git a/source/RobotAPI/interface/libraries/Controllers/LVL1Controller.ice b/source/RobotAPI/interface/libraries/Controllers/LVL1Controller.ice new file mode 100644 index 0000000000000000000000000000000000000000..630d01d84cb2a5b4be8e7b897be405de708bf09f --- /dev/null +++ b/source/RobotAPI/interface/libraries/Controllers/LVL1Controller.ice @@ -0,0 +1,33 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::LVL1ControllerInterface + * @author Raphael Grimm ( raphael dot grimm at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +module armarx +{ + class LVL1ControllerConfig + { + }; + + class LVL1ControllerInterface + { + + }; +}; diff --git a/source/RobotAPI/libraries/CMakeLists.txt b/source/RobotAPI/libraries/CMakeLists.txt index c91c3c67b7b19691e2999f179a31cd990020fcbd..a9bcbc4783cdcb37ee328259f0c288087fcdae18 100644 --- a/source/RobotAPI/libraries/CMakeLists.txt +++ b/source/RobotAPI/libraries/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory(core) add_subdirectory(widgets) - +add_subdirectory(Controllers) diff --git a/source/RobotAPI/libraries/Controllers/CMakeLists.txt b/source/RobotAPI/libraries/Controllers/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b95e6d68c0e10df7e15523bef764bebd6ab2697f --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/CMakeLists.txt @@ -0,0 +1,48 @@ +armarx_component_set_name("Controllers") +armarx_set_target("Library: Controllers") + +set(LIB_NAME Controllers) + +#find_package(MyLib QUIET) +#armarx_build_if(MyLib_FOUND "MyLib not available") +# +# all include_directories must be guarded by if(Xyz_FOUND) +# for multiple libraries write: if(X_FOUND AND Y_FOUND).... +#if(MyLib_FOUND) +# include_directories(${MyLib_INCLUDE_DIRS}) +#endif() + +set(LIBS + ArmarXCoreInterfaces + ArmarXCore + RobotAPIInterfaces +) + +set(LIB_FILES + SyntaxCheck.cpp + + LVL0Controller.cpp + LVL1Controller.cpp +) +set(LIB_HEADERS + Constatnts.h + + Targets/JointTargetBase.h + Targets/JointPositionTarget.h + Targets/JointVelocityTarget.h + Targets/JointPositionVelocityTarget.h + Targets/JointTorqueTarget.h + + DataUnits/ForceTorqueDataUnit.h + DataUnits/HapticDataUnit.h + DataUnits/IMUDataUnit.h + DataUnits/KinematicDataUnit.h + DataUnits/PlatformDataUnit.h + + LVL0Controller.h + LVL1Controller.h +) + + +armarx_add_library("${LIB_NAME}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}") + diff --git a/source/RobotAPI/libraries/Controllers/Constatnts.h b/source/RobotAPI/libraries/Controllers/Constatnts.h new file mode 100644 index 0000000000000000000000000000000000000000..022b523303988352485d36da47e6cb8d1aefb2d9 --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/Constatnts.h @@ -0,0 +1,37 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_ControllerConstatns_H +#define _ARMARX_LIB_RobotAPI_ControllerConstatns_H + +#include <cmath> +#include <string> + +namespace armarx +{ + namespace ControllerConstatns + { + const float ValueNotSetNaN = std::nanf(std::to_string((1 << 16) - 1).c_str()); + } +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/DataUnits/ForceTorqueDataUnit.h b/source/RobotAPI/libraries/Controllers/DataUnits/ForceTorqueDataUnit.h new file mode 100644 index 0000000000000000000000000000000000000000..4c3f054697e54f0b174385d1c4a6139f7b5ecce4 --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/DataUnits/ForceTorqueDataUnit.h @@ -0,0 +1,34 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::ForceTorqueDataUnit + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_ForceTorqueDataUnit_H +#define _ARMARX_LIB_RobotAPI_ForceTorqueDataUnit_H + +namespace armarx +{ + class ForceTorqueDataUnit + { + + }; +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/DataUnits/HapticDataUnit.h b/source/RobotAPI/libraries/Controllers/DataUnits/HapticDataUnit.h new file mode 100644 index 0000000000000000000000000000000000000000..d9f6ac30de60122cb6ab22d8e2cd03501927a4bf --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/DataUnits/HapticDataUnit.h @@ -0,0 +1,34 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::HapticDataUnit + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_HapticDataUnit_H +#define _ARMARX_LIB_RobotAPI_HapticDataUnit_H + +namespace armarx +{ + class HapticDataUnit + { + + }; +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/DataUnits/IMUDataUnit.h b/source/RobotAPI/libraries/Controllers/DataUnits/IMUDataUnit.h new file mode 100644 index 0000000000000000000000000000000000000000..d337532b651fad6b0666d46f8fa151484cf184dc --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/DataUnits/IMUDataUnit.h @@ -0,0 +1,34 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::IMUDataUnit + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_IMUDataUnit_H +#define _ARMARX_LIB_RobotAPI_IMUDataUnit_H + +namespace armarx +{ + class IMUDataUnit + { + + }; +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/DataUnits/KinematicDataUnit.h b/source/RobotAPI/libraries/Controllers/DataUnits/KinematicDataUnit.h new file mode 100644 index 0000000000000000000000000000000000000000..6cf3a555c21c3c33dfef5a42142f4d60c7a42adb --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/DataUnits/KinematicDataUnit.h @@ -0,0 +1,128 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::KinematicDataUnit + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_KinematicDataUnit_H +#define _ARMARX_LIB_RobotAPI_KinematicDataUnit_H + +#include <vector> +#include <string> +#include <unordered_map> +#include <algorithm> + +#include "../Constatnts.h" + +namespace armarx +{ + class KinematicDataUnit + { + template<class T> + static std::unordered_map<T, std::size_t> toInexMap(const std::vector<T>& vec) + { + std::unordered_map<T, std::size_t> result; + result.reserve(vec.size()); + for (std::size_t i = 0; i < vec.size(); ++i) + { + auto emplacement = result.emplace(vec.at(i), i).second; + if (!emplacement) + { + throw std::invalid_argument {"The given vector did not contain unique elements!"}; + } + } + return result; + } + + public: + KinematicDataUnit(const std::vector<std::string>& jointNames): + jointAngles(jointNames.size(), ControllerConstatns::ValueNotSetNaN), + jointVelocites(jointNames.size(), ControllerConstatns::ValueNotSetNaN), + jointTorques(jointNames.size(), ControllerConstatns::ValueNotSetNaN), + jointCurrents(jointNames.size(), ControllerConstatns::ValueNotSetNaN), + jointMotorTemperatures(jointNames.size(), ControllerConstatns::ValueNotSetNaN), + jointGearTempertures(jointNames.size(), ControllerConstatns::ValueNotSetNaN), + jointNames {jointNames}, + jointIndices {toInexMap(jointNames)} + {} + KinematicDataUnit() = default; + KinematicDataUnit(const KinematicDataUnit&) = default; + + const std::vector<std::string>& getJointNames() const + { + return jointNames; + } + std::size_t getJointIndex(const std::string& joint) const + { + return jointIndices.at(joint); + } + + virtual std::vector<const float*> getJointAngles(const std::vector<std::string>& joints)const + { + return getPointers(joints, jointAngles); + } + virtual std::vector<const float*> getJointVelocities(const std::vector<std::string>& joints)const + { + return getPointers(joints, jointVelocites); + } + virtual std::vector<const float*> getJointTorques(const std::vector<std::string>& joints)const + { + return getPointers(joints, jointTorques); + } + virtual std::vector<const float*> getJointCurrents(const std::vector<std::string>& joints)const + { + return getPointers(joints, jointCurrents); + } + virtual std::vector<const float*> getJointMotorTemperatures(const std::vector<std::string>& joints)const + { + return getPointers(joints, jointMotorTemperatures); + } + virtual std::vector<const float*> getJointGearTemperatures(const std::vector<std::string>& joints)const + { + return getPointers(joints, jointGearTempertures); + } + + protected: + std::vector<float> jointAngles; + std::vector<float> jointVelocites; + std::vector<float> jointTorques; + std::vector<float> jointCurrents; + std::vector<float> jointMotorTemperatures; + std::vector<float> jointGearTempertures; + private: + template<class T> + std::vector<const T*> getPointers(const std::vector<std::string>& joints, const std::vector<T>& targets) const + { + std::vector<const T*> result; + result.resize(joints.size()); + std::transform( + joints.begin(), joints.end(), std::back_inserter(result), + [targets, this](const std::string & joint) + { + return &targets.at(getJointIndex(joint)); + } + ); + return result; + } + const std::vector<std::string> jointNames; + const std::unordered_map<std::string, std::size_t> jointIndices; + }; +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/DataUnits/PlatformDataUnit.h b/source/RobotAPI/libraries/Controllers/DataUnits/PlatformDataUnit.h new file mode 100644 index 0000000000000000000000000000000000000000..3fccfc8902e8986ca8757f30593762f9b5e0029a --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/DataUnits/PlatformDataUnit.h @@ -0,0 +1,69 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::PlatformDataUnit + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_PlatformDataUnit_H +#define _ARMARX_LIB_RobotAPI_PlatformDataUnit_H + +#include "../Constatnts.h" + +namespace armarx +{ + class PlatformDataUnit + { + public: + const float* getPositionX() const + { + return &positionX; + } + const float* getPositionY() const + { + return &positionY; + } + const float* getRotation() const + { + return &rotation; + } + + const float* getVelocityX() const + { + return &velocityX; + } + const float* getVelocityY() const + { + return &velocityY; + } + const float* getVelocityRotation() const + { + return &velocityRotation; + } + protected: + float positionX = ControllerConstatns::ValueNotSetNaN; + float positionY = ControllerConstatns::ValueNotSetNaN; + float rotation = ControllerConstatns::ValueNotSetNaN; + + float velocityX = ControllerConstatns::ValueNotSetNaN; + float velocityY = ControllerConstatns::ValueNotSetNaN; + float velocityRotation = ControllerConstatns::ValueNotSetNaN; + }; +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/LVL0Controller.cpp b/source/RobotAPI/libraries/Controllers/LVL0Controller.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f1314225db47875c050245ae3a477a13cad453ef --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/LVL0Controller.cpp @@ -0,0 +1,28 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::LVL0Controller + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "LVL0Controller.h" + + +using namespace armarx; + + diff --git a/source/RobotAPI/libraries/Controllers/LVL0Controller.h b/source/RobotAPI/libraries/Controllers/LVL0Controller.h new file mode 100644 index 0000000000000000000000000000000000000000..e38510288888bfc6b90ce0679b638f5f63c591b7 --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/LVL0Controller.h @@ -0,0 +1,81 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::LVL0Controller + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_LVL0Controller_H +#define _ARMARX_LIB_RobotAPI_LVL0Controller_H + +#include <stdexcept> + +namespace armarx +{ + /** + * @defgroup Library-Controllers Controllers + * @ingroup RobotAPI + * A description of the library Controllers. + * + * @class LVL0Controller + * @ingroup Library-Controllers + * @brief Brief description of class LVL0Controller. + * + * Detailed description of class LVL0Controller. + */ + template<class TargetT> + class LVL0Controller + { + public: + using TargetType = TargetT; + LVL0Controller() + { + resetTarget(); + } + + TargetType* getTarget() + { + return target; + } + + void resetTarget() + { + target.reset(); + } + + void run() + { + if (!target.valid()) + { + throw std::logic_error {"LVL0 Controller failed! Target is invalid"}; + } + writeTarget(); + resetTarget(); + } + + /** + * @brief This function needs to be implemented for a LVL0Controller. + * It sends the command to the robot (or writes it in its send buffer). + */ + void writeTarget() = 0; + + private: + TargetType target; + }; +} +#endif diff --git a/source/RobotAPI/libraries/Controllers/LVL1Controller.cpp b/source/RobotAPI/libraries/Controllers/LVL1Controller.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2ebd3f9241452b55cacec6bb108936c3ba70350 --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/LVL1Controller.cpp @@ -0,0 +1,28 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::LVL1Controller + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "LVL1Controller.h" + + +using namespace armarx; + + diff --git a/source/RobotAPI/libraries/Controllers/LVL1Controller.h b/source/RobotAPI/libraries/Controllers/LVL1Controller.h new file mode 100644 index 0000000000000000000000000000000000000000..8e44980e01990839a6d02b73528bf672f808d213 --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/LVL1Controller.h @@ -0,0 +1,56 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::LVL1Controller + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_LVL1Controller_H +#define _ARMARX_LIB_RobotAPI_LVL1Controller_H + +#include <map> + +#include <RobotAPI/interface/units/KinematicUnitInterface.h> + +#include "Targets/JointTargetBase.h" + +namespace armarx +{ + /** + * @defgroup Library-Controllers Controllers + * @ingroup RobotAPI + * A description of the library Controllers. + * + * @class LVL1Controller + * @ingroup Library-Controllers + * @brief Brief description of class LVL1Controller. + * + * Detailed description of class LVL1Controller. + */ + class LVL1Controller + { + public: + LVL1Controller(/*string instanceName, RobotUnitPtr robotUnit, ControllerConfig config*/); + virtual void run() = 0; + virtual std::map<std::string, ControlMode> getJointTargetDefinitions() = 0; + virtual void setJointTargetPtrs(std::vector<JointTargetBase*> ptrs) = 0; + }; + +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/SyntaxCheck.cpp b/source/RobotAPI/libraries/Controllers/SyntaxCheck.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b6406e2dddce0f3602d7781ba7e1c5f92d3a1884 --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/SyntaxCheck.cpp @@ -0,0 +1,37 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "Constatnts.h" +#include "LVL0Controller.h" +#include "LVL1Controller.h" + +#include "DataUnits/ForceTorqueDataUnit.h" +#include "DataUnits/HapticDataUnit.h" +#include "DataUnits/IMUDataUnit.h" +#include "DataUnits/KinematicDataUnit.h" +#include "DataUnits/PlatformDataUnit.h" + +#include "Targets/JointPositionTarget.h" +#include "Targets/JointPositionVelocityTarget.h" +#include "Targets/JointTargetBase.h" +#include "Targets/JointTorqueTarget.h" +#include "Targets/JointVelocityTarget.h" diff --git a/source/RobotAPI/libraries/Controllers/Targets/JointPositionTarget.h b/source/RobotAPI/libraries/Controllers/Targets/JointPositionTarget.h new file mode 100644 index 0000000000000000000000000000000000000000..9bc7d9d13e3ca59b209090e3e0156a2dd43c5bcc --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/Targets/JointPositionTarget.h @@ -0,0 +1,61 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::JointPositionTarget + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_JointPositionTarget_H +#define _ARMARX_LIB_RobotAPI_JointPositionTarget_H + +#include "JointTargetBase.h" + +namespace armarx +{ + /** + * @defgroup Library-Controllers Controllers + * @ingroup RobotAPI + * A description of the library Controllers. + * + * @class JointPositionTarget + * @ingroup Library-Controllers + * @brief Brief description of class JointPositionTarget. + * + * Detailed description of class JointPositionTarget. + */ + class JointPositionTarget: public JointTargetBase + { + public: + float position = ControllerConstatns::ValueNotSetNaN; + virtual ControlMode getType() const override + { + return ePositionControl; + } + virtual void reset() + { + position = ControllerConstatns::ValueNotSetNaN; + } + bool isValid() const + { + return std::isfinite(position); + } + }; + +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/Targets/JointPositionVelocityTarget.h b/source/RobotAPI/libraries/Controllers/Targets/JointPositionVelocityTarget.h new file mode 100644 index 0000000000000000000000000000000000000000..d2622cc9167c5dcb5a2ba736623b62d059171a74 --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/Targets/JointPositionVelocityTarget.h @@ -0,0 +1,63 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::JointPositionVelocityTarget + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_JointPositionVelocityTarget_H +#define _ARMARX_LIB_RobotAPI_JointPositionVelocityTarget_H + +#include "JointTargetBase.h" + +namespace armarx +{ + /** + * @defgroup Library-Controllers Controllers + * @ingroup RobotAPI + * A description of the library Controllers. + * + * @class JointPositionVelocityTarget + * @ingroup Library-Controllers + * @brief Brief description of class JointPositionVelocityTarget. + * + * Detailed description of class JointPositionVelocityTarget. + */ + class JointPositionVelocityTarget: public JointTargetBase + { + public: + float position = ControllerConstatns::ValueNotSetNaN; + float velocity = ControllerConstatns::ValueNotSetNaN; + virtual ControlMode getType() const override + { + return ePositionVelocityControl; + } + virtual void reset() + { + position = ControllerConstatns::ValueNotSetNaN; + velocity = ControllerConstatns::ValueNotSetNaN; + } + bool isValid() const + { + return std::isfinite(position) && std::isfinite(velocity); + } + }; + +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/Targets/JointTargetBase.h b/source/RobotAPI/libraries/Controllers/Targets/JointTargetBase.h new file mode 100644 index 0000000000000000000000000000000000000000..0dc9ee2b6ea27136b20722b7c4f3772a4f547374 --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/Targets/JointTargetBase.h @@ -0,0 +1,50 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::JointTargetBase + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_JointTargetBase_H +#define _ARMARX_LIB_RobotAPI_JointTargetBase_H + +#include <RobotAPI/interface/units/KinematicUnitInterface.h> +#include "../Constatnts.h" + +namespace armarx +{ + /** + * @defgroup Library-Controllers Controllers + * @ingroup RobotAPI + * A description of the library Controllers. + * + * @class JointTargetBase + * @ingroup Library-Controllers + * @brief Brief description of class JointTargetBase. + * + * Detailed description of class JointTargetBase. + */ + class JointTargetBase + { + public: + virtual ControlMode getType() const = 0; + }; + +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/Targets/JointTorqueTarget.h b/source/RobotAPI/libraries/Controllers/Targets/JointTorqueTarget.h new file mode 100644 index 0000000000000000000000000000000000000000..8b4ffad81a3d10e690ee43a05e2283977ad4f9b5 --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/Targets/JointTorqueTarget.h @@ -0,0 +1,61 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::JointTorqueTarget + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_JointTorqueTarget_H +#define _ARMARX_LIB_RobotAPI_JointTorqueTarget_H + +#include "JointTargetBase.h" + +namespace armarx +{ + /** + * @defgroup Library-Controllers Controllers + * @ingroup RobotAPI + * A description of the library Controllers. + * + * @class JointTorqueTarget + * @ingroup Library-Controllers + * @brief Brief description of class JointTorqueTarget. + * + * Detailed description of class JointTorqueTarget. + */ + class JointTorqueTarget: public JointTargetBase + { + public: + float torque = ControllerConstatns::ValueNotSetNaN; + virtual ControlMode getType() const override + { + return eTorqueControl; + } + virtual void reset() + { + torque = ControllerConstatns::ValueNotSetNaN; + } + bool isValid() const + { + return std::isfinite(torque); + } + }; + +} + +#endif diff --git a/source/RobotAPI/libraries/Controllers/Targets/JointVelocityTarget.h b/source/RobotAPI/libraries/Controllers/Targets/JointVelocityTarget.h new file mode 100644 index 0000000000000000000000000000000000000000..8f44b2c055922fdf5714665b1631a4acc2da41cb --- /dev/null +++ b/source/RobotAPI/libraries/Controllers/Targets/JointVelocityTarget.h @@ -0,0 +1,61 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::JointVelocityTarget + * @author Raphael ( ufdrv at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_LIB_RobotAPI_JointVelocityTarget_H +#define _ARMARX_LIB_RobotAPI_JointVelocityTarget_H + +#include "JointTargetBase.h" + +namespace armarx +{ + /** + * @defgroup Library-Controllers Controllers + * @ingroup RobotAPI + * A description of the library Controllers. + * + * @class JointVelocityTarget + * @ingroup Library-Controllers + * @brief Brief description of class JointVelocityTarget. + * + * Detailed description of class JointVelocityTarget. + */ + class JointVelocityTarget: public JointTargetBase + { + public: + float velocity = ControllerConstatns::ValueNotSetNaN; + virtual ControlMode getType() const override + { + return eVelocityControl; + } + virtual void reset() + { + velocity = ControllerConstatns::ValueNotSetNaN; + } + bool isValid() const + { + return std::isfinite(velocity); + } + }; + +} + +#endif