hpp-python: include/pyhpp/core/problem.hh Source File

hpp-python 9.0.2 python bindings for HPP, based on boost python

Loading...
Searching...
No Matches
problem.hh
Go to the documentation of this file.
1// problem.hh
2//
3// Copyright (c) 2025, CNRS
4// Authors: Paul Sardin
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions
8// are met:
9
10// 1. Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12
13// 2. Redistributions in binary form must reproduce the above
14// copyright notice, this list of conditions and the following
15// disclaimer in the documentation and/or other materials provided
16// with the distribution.
17
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29// OF THE POSSIBILITY OF SUCH DAMAGE.
30
31#ifndef PYHPP_CORE_PROBLEM_HH
32#define PYHPP_CORE_PROBLEM_HH
33
34#include <hpp/manipulation/problem.hh>
35#include <hpp/pinocchio/device.hh>
36#include <hpp/util/pointer.hh>
37#include <pyhpp/core/fwd.hh>
38
39namespace pyhpp {
40namespace core {
41
42struct SteeringMethod;
43 typedef std::shared_ptr<SteeringMethod> PyWSteeringMethodPtr_t;
44
45 typedef hpp::core::ProblemPtr_t ProblemPtr_t;
46typedef hpp::core::ProblemConstPtr_t ProblemConstPtr_t;
47 typedef hpp::core::DevicePtr_t DevicePtr_t;
48 typedef hpp::core::Parameter Parameter;
49 typedef hpp::core::ConfigurationIn_t ConfigurationIn_t;
50 typedef hpp::core::ConfigurationShooterPtr_t ConfigurationShooterPtr_t;
51 typedef hpp::core::SteeringMethodPtr_t SteeringMethodPtr_t;
52 typedef hpp::core::ConfigValidationsPtr_t ConfigValidationsPtr_t;
53 typedef hpp::core::PathValidationPtr_t PathValidationPtr_t;
54 typedef hpp::core::PathProjectorPtr_t PathProjectorPtr_t;
55 typedef hpp::core::ProblemTargetPtr_t ProblemTargetPtr_t;
56 typedef hpp::core::DistancePtr_t DistancePtr_t;
57 typedef hpp::core::value_type value_type;
58 typedef hpp::core::size_type size_type;
59 typedef hpp::core::Configuration_t Configuration_t;
60
61// Wrapper class for hpp::core::Problem
62 struct Problem {
63 hpp::core::ProblemPtr_t obj;
64 Problem(const DevicePtr_t& robot);
65 Problem(hpp::core::ProblemPtr_t problemPtr) : obj(problemPtr) {}
66
67 // wrapped methods
68 const DevicePtr_t& robot() const;
69 void setParameter(const std::string& name, const Parameter& value);
70 void setParameterFloat(const std::string& name, value_type value);
71 void setParameterInt(const std::string& name, size_type value);
72 const Parameter& getParameter(const std::string& name) const;
73 PyWSteeringMethodPtr_t steeringMethod() const;
74 const ConfigValidationsPtr_t& configValidation() const;
75 PathValidationPtr_t pathValidation() const;
76 PathProjectorPtr_t pathProjector() const;
77 DistancePtr_t distance() const;
78 const ProblemTargetPtr_t& target() const;
79 ConfigurationShooterPtr_t configurationShooter() const;
80 void steeringMethod(const PyWSteeringMethodPtr_t& steeringMethod);
81 void configValidation(const ConfigValidationsPtr_t& cv);
82 void clearConfigValidations();
83 void pathValidation(const PathValidationPtr_t& pv);
84 void pathProjector(const PathProjectorPtr_t& pp);
85 void distance(const DistancePtr_t& d);
86 void target(const ProblemTargetPtr_t& t);
87 void configurationShooter(
88 const ConfigurationShooterPtr_t& configurationShooter);
89 void initConfig(ConfigurationIn_t inConfig);
90 void addGoalConfig(ConfigurationIn_t config);
91 void addConfigValidation(const std::string& type);
92 void resetGoalConfigs();
93
94 hpp::manipulation::ProblemPtr_t asManipulationProblem() const {
95 auto manipProb = HPP_DYNAMIC_PTR_CAST(hpp::manipulation::Problem, obj);
96 if (!manipProb) {
97 throw std::runtime_error("Not a manipulation problem");
98 }
99 return manipProb;
100 }
101
102 bool isManipulationProblem() const {
103 return bool(HPP_DYNAMIC_PTR_CAST(hpp::manipulation::Problem, obj));
104 }
105
106 // Constraints utility functions
107
108 void addPartialCom(const std::string& name, boost::python::list pyjointNames);
109 hpp::pinocchio::vector3_t getPartialCom(const std::string& name);
110 std::map<std::string, hpp::pinocchio::CenterOfMassComputationPtr_t>
111 centerOfMassComputations;
112 hpp::constraints::ImplicitPtr_t createRelativeComConstraint(
113 const char* constraintName, const char* comName, const char* jointName,
114 hpp::pinocchio::vector3_t point, boost::python::list mask);
115
116 hpp::constraints::ImplicitPtr_t createTransformationConstraint(
117 const char* constraintName, const char* joint1Name,
118 const char* joint2Name, const hpp::pinocchio::Transform3s& M,
119 boost::python::list mask);
120
121 hpp::constraints::ImplicitPtr_t createTransformationConstraint2(
122 const char* constraintName, const char* joint1Name,
123 const char* joint2Name, const hpp::pinocchio::Transform3s& M1,
124 const hpp::pinocchio::Transform3s& M2, const boost::python::list mask);
125
126 void setConstantRightHandSide(hpp::constraints::ImplicitPtr_t constraint,
127 bool constant);
128
129 boost::python::tuple applyConstraints(ConfigurationIn_t config);
130 boost::python::tuple isConfigValid(ConfigurationIn_t dofArray);
131 void setConstraints(hpp::core::ConstraintSetPtr_t constraints);
132 hpp::core::ConstraintSetPtr_t getConstraints();
133 void setRightHandSideFromConfig(ConfigurationIn_t configIn);
134
135 void addNumericalConstraintsToConfigProjector1(
136 const char* configProjName, boost::python::list constraints,
137 boost::python::list priorities);
138 void addNumericalConstraintsToConfigProjector2(
139 const char* configProjName, boost::python::list constraints);
140 hpp::constraints::ImplicitPtr_t createComBetweenFeet(
141 const char* constraintName, const char* comName, const char* jointLName,
142 const char* jointRName, const hpp::pinocchio::vector3_t& pointL,
143 const hpp::pinocchio::vector3_t& pointR, const char* jointRefName,
144 const hpp::pinocchio::vector3_t& pointRef, boost::python::list mask);
145
146 boost::python::tuple directPath(ConfigurationIn_t start,
147 ConfigurationIn_t end, bool validate);
148 hpp::core::ConstraintSetPtr_t constraints_;
149 value_type errorThreshold_;
150 size_type maxIterProjection_;
151};
152
153} // namespace core
154} // namespace pyhpp
155
156#endif // PYHPP_CORE_PROBLEM_HH
hpp::core::Parameter
hpp::core::Problem
hpp::core::Problem::configValidation
void configValidation(const ConfigValidationsPtr_t &configValidations)
Definition problem.cc:190
hpp::core::Problem::steeringMethod
SteeringMethodPtr_t steeringMethod() const
Definition problem.cc:161
hpp::core::Problem::Problem
Problem()
hpp::core::Problem::addConfigValidation
void addConfigValidation(const ConfigValidationPtr_t &configValidation)
hpp::core::Problem::configurationShooter
ConfigurationShooterPtr_t configurationShooter() const
Definition problem.cc:157
hpp::core::Problem::constraints
const ConstraintSetPtr_t & constraints() const
hpp::core::Problem::robot
const DevicePtr_t & robot() const
Definition problem.cc:126
hpp::manipulation::Problem
fwd.hh
directPath
PathPtr_t directPath(ConfigurationIn_t q1, ConfigurationIn_t q2, bool validate, bool &success, std::string &status)
hpp::constraints::ImplicitPtr_t
shared_ptr< Implicit > ImplicitPtr_t
hpp::core::value_type
pinocchio::value_type value_type
hpp::core::PathValidationPtr_t
shared_ptr< PathValidation > PathValidationPtr_t
hpp::core::DistancePtr_t
shared_ptr< Distance > DistancePtr_t
hpp::core::ConfigurationShooterPtr_t
shared_ptr< ConfigurationShooter > ConfigurationShooterPtr_t
hpp::core::PathProjectorPtr_t
shared_ptr< PathProjector > PathProjectorPtr_t
hpp::core::ProblemTargetPtr_t
shared_ptr< ProblemTarget > ProblemTargetPtr_t
hpp::core::ConfigValidationsPtr_t
shared_ptr< ConfigValidations > ConfigValidationsPtr_t
hpp::core::ProblemPtr_t
shared_ptr< Problem > ProblemPtr_t
hpp::core::SteeringMethodPtr_t
shared_ptr< SteeringMethod > SteeringMethodPtr_t
hpp::core::ConfigurationIn_t
pinocchio::ConfigurationIn_t ConfigurationIn_t
hpp::core::size_type
pinocchio::size_type size_type
hpp::core::ProblemConstPtr_t
shared_ptr< const Problem > ProblemConstPtr_t
hpp::core::Configuration_t
pinocchio::Configuration_t Configuration_t
hpp::core::DevicePtr_t
pinocchio::DevicePtr_t DevicePtr_t
hpp::core::ConstraintSetPtr_t
shared_ptr< ConstraintSet > ConstraintSetPtr_t
hpp::manipulation::ProblemPtr_t
shared_ptr< Problem > ProblemPtr_t
hpp::pinocchio::vector3_t
Eigen::Matrix< value_type, 3, 1 > vector3_t
hpp::pinocchio::Transform3s
::pinocchio::SE3 Transform3s
pyhpp::core::Parameter
hpp::core::Parameter Parameter
Definition problem.hh:48
pyhpp::core::PyWSteeringMethodPtr_t
std::shared_ptr< SteeringMethod > PyWSteeringMethodPtr_t
Definition problem.hh:43
pyhpp
Definition fwd.hh:35
pointer.hh
HPP_DYNAMIC_PTR_CAST
#define HPP_DYNAMIC_PTR_CAST(t, x)
pyhpp::core::Problem::pathProjector
void pathProjector(const PathProjectorPtr_t &pp)
pyhpp::core::Problem::setConstraints
void setConstraints(hpp::core::ConstraintSetPtr_t constraints)
Definition problem.cc:415
pyhpp::core::Problem::setParameter
void setParameter(const std::string &name, const Parameter &value)
pyhpp::core::Problem::applyConstraints
boost::python::tuple applyConstraints(ConfigurationIn_t config)
Definition problem.cc:378
pyhpp::core::Problem::createRelativeComConstraint
hpp::constraints::ImplicitPtr_t createRelativeComConstraint(const char *constraintName, const char *comName, const char *jointName, hpp::pinocchio::vector3_t point, boost::python::list mask)
Definition problem.cc:256
pyhpp::core::Problem::target
const ProblemTargetPtr_t & target() const
pyhpp::core::Problem::setParameterFloat
void setParameterFloat(const std::string &name, value_type value)
Definition problem.cc:132
pyhpp::core::Problem::getConstraints
hpp::core::ConstraintSetPtr_t getConstraints()
Definition problem.cc:426
pyhpp::core::Problem::target
void target(const ProblemTargetPtr_t &t)
pyhpp::core::Problem::asManipulationProblem
hpp::manipulation::ProblemPtr_t asManipulationProblem() const
Definition problem.hh:94
pyhpp::core::Problem::isManipulationProblem
bool isManipulationProblem() const
Definition problem.hh:102
pyhpp::core::Problem::maxIterProjection_
size_type maxIterProjection_
Definition problem.hh:150
pyhpp::core::Problem::isConfigValid
boost::python::tuple isConfigValid(ConfigurationIn_t dofArray)
Definition problem.cc:394
pyhpp::core::Problem::pathProjector
PathProjectorPtr_t pathProjector() const
pyhpp::core::Problem::constraints_
hpp::core::ConstraintSetPtr_t constraints_
Definition problem.hh:148
pyhpp::core::Problem::createTransformationConstraint
hpp::constraints::ImplicitPtr_t createTransformationConstraint(const char *constraintName, const char *joint1Name, const char *joint2Name, const hpp::pinocchio::Transform3s &M, boost::python::list mask)
Definition problem.cc:285
pyhpp::core::Problem::distance
void distance(const DistancePtr_t &d)
pyhpp::core::Problem::configurationShooter
ConfigurationShooterPtr_t configurationShooter() const
pyhpp::core::Problem::errorThreshold_
value_type errorThreshold_
Definition problem.hh:149
pyhpp::core::Problem::Problem
Problem(hpp::core::ProblemPtr_t problemPtr)
Definition problem.hh:65
pyhpp::core::Problem::resetGoalConfigs
void resetGoalConfigs()
pyhpp::core::Problem::robot
const DevicePtr_t & robot() const
pyhpp::core::Problem::steeringMethod
PyWSteeringMethodPtr_t steeringMethod() const
pyhpp::core::Problem::setRightHandSideFromConfig
void setRightHandSideFromConfig(ConfigurationIn_t configIn)
Definition problem.cc:434
pyhpp::core::Problem::setConstantRightHandSide
void setConstantRightHandSide(hpp::constraints::ImplicitPtr_t constraint, bool constant)
Definition problem.cc:359
pyhpp::core::Problem::createComBetweenFeet
hpp::constraints::ImplicitPtr_t createComBetweenFeet(const char *constraintName, const char *comName, const char *jointLName, const char *jointRName, const hpp::pinocchio::vector3_t &pointL, const hpp::pinocchio::vector3_t &pointR, const char *jointRefName, const hpp::pinocchio::vector3_t &pointRef, boost::python::list mask)
Definition problem.cc:490
pyhpp::core::Problem::configurationShooter
void configurationShooter(const ConfigurationShooterPtr_t &configurationShooter)
pyhpp::core::Problem::obj
hpp::core::ProblemPtr_t obj
Definition problem.hh:63
pyhpp::core::Problem::addNumericalConstraintsToConfigProjector1
void addNumericalConstraintsToConfigProjector1(const char *configProjName, boost::python::list constraints, boost::python::list priorities)
Definition problem.cc:448
pyhpp::core::Problem::clearConfigValidations
void clearConfigValidations()
pyhpp::core::Problem::centerOfMassComputations
std::map< std::string, hpp::pinocchio::CenterOfMassComputationPtr_t > centerOfMassComputations
Definition problem.hh:111
pyhpp::core::Problem::setParameterInt
void setParameterInt(const std::string &name, size_type value)
Definition problem.cc:137
pyhpp::core::Problem::getParameter
const Parameter & getParameter(const std::string &name) const
pyhpp::core::Problem::pathValidation
PathValidationPtr_t pathValidation() const
pyhpp::core::Problem::createTransformationConstraint2
hpp::constraints::ImplicitPtr_t createTransformationConstraint2(const char *constraintName, const char *joint1Name, const char *joint2Name, const hpp::pinocchio::Transform3s &M1, const hpp::pinocchio::Transform3s &M2, const boost::python::list mask)
Definition problem.cc:321
pyhpp::core::Problem::configValidation
void configValidation(const ConfigValidationsPtr_t &cv)
pyhpp::core::Problem::distance
DistancePtr_t distance() const
pyhpp::core::Problem::pathValidation
void pathValidation(const PathValidationPtr_t &pv)
pyhpp::core::Problem::addGoalConfig
void addGoalConfig(ConfigurationIn_t config)
pyhpp::core::Problem::initConfig
void initConfig(ConfigurationIn_t inConfig)
pyhpp::core::Problem::addNumericalConstraintsToConfigProjector2
void addNumericalConstraintsToConfigProjector2(const char *configProjName, boost::python::list constraints)
Definition problem.cc:470