22 template <
int t_features>
48 Eigen::VectorXd velocity_in_local;
51 if((tags_velocity_.find(tag_name) != tags_velocity_.end()))
53 velocity_in_local = tags_velocity_.at(tag_name);
57 velocity_in_local.setZero();
60 const std::size_t part_size = 3;
64 return(velocity_in_local.tail(part_size));
66 return(velocity_in_local.head(part_size));
68 return(velocity_in_local);
82 tags_velocity_ = tag_velocity;
94 return(getTagVelocityInGlobal(model,
"CameraTop_optical_frame",
95 getTagVelocityInLocal(
"CameraTop_optical_frame",
111 const std::string& tag_name,
112 const etools::Vector6& tag_velocity_local,
116 "Computing global tag velocity requires full local tag velocity vector.")
120 Eigen::VectorXd velocity_in_global;
123 const std::size_t part_size = 3;
128 tag_velocity_local.tail(part_size);
133 * tag_velocity_local.tail(part_size))
135 tag_velocity_local.head(part_size);
140 tag_velocity_local.tail(part_size);
143 * tag_velocity_local.tail(part_size))
145 tag_velocity_local.head(part_size);
152 return(velocity_in_global);
163 std::map<std::string, etools::Vector6>::iterator i;
164 for(i = tags_velocity_.begin(); i != tags_velocity_.end(); ++i)
168 const std::size_t part_size = 3;
169 etools::Vector6 tag_pose;
178 getTagVelocityInGlobal(model, i->first,
179 getTagVelocityInLocal(i->first,
183 tags_desired_pose_global_[i->first] = tag_pose;
196 const std::string& tag_name)
const 198 etools::Vector6 tag_pose_error;
199 tag_pose_error.setZero();
201 if(tags_desired_pose_global_.find(tag_name) != tags_desired_pose_global_.end())
205 std::size_t part_size = 3;
211 tag_pose_error.tail(part_size) = tags_desired_pose_global_.at(tag_name).tail(part_size) - model.
getTagPosition(tag);
214 return(tag_pose_error);
223 solution_is_parsed_ =
false;
233 : wbc_parameters_(wbc_parameters)
235 solution_is_parsed_ =
false;
252 solution_is_parsed_ =
false;
255 sol_structure_.reset();
256 sol_structure_.addSolutionPart(
ROOT_VARIABLES_ID , ModelDescription<t_features>::ROOT_DOF_NUMBER);
257 sol_structure_.addSolutionPart(
JOINTS_VARIABLES_ID, ModelDescription<t_features>::JOINTS_DOF_NUMBER);
259 motion_parameters_ = motion_parameters;
261 return (control_status);
272 solution_is_parsed_ =
true;
289 HUMOTO_ASSERT(solution_is_parsed_ ==
false,
"The solution is parsed.");
290 parseSolution(solution);
293 next_generalized_coordinates = model.
getState();
297 return(next_generalized_coordinates);
312 HUMOTO_ASSERT(solution_is_parsed_ ==
true,
"This function can be called only after the solution is parsed.");
313 return(model.state_);
326 const std::string & name =
"wbc")
const boost::shared_ptr< const TagLink > TagLinkPtr
Abstract base class (for control problems)
static const char * ROOT_VARIABLES_ID
Root position and orientation.
std::map< std::string, etools::Vector6 > tags_velocity_
static std::size_t getNumberOfElements(const Type &spatial_type)
Returns number of elements (dimensionality) for given spatial data type.
WholeBodyController(const humoto::pepper_ik::WBCParameters &wbc_parameters)
Constructor.
static const char * JOINTS_VARIABLES_ID
Joint angles.
Desired motion parameters.
Eigen::VectorBlock< Eigen::VectorXd > getSolutionPart(const std::string &id)
Get part of the solution by its id.
etools::Vector3 getTagPosition(const rbdl::TagLinkPtr tag) const
Get tag position.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
#define HUMOTO_ASSERT(condition, message)
Container of the solution.
humoto::pepper_ik::GeneralizedCoordinates< t_features > getNextGeneralizedCoordinates(const humoto::Solution &solution, const humoto::pepper_ik::Model< t_features > &model)
Get next model state.
#define HUMOTO_THROW_MSG(s)
HUMOTO_THROW_MSG throws an error message concatenated with the name of the function (if supported)...
Represents log entry name.
humoto::pepper_ik::GeneralizedCoordinates< t_features > getNextGeneralizedCoordinates(const humoto::pepper_ik::Model< t_features > &model) const
Get next model state.
etools::Matrix3 getTagOrientation(const rbdl::TagLinkPtr tag) const
Get tag orientation.
Eigen::VectorXd getTagVelocityInGlobal(const humoto::pepper_ik::Model< t_features > &model, const std::string &tag_name, const etools::Vector6 &tag_velocity_local, const rbdl::SpatialType::Type &spatial_type) const
Get velocity in global frame.
etools::Vector3 convertMatrixToEulerAngles(const etools::Matrix3 &rotation_matrix, const EulerAngles::Type euler_angles_type)
Convert rotation matrix to Euler angles.
void setTagsVelocity(const std::map< std::string, etools::Vector6 > &tag_velocity)
Set tag(s) velocity.
etools::Vector3 getRotationErrorAngleAxis(const etools::Matrix3 ¤t, const etools::Matrix3 &reference)
etools::Matrix3 integrateAngularVelocity(const etools::Matrix3 &orientation, const etools::Vector3 &angular_velocity, const double dt)
Integrate angular velocity to obtain orientation matrix. Simple version.
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
std::map< std::string, etools::Vector6 > tags_desired_pose_global_
WholeBodyController()
Constructor.
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="wbc") const
Log.
etools::Vector6 getBaseVelocityInGlobal(const humoto::pepper_ik::Model< t_features > &model)
Get base velocity in global frame.
etools::Vector6 getTagPoseErrorInGlobal(const humoto::pepper_ik::Model< t_features > &model, const std::string &tag_name) const
Get tag pose error in global frame.
The root namespace of HuMoTo.
humoto::pepper_ik::WBCParameters wbc_parameters_
humoto::pepper_ik::MotionParameters motion_parameters_
rbdl::TagLinkPtr getLinkTag(const std::string &id) const
Get tag.
const GeneralizedCoordinates< t_features > & getState() const
Return current model state.
void parseSolution(const humoto::Solution &solution)
Process solution.
void computeTagsDesiredPoseInGlobal(const humoto::pepper_ik::Model< t_features > &model)
Get desired tag(s) pose in global frame.
Type
Type os spatial data.
ControlProblemStatus::Status update(humoto::pepper_ik::Model< t_features > &model, const humoto::pepper_ik::MotionParameters &motion_parameters)
Update control problem.
Parameters of the WBC problem.
etools::Matrix3 convertEulerAnglesToMatrix(const etools::Vector3 &euler_angles, const EulerAngles::Type euler_angles_type)
Convert rotation matrix to Euler angles.
Eigen::VectorXd getTagVelocityInLocal(const std::string &tag_name, const rbdl::SpatialType::Type &spatial_type) const
Get tag velocity in local frame (vx, vy, vz, wx, wy, wz)