/* * 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 armar7_rt * @author Tobias Gröger ( tobias dot groeger at student dot kit dot edu ) * @date 2023 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt * GNU General Public License */ #pragma once #include <ArmarXCore/interface/core/BasicTypes.h> #include "RobotAPI/components/units/RobotUnit/SensorValues/SensorValue1DoFActuator.h" #include <RobotAPI/components/units/RobotUnit/ControlTargets/ControlTarget1DoFActuator.h> #include <RobotAPI/components/units/RobotUnit/NJointControllers/NJointController.h> #include <RobotAPI/components/units/RobotUnit/RobotUnit.h> namespace armarx { struct Params { std::string kneeJointName; std::string hipJointName; std::string hipBodyName; }; struct Config { Params params; float kneeAngle; float bowAngle; }; // TYPEDEF_PTRS_HANDLE(NJointKneeHipControllerConfig); TYPEDEF_PTRS_HANDLE(NJointKneeHipController); class NJointKneeHipController : virtual public armarx::NJointControllerWithTripleBuffer<Config> { public: // using ConfigPtrT = NJointKneeHipControllerPtr; using ConfigPtrT = NJointControllerConfigPtr; NJointKneeHipController(RobotUnit* robotUnit, const armarx::NJointControllerConfigPtr& config, const VirtualRobot::RobotPtr& /* unused */); ~NJointKneeHipController() override; // void updateConfig(const ::armarx::aron::data::dto::DictPtr& dto, // const Ice::Current& iceCurrent = Ice::emptyCurrent) ; void onPublish(const SensorAndControl&, const DebugDrawerInterfacePrx&, const DebugObserverInterfacePrx& debugObserver) override; protected: // // NJointControllerInterface interface // void onInitNJointController() override; void onConnectNJointController() override; std::string getClassName(const Ice::Current& = Ice::emptyCurrent) const override; void rtRun(const IceUtil::Time& sensorValuesTimestamp, const IceUtil::Time& timeSinceLastIteration) override; void rtPreActivateController() override; void rtPostDeactivateController() override; // ---------------- private: // rt variables VirtualRobot::RobotPtr _rtRobot; VirtualRobot::RobotNodePtr _rtKneeNode; VirtualRobot::RobotNodePtr _rtHipNode; VirtualRobot::RobotNodePtr _rtHipBodyNode; const SensorValue1DoFActuatorVelocity* velocitySensor; // const SensorValue1DoFActuatorPosition* positionSensor; static double calculate_dAnkle_dKnee(double kneeAngle, double shank, double p1, double p2, double p3); static double calculate_psi(double kneeAngle, double shank, double p1, double p2, double p3); // armarx::ControlTarget1DoFActuatorPosition* _rtKneeCtrlTarget; armarx::ControlTarget1DoFActuatorVelocity* _rtHipCtrlTarget; struct DebugData { std::int64_t localTimestamp; double kneeAngle; double kneeVelocity; double hipAngle; double hipVelocity; }; TripleBuffer<DebugData> bufferRtToOnPublish_; }; } // namespace armarx