Closed Flo-Wo closed 1 year ago
Hi,
I can't reproduce without FrictionModel.hpp & ActionModel.hpp. Could you either fix your cpp or include those files ?
Ah yes, you are perfectly right. Sorry for the inconvenience and thanks for the quick response!
FrictionModel.hpp
#ifndef FRICTION_MODEL_HPP
#define FRICTION_MODEL_HPP
#include <Eigen/Dense>
class FrictionModel {
public:
FrictionModel(const Eigen::Ref<const Eigen::VectorXd>& coulomb_friction,
const Eigen::Ref<const Eigen::VectorXd>& damping,
float coulomb_slope = 100.0
)
: coulomb_friction_(coulomb_friction), damping_(damping), coulomb_slope_(coulomb_slope) {}
// calculation methods
Eigen::VectorXd calc(const Eigen::Ref<const Eigen::VectorXd>& v) const {
return (-1) * (coulomb_friction_.array() * (coulomb_slope_ * v).array().tanh()).matrix() - v.cwiseProduct(damping_);
}
Eigen::MatrixXd calcDiff(const Eigen::Ref<const Eigen::VectorXd>& v) const {
return ((-1) * coulomb_slope_ * (1 - (coulomb_slope_ * v).array().tanh().square())).matrix().asDiagonal() - damping_.asDiagonal();
}
private:
Eigen::VectorXd coulomb_friction_;
Eigen::VectorXd damping_;
float coulomb_slope_;
};
#endif // FRICTION_MODEL_HPP
and
ActionModel.hpp
#ifndef ACTION_MODEL_HPP
#define ACTION_MODEL_HPP
#include <crocoddyl/core/action-base.hpp>
#include <crocoddyl/core/actuation-base.hpp>
#include <crocoddyl/core/data-collector-base.hpp>
#include <crocoddyl/core/utils/exception.hpp>
#include <crocoddyl/core/diff-action-base.hpp>
#include <crocoddyl/core/costs/cost-sum.hpp>
#include <crocoddyl/multibody/states/multibody.hpp>
#include <crocoddyl/multibody/data/multibody.hpp>
#include "FrictionModel.hpp"
class DifferentialActionModelFrictionFwdDynamics : public crocoddyl::DifferentialActionModelAbstract {
public:
DifferentialActionModelFrictionFwdDynamics(
boost::shared_ptr<crocoddyl::StateMultibody> state,
boost::shared_ptr<crocoddyl::ActuationModelAbstract> actuation,
boost::shared_ptr<crocoddyl::CostModelSum> costs,
const Eigen::VectorXd& armature = Eigen::VectorXd(),
const Eigen::VectorXd& damping = Eigen::VectorXd(),
const Eigen::VectorXd& coulomb_friction = Eigen::VectorXd(),
const Eigen::VectorXi& grav_comp_idxs = Eigen::VectorXi()
);
void calc(const boost::shared_ptr<DifferentialActionDataAbstract>& data,
const Eigen::Ref<const Eigen::VectorXd>& x,
const Eigen::Ref<const Eigen::VectorXd>& u = Eigen::VectorXd());
void calcDiff(const boost::shared_ptr<DifferentialActionDataAbstract>& data,
const Eigen::Ref<const Eigen::VectorXd>& x,
const Eigen::Ref<const Eigen::VectorXd>& u);
// void quasiStatic(
// const boost::shared_ptr<DifferentialActionDataAbstract>& data,
// Eigen::Ref<VectorXs> u, const Eigen::Ref<const VectorXs>& x,
// const std::size_t maxIter, const float tol
// );
boost::shared_ptr<crocoddyl::DifferentialActionDataAbstract> createData();
// make all attributes public
boost::shared_ptr<crocoddyl::ActuationModelAbstract> actuation_;
boost::shared_ptr<crocoddyl::StateMultibody> state_;
boost::shared_ptr<crocoddyl::CostModelSum> costs_;
// pinocchio part
pinocchio::Model pinocchio_;
// friction model
Eigen::VectorXd armature_;
Eigen::VectorXd damping_;
Eigen::VectorXd coulomb_friction_;
Eigen::VectorXi grav_comp_idxs_;
FrictionModel friction_model_;
};
#endif // ACTION_MODEL_HPP
Closing this issue due to inactivity
Hi all,
thank you for providing such an amazing package. After we achieved outstanding results in simulation with your package, we want to transfer our results to the real system and thus need a C++ implementation.
After building all the dependencies from source and then building crocoddyl 2.0 from source (which worked like a charm), I receive the following error
when I try to compile the following custom model:
I use the following command to start the compiler:
I tried it with different version, e.g. c++20, but that did not work due to some error in the boost library which does not seem to be fixed yet.
Since I am not a C++ expert, I am really grateful for your hints.
Thank you very much in advance!