robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
contact_sequence.hpp
Go to the documentation of this file.
1#ifndef ROBOTOC_CONTACT_SEQUENCE_HPP_
2#define ROBOTOC_CONTACT_SEQUENCE_HPP_
3
4#include <deque>
5#include <iostream>
6#include <memory>
7#include <cassert>
8
10#include "robotoc/robot/se3.hpp"
15
16
17namespace robotoc {
18
24public:
32 ContactSequence(const Robot& robot, const int reserved_num_discrete_events=0);
33
38
42 ~ContactSequence() = default;
43
48
53
57 ContactSequence(ContactSequence&&) noexcept = default;
58
62 ContactSequence& operator=(ContactSequence&&) noexcept = default;
63
69 void init(const ContactStatus& contact_status);
70
82 void push_back(const DiscreteEvent& discrete_event, const double event_time,
83 const bool sto=false);
84
98 void push_back(const ContactStatus& contact_status,
99 const double switching_time, const bool sto=false);
100
105 void pop_back();
106
111 void pop_front();
112
119 void setImpactTime(const int impact_index, const double impact_time);
120
127 void setLiftTime(const int lift_index, const double lift_time);
128
134 bool isSTOEnabledImpact(const int impact_index) const;
135
141 bool isSTOEnabledLift(const int lift_index) const;
142
148
158 const int contact_phase,
159 const std::vector<Eigen::Vector3d>& contact_positions);
160
170 const int contact_phase,
171 const std::vector<Eigen::Vector3d>& contact_positions,
172 const std::vector<Eigen::Matrix3d>& contact_rotations);
173
181 void setContactPlacements(const int contact_phase,
182 const aligned_vector<SE3>& contact_placements);
183
190 void setFrictionCoefficients(const int contact_phase,
191 const std::vector<double>& friction_coefficients);
192
197 int numContactPhases() const {
198 return contact_statuses_.size();
199 }
200
206 int numDiscreteEvents() const {
207 return (numContactPhases()-1);
208 }
209
214 int numImpactEvents() const {
215 return impact_events_.size();
216 }
217
222 int numLiftEvents() const {
224 }
225
231 const ContactStatus& contactStatus(const int contact_phase) const {
232 assert(contact_phase >= 0);
233 assert(contact_phase < numContactPhases());
234 return contact_statuses_[contact_phase];
235 }
236
242 const ImpactStatus& impactStatus(const int impact_index) const {
243 assert(impact_index >= 0);
244 assert(impact_index < numImpactEvents());
245 return impact_events_[impact_index].impactStatus();
246 }
247
252 double impactTime(const int impact_index) const {
253 assert(impact_index >= 0);
254 assert(impact_index < numImpactEvents());
255 return impact_time_[impact_index];
256 }
257
262 double liftTime(const int lift_index) const {
263 assert(lift_index >= 0);
264 assert(lift_index < numLiftEvents());
265 return lift_time_[lift_index];
266 }
267
274 DiscreteEventType eventType(const int event_index) const {
275 assert(event_index >= 0);
276 assert(event_index < numImpactEvents()+numLiftEvents());
277 if (is_impact_event_[event_index]) return DiscreteEventType::Impact;
278 else return DiscreteEventType::Lift;
279 }
280
285 const std::deque<double>& eventTimes() const {
286 return event_time_;
287 }
288
294 void reserve(const int reserved_num_discrete_events);
295
300
304 void disp(std::ostream& os) const;
305
306 friend std::ostream& operator<<(std::ostream& os,
307 const ContactSequence& contact_sequence);
308
309 friend std::ostream& operator<<(
310 std::ostream& os,
311 const std::shared_ptr<ContactSequence>& contact_sequence);
312
313private:
314 int reserved_num_discrete_events_;
315 ContactStatus default_contact_status_;
316 std::deque<ContactStatus> contact_statuses_;
317 std::deque<DiscreteEvent> impact_events_;
318 std::deque<int> event_index_impact_, event_index_lift_;
319 std::deque<double> event_time_, impact_time_, lift_time_;
320 std::deque<bool> is_impact_event_, sto_impact_, sto_lift_;
321
322 void clear();
323};
324
325} // namespace robotoc
326
327#endif // ROBOTOC_CONTACT_SEQUENCE_HPP_
The sequence of contact status and discrete events (impact and lift).
Definition: contact_sequence.hpp:23
int numContactPhases() const
Returns number of contact phases.
Definition: contact_sequence.hpp:197
void init(const ContactStatus &contact_status)
Sets the contact status over all of the time stages uniformly. Also, disable discrete events over all...
void setContactPlacements(const int contact_phase, const std::vector< Eigen::Vector3d > &contact_positions)
Sets the contact placements (positions and rotations) to contact statsus with specified contact phase...
int numImpactEvents() const
Returns number of impact events.
Definition: contact_sequence.hpp:214
int numDiscreteEvents() const
Returns number of discrete events, i.e., sum of numImpactEvents() and numLiftEvents().
Definition: contact_sequence.hpp:206
const std::deque< double > & eventTimes() const
Returns the event times of each event.
Definition: contact_sequence.hpp:285
void setLiftTime(const int lift_index, const double lift_time)
Sets the time of the lift event.
void pop_back()
Pop back the discrete event. Contact status after discrete event is also removed.
void pop_front()
Pop front the discrete event. Contact status before the front discrete event is also removed.
void reserve(const int reserved_num_discrete_events)
Reserves each discrete events (impact and lift) to avoid dynamic memory allocation.
const ContactStatus & contactStatus(const int contact_phase) const
Gets the contact status.
Definition: contact_sequence.hpp:231
bool isEventTimeConsistent() const
Checks wheather the event times are consistent.
double liftTime(const int lift_index) const
Returns lift event time.
Definition: contact_sequence.hpp:262
DiscreteEventType eventType(const int event_index) const
Returns the event type of the specified discrete event.
Definition: contact_sequence.hpp:274
void setFrictionCoefficients(const int contact_phase, const std::vector< double > &friction_coefficients)
Sets the friction coefficients. Also sets the friction coefficients of the discrete event just before...
int numLiftEvents() const
Returns number of lift events.
Definition: contact_sequence.hpp:222
ContactSequence(const ContactSequence &)=default
Default copy constructor.
ContactSequence & operator=(const ContactSequence &)=default
Default copy assign operator.
int reservedNumDiscreteEvents() const
Returns reserved size of container of each discrete events.
const ImpactStatus & impactStatus(const int impact_index) const
Gets the impact status.
Definition: contact_sequence.hpp:242
double impactTime(const int impact_index) const
Returns impact event time.
Definition: contact_sequence.hpp:252
void setImpactTime(const int impact_index, const double impact_time)
Sets the time of the impact event.
ContactSequence()
Default constructor.
bool isSTOEnabledImpact(const int impact_index) const
Checks wheather the STO is enabled for the specified impact event.
friend std::ostream & operator<<(std::ostream &os, const std::shared_ptr< ContactSequence > &contact_sequence)
void disp(std::ostream &os) const
Displays the contact sequence onto a ostream.
friend std::ostream & operator<<(std::ostream &os, const ContactSequence &contact_sequence)
bool isSTOEnabledLift(const int lift_index) const
Checks wheather the STO is enabled for the specified lift event.
void push_back(const DiscreteEvent &discrete_event, const double event_time, const bool sto=false)
Push back the discrete event. Contact status after discrete event is also appended according to discr...
ContactSequence(ContactSequence &&) noexcept=default
Default move constructor.
~ContactSequence()=default
Default destructor.
ContactSequence(const Robot &robot, const int reserved_num_discrete_events=0)
Constructor.
Contact status of robot model.
Definition: contact_status.hpp:32
Discrete event composed by impact and lift.
Definition: discrete_event.hpp:26
Impact status of robot model. Wrapper of ContactStatus to treat impacts.
Definition: impact_status.hpp:21
Dynamics and kinematics model of robots. Wraps pinocchio::Model and pinocchio::Data....
Definition: robot.hpp:32
Definition: constraint_component_base.hpp:17
DiscreteEventType
Type of the discrete events.
Definition: discrete_event.hpp:16
std::vector< T, Eigen::aligned_allocator< T > > aligned_vector
std vector with Eigen::aligned_allocator.
Definition: aligned_vector.hpp:14
pinocchio::SE3 SE3
Using pinocchio::SE3 without its namespace.
Definition: se3.hpp:15