1#ifndef __multicontact_api_scenario_contact_phase_hpp__ 2#define __multicontact_api_scenario_contact_phase_hpp__ 7#include <boost/serialization/map.hpp> 8#include <boost/serialization/string.hpp> 9#include <boost/serialization/vector.hpp> 27template <
typename _Scalar>
30 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
132 if (t_final < t_init)
133 throw std::invalid_argument(
"t_final cannot be inferior to t_initial");
137 template <
typename S2>
171 template <
typename S2>
186 (
m_q && other.
m_q &&
m_q->isApprox(other.
m_q.get()))) &&
194 (
m_c && other.
m_c &&
m_c->isApprox(other.
m_c.get()))) &&
200 (
m_L && other.
m_L &&
m_L->isApprox(other.
m_L.get()))) &&
218 template <
typename S2>
220 return !(*
this == other);
280 throw std::invalid_argument(
"t_final cannot be inferior to t_initial");
286 throw std::invalid_argument(
"Duration of the phase cannot be negative.");
296 throw std::invalid_argument(
297 "This contact phase do not contain any contact force trajectory for " 306 throw std::invalid_argument(
307 "This contact phase do not contain any normal contact force " 308 "trajectory for the effector " +
316 throw std::invalid_argument(
317 "This contact phase do not contain any effector trajectory for the " 336 throw std::invalid_argument(
337 "Cannot add a contact force trajectory for effector " + eeName +
338 " as it is not in contact for the current phase.");
342 std::pair<std::string, curve_ptr>(eeName, trajectory));
343 return !alreadyExist;
359 throw std::invalid_argument(
360 "Cannot add a contact normal trajectory for effector " + eeName +
361 " as it is not in contact for the current phase.");
362 if (trajectory->dim() != 1)
363 throw std::invalid_argument(
364 "Contact normal force trajectory must be of dimension 1");
368 std::pair<std::string, curve_ptr>(eeName, trajectory));
369 return !alreadyExist;
383 throw std::invalid_argument(
384 "Cannot add an effector trajectory for effector " + eeName +
385 " as it is in contact for the current phase.");
389 std::pair<std::string, curve_SE3_ptr>(eeName, trajectory));
390 return !alreadyExist;
396 throw std::invalid_argument(
397 "This contact phase do not contain any contact patch for the " 420 std::pair<std::string, ContactPatch>(eeName, patch));
422 return !alreadyExist;
464 for (
typename CurveSE3Map_t::const_iterator mit =
467 effectors.push_back(mit->first);
498 std::cout <<
"WARNING : not implemented yet, return True" << std::endl;
499 (void)throw_if_inconsistent;
537 if (
m_c->dim() != 3 ||
m_dc->dim() != 3 ||
m_ddc->dim() != 3)
538 throw std::invalid_argument(
"Dimension of the points must be 3.");
577 if (
m_L->dim() != 3 ||
m_dL->dim() != 3)
578 throw std::invalid_argument(
"Dimension of the points must be 3.");
665 to_patch_map.at(eeName).placement())
666 res.push_back(eeName);
678 std::set<std::string>
681 set_res.insert(eeName);
684 set_res.insert(eeName);
687 set_res.insert(eeName);
689 return t_strings(set_res.begin(), set_res.end());
694 void disp(std::ostream& os)
const {
695 Eigen::Matrix<Scalar, 3, 5> state0(Eigen::Matrix<Scalar, 3, 5>::Zero());
696 Eigen::Matrix<Scalar, 3, 5> state1(Eigen::Matrix<Scalar, 3, 5>::Zero());
697 state0.block(0, 0, 3, 1) =
m_c_init;
700 state0.block(0, 3, 3, 1) =
m_L_init;
710 <<
"Conecting (c0,dc0,ddc0,L0,dL0) = " << std::endl
711 << state0 << std::endl
712 <<
"to (c0,dc0,ddc0,L0,dL0) = " << std::endl
713 << state1 << std::endl;
718 os <<
"______________________________________________" << std::endl
719 <<
"Effector " << *ee <<
" contact patch:" << std::endl
721 <<
"Has contact force trajectory : " 723 <<
"Has contact normal force trajectory : " 728 template <
typename S2>
755 friend class boost::serialization::access;
757 template <
class Archive>
758 void serialize(Archive& ar,
const unsigned int version) {
760 unsigned int curve_version;
768 ar& boost::serialization::make_nvp(
"c_init",
m_c_init);
769 ar& boost::serialization::make_nvp(
"dc_init",
m_dc_init);
770 ar& boost::serialization::make_nvp(
"ddc_init",
m_ddc_init);
771 ar& boost::serialization::make_nvp(
"L_init",
m_L_init);
772 ar& boost::serialization::make_nvp(
"dL_init",
m_dL_init);
773 ar& boost::serialization::make_nvp(
"q_init",
m_q_init);
774 ar& boost::serialization::make_nvp(
"c_final",
m_c_final);
775 ar& boost::serialization::make_nvp(
"dc_final",
m_dc_final);
776 ar& boost::serialization::make_nvp(
"ddc_final",
m_ddc_final);
777 ar& boost::serialization::make_nvp(
"L_final",
m_L_final);
778 ar& boost::serialization::make_nvp(
"dL_final",
m_dL_final);
779 ar& boost::serialization::make_nvp(
"q_final",
m_q_final);
780 ar& boost::serialization::make_nvp(
"q",
m_q);
781 ar& boost::serialization::make_nvp(
"dq",
m_dq);
782 ar& boost::serialization::make_nvp(
"ddq",
m_ddq);
783 ar& boost::serialization::make_nvp(
"tau",
m_tau);
784 ar& boost::serialization::make_nvp(
"c",
m_c);
785 ar& boost::serialization::make_nvp(
"dc",
m_dc);
786 ar& boost::serialization::make_nvp(
"ddc",
m_ddc);
787 ar& boost::serialization::make_nvp(
"L",
m_L);
788 ar& boost::serialization::make_nvp(
"dL",
m_dL);
789 ar& boost::serialization::make_nvp(
"wrench",
m_wrench);
790 ar& boost::serialization::make_nvp(
"zmp",
m_zmp);
791 ar& boost::serialization::make_nvp(
"root",
m_root);
793 ar& boost::serialization::make_nvp(
"contact_normal_force",
795 ar& boost::serialization::make_nvp(
"effector_trajectories",
797 ar& boost::serialization::make_nvp(
"effector_in_contact",
800 ar& boost::serialization::make_nvp(
"t_init",
m_t_init);
801 ar& boost::serialization::make_nvp(
"t_final",
m_t_final);
void register_types(Archive &ar, const unsigned int version)
std::vector< pointX_t, Eigen::aligned_allocator< pointX_t > > t_pointX_t
curve_abc< double, double, true, transform_t, point6_t > curve_SE3_t
std::shared_ptr< curve_SE3_t > curve_SE3_ptr_t
curve_abc< double, double, true, pointX_t, pointX_t > curve_abc_t
std::vector< point3_t, Eigen::aligned_allocator< point3_t > > t_point3_t
std::shared_ptr< curve_abc_t > curve_ptr_t
Eigen::Transform< double, 3, Eigen::Affine > transform_t
piecewise_curve< double, double, true, point3_t, point3_t, curve_3_t > piecewise3_t
Eigen::Matrix< double, 6, 1 > point6_t
polynomial< double, double, true, pointX_t, t_pointX_t > polynomial_t
piecewise_curve< double, double, true, pointX_t, pointX_t, curve_abc_t > piecewise_t
#define MULTICONTACT_API_DEFINE_CLASS_TEMPLATE_VERSION(Template, Type)
Definition archive.hpp:22
Definition curve-map.hpp:21
static piecewise_curve_t convert_discrete_points_to_polynomial(t_point_t points, t_time_t time_points)
std::vector< Time > t_time_t