ocra-recipes
Doxygen documentation for the ocra-recipes repository
ContactSet.cpp
Go to the documentation of this file.
2 
3 
4 
5 namespace ocra
6 {
7  ContactSet::ContactSet(const std::string& name, const Controller& factory, SegmentFrame::Ptr body, double mu, double margin)
8  : NamedInstance(name)
9  , _factory(factory)
10  , _body(body)
11  , _bodyFeature(std::make_shared<ContactConstraintFeature>(body->getName()+".feature", body))
12  , _bodyTask(factory.createTask(body->getName()+".task", _bodyFeature))
13  , _points()
14  , _mu(mu)
15  , _margin(margin)
16  , _nFacets(4)
17  {
18  _bodyTask->activateContactMode();
19  }
20 
22  {
23  }
24 
25  void ContactSet::addContactFrame(const Eigen::Displacementd& frame)
26  {
27  std::stringstream ss;
28  ss << getName() << "." << _points.size();
29 
30  SegmentFrame::Ptr sf = std::make_shared<SegmentFrame>(ss.str(), _body->getModel(), _body->getSegmentIndex(), frame);
31  _points.push_back(sf);
32 
33  PointContactFeature::Ptr pf = std::make_shared<PointContactFeature>(sf->getName()+".feature", sf);
34  _features.push_back(pf);
35 
36  std::shared_ptr<Task> task = _factory.createContactTask(sf->getName()+".task", pf, _mu, _margin);
37  _tasks.push_back(task);
38  }
39 
40  SegmentFrame::Ptr ContactSet::getBodyFrame() const
41  {
42  return _body;
43  }
44 
46  {
47  return *_bodyFeature;
48  }
49 
50  std::shared_ptr<Task> ContactSet::getBodyTask() const
51  {
52  return _bodyTask;
53  }
54 
55  const std::vector<SegmentFrame::Ptr>& ContactSet::getPoints() const
56  {
57  return _points;
58  }
59 
60  const std::vector<PointContactFeature::Ptr>& ContactSet::getFeatures() const
61  {
62  return _features;
63  }
64 
65  const std::vector<std::shared_ptr<Task>>& ContactSet::getTasks() const
66  {
67  return _tasks;
68  }
69 
70  void ContactSet::setMu(double mu)
71  {
72  _mu = mu;
73  }
74 
75  double ContactSet::getMu() const
76  {
77  return _mu;
78  }
79 
80  void ContactSet::setMargin(double margin)
81  {
82  _margin = margin;
83  }
84 
85  double ContactSet::getMargin() const
86  {
87  return _margin;
88  }
89 
90  void ContactSet::setNFacets(int nFacets)
91  {
92  _nFacets = nFacets;
93  }
94 
96  {
97  return _nFacets;
98  }
99 }
100 
101 // cmake:sourcegroup=Api
double getMu() const
Definition: ContactSet.cpp:75
Factory classes and functions to build sets of contact frames.
void addContactFrame(const Eigen::Displacementd &frame)
Definition: ContactSet.cpp:25
ContactSet(const std::string &name, const Controller &factory, SegmentFrame::Ptr body, double mu, double margin)
Definition: ContactSet.cpp:7
SegmentFrame::Ptr getBodyFrame() const
Definition: ContactSet.cpp:40
std::shared_ptr< Task > getBodyTask() const
Definition: ContactSet.cpp:50
const std::string & getName() const
const std::vector< SegmentFrame::Ptr > & getPoints() const
Definition: ContactSet.cpp:55
void setMargin(double margin)
Definition: ContactSet.cpp:80
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
Interface for controllers.
Definition: Controller.h:53
virtual ~ContactSet()
Definition: ContactSet.cpp:21
std::shared_ptr< Task > createContactTask(const std::string &name, PointContactFeature::Ptr feature, double mu, double margin) const
Creates a contact task.
Definition: Controller.cpp:378
void setNFacets(int nFacets)
Definition: ContactSet.cpp:90
const std::vector< std::shared_ptr< Task > > & getTasks() const
Definition: ContactSet.cpp:65
Used to build contact constraint tasks (null acceleration).
Definition: Feature.h:279
const std::vector< PointContactFeature::Ptr > & getFeatures() const
Definition: ContactSet.cpp:60
void setMu(double mu)
Definition: ContactSet.cpp:70
int getNFacets() const
Definition: ContactSet.cpp:95
double getMargin() const
Definition: ContactSet.cpp:85
ContactConstraintFeature & getBodyFeature() const
Definition: ContactSet.cpp:45