Skip to content
Snippets Groups Projects
DynamicsHelper.h 2.69 KiB
Newer Older
/*
 * This file is part of ArmarX.
 *
 * Copyright (C) 2011-2017, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
 *
 * 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    ArmarX
 * @author     Mirko Waechter( mirko.waechter at kit dot edu)
 * @date       2019
 * @copyright  http://www.gnu.org/licenses/gpl-2.0.txt
 *             GNU General Public License
 */
#pragma once
#include <Eigen/Core>
Christoph Pohl's avatar
Christoph Pohl committed

#include <VirtualRobot/Dynamics/Dynamics.h>
#include <VirtualRobot/VirtualRobot.h>
Christoph Pohl's avatar
Christoph Pohl committed

#include <RobotAPI/components/units/RobotUnit/SensorValues/SensorValue1DoFActuator.h>

namespace armarx::rtfilters
{
    class RTFilterBase;
    using RTFilterBasePtr = std::shared_ptr<RTFilterBase>;
Christoph Pohl's avatar
Christoph Pohl committed
} // namespace armarx::rtfilters
namespace armarx
{
    class RobotUnit;
Christoph Pohl's avatar
Christoph Pohl committed

    class DynamicsHelper
    {
    public:
        struct DynamicsData
        {
Christoph Pohl's avatar
Christoph Pohl committed
            DynamicsData(VirtualRobot::RobotNodeSetPtr rnsJoints,
                         VirtualRobot::RobotNodeSetPtr rnsBodies);
Christoph Pohl's avatar
Christoph Pohl committed

            DynamicsData(const DynamicsData& r) = default;
            VirtualRobot::RobotNodeSetPtr rnsJoints, rnsBodies;
            VirtualRobot::Dynamics dynamics;
            Eigen::VectorXd q, qDot, qDDot, tau, tauGravity;
Christoph Pohl's avatar
Christoph Pohl committed
            std::vector<std::pair<VirtualRobot::RobotNodePtr, SensorValue1DoFActuator*>>
                nodeSensorVec;
            std::vector<rtfilters::RTFilterBasePtr> velocityFilter;
            std::vector<rtfilters::RTFilterBasePtr> accelerationFilter;
        };

        DynamicsHelper(RobotUnit* robotUnit);
        ~DynamicsHelper() = default;
Christoph Pohl's avatar
Christoph Pohl committed
        void
        addRobotPart(VirtualRobot::RobotNodeSetPtr rnsJoints,
                     VirtualRobot::RobotNodeSetPtr rnsBodies,
                     rtfilters::RTFilterBasePtr velocityFilter = rtfilters::RTFilterBasePtr(),
                     rtfilters::RTFilterBasePtr accelerationFilter = rtfilters::RTFilterBasePtr());
        void update(const IceUtil::Time& sensorValuesTimestamp,
                    const IceUtil::Time& timeSinceLastIteration);

    protected:
        RobotUnit* robotUnit;
        std::map<VirtualRobot::RobotNodeSetPtr, DynamicsData> dataMap;
    };

Christoph Pohl's avatar
Christoph Pohl committed
} // namespace armarx