mbsim 4.0.0 MBSim Kernel

inverse_kinematics_constraint_observer.h
1 /* Copyright (C) 2004-2019 MBSim Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 *
17 * Contact: martin.o.foerg@gmail.com
18 */
19
20 #ifndef _INVERSE_KINEMATICS_CONSTRAINT_OBSERVER_H__
21 #define _INVERSE_KINEMATICS_CONSTRAINT_OBSERVER_H__
22
23 #include "mbsim/observers/observer.h"
24
25 #include <mbsim/utils/boost_parameters.h>
26 #include <mbsim/utils/openmbv_utils.h>
27
28 namespace MBSim {
29
30 class InverseKinematicsConstraint;
31
32 class InverseKinematicsConstraintObserver : public Observer {
33 protected:
34 InverseKinematicsConstraint* constraint;
35 std::string saved_constraint;
36 std::shared_ptr<OpenMBVArrow> ombv;
37 std::vector<std::shared_ptr<OpenMBV::Arrow>> openMBVForce, openMBVMoment;
38 #ifndef SWIG
39 double (InverseKinematicsConstraintObserver::*evalOMBVForceColorRepresentation[2])(int i);
40 double (InverseKinematicsConstraintObserver::*evalOMBVMomentColorRepresentation[2])(int i);
41 #endif
42 double evalNone(int i) { return 1; }
43 double evalAbsoluteForce(int i);
44 double evalAbsoluteMoment(int i);
45
46 public:
47 InverseKinematicsConstraintObserver(const std::string &name="");
48 void setInverseKinematicsConstraint(InverseKinematicsConstraint *constraint_) { constraint = constraint_; }
49 void setOutputFrame(Frame *outputFrame_) { outputFrame = outputFrame_; }
50
51 void init(InitStage stage, const InitConfigSet &config) override;
52 void plot() override;
53 void initializeUsingXML(xercesc::DOMElement *element) override;
54
55 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBVArrow::ReferencePoint),OpenMBVArrow::toPoint)(colorRepresentation,(OpenMBVArrow::ColorRepresentation),OpenMBVArrow::none)(minimalColorValue,(double),0)(maximalColorValue,(double),1)(diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
56 ombv = std::shared_ptr<OpenMBVArrow>(new OpenMBVArrow(scaleLength,scaleSize,OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
57 }
58 private:
59 Frame *outputFrame { nullptr };
60 std::string saved_outputFrame;
61 };
62
63 }
64
65 #endif
MBSim::OpenMBVArrow
Definition: openmbv_utils.h:79
MBSim::Element::InitStage
InitStage
The stages of the initialization.
Definition: element.h:62
MBSim::InverseKinematicsConstraintObserver::plot
void plot() override
plots time dependent data
Definition: inverse_kinematics_constraint_observer.cc:95
MBSim::InverseKinematicsConstraintObserver::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: inverse_kinematics_constraint_observer.cc:45
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::Frame
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
MBSim::InverseKinematicsConstraintObserver
Definition: inverse_kinematics_constraint_observer.h:32
MBSim::InverseKinematicsConstraint
Inverse kinematics contraint.
Definition: inverse_kinematics_constraint.h:36
MBSim::Observer
Definition: observer.h:26
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30