Drake Designer
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
ddDrakeModel.h
Go to the documentation of this file.
1 #ifndef __ddDrakeModel_h
2 #define __ddDrakeModel_h
3 
4 #include <QObject>
5 #include <QColor>
6 #include <QVector>
7 #include "ddSharedPtr.h"
8 #include "ddAppConfigure.h"
9 #include "ddDrakeVersion.h"
10 #ifdef DRAKE_OH_FORK
11 #include <drake/systems/plants/RigidBodyTree.h>
12 #else
13 #include <drake/multibody/rigid_body_tree.h>
14 #endif
15 
16 class vtkRenderer;
17 class vtkTransform;
18 class vtkPolyData;
19 
20 #ifdef DRAKE_OH_FORK
21 #define RigidBodyTreed RigidBodyTree
22 #endif
23 
24 class DD_APP_EXPORT ddDrakeModel : public QObject
25 {
26  Q_OBJECT
27 
28 public:
29 
30  ddDrakeModel(QObject* parent=0);
31  virtual ~ddDrakeModel();
32 
33  bool loadFromFile(const QString& filename, const QString& floatingBaseType = "ROLLPITCHYAW");
34  bool loadFromXML(const QString& xmlString);
35  const QString& filename() const;
36 
37  const ddSharedPtr<RigidBodyTreed> getDrakeRBM() const;
38  const ddSharedPtr<KinematicsCache<double> > getKinematicsCache() const;
39 
40  void addToRenderer(vtkRenderer* renderer);
41  void removeFromRenderer(vtkRenderer* renderer);
42 
43  int numberOfJoints();
44  void setJointPositions(const QVector<double>& positions, const QList<QString>& jointNames);
45  void setJointPositions(const QVector<double>& positions);
46  QVector<double> getJointPositions(const QList<QString>& jointNames) const;
47  const QVector<double>& getJointPositions() const;
48  QVector<double> getCenterOfMass() const;
49  QVector<double> getJointLimits(const QString& jointName) const;
50  QVector<double> getBodyContactPoints(const QString& bodyName) const;
51  QVector<double> geometricJacobian(int base_body_or_frame_ind, int end_effector_body_or_frame_ind, int expressed_in_body_or_frame_ind, int gradient_order, bool in_terms_of_qdot = false);
52  bool getLinkToWorld(const QString& linkName, vtkTransform* transform);
53  bool getFrameToWorld(int frameId, vtkTransform* transform);
54  QList<QString> getLinkNames();
55  QList<QString> getJointNames();
56  int findLinkID(const QString& linkName) const;
57  int findJointID(const QString& jointName) const;
58  int findFrameID(const QString& frameName) const;
59  QString findNameOfChildBodyOfJoint(const QString& jointName) const;
60 
61  void getModelMesh(vtkPolyData* polyData);
62  void getModelMeshWithLinkInfoAndNormals(vtkPolyData* polyData);
63  void getLinkModelMesh(const QString& linkName, vtkPolyData* polyData);
64  QString getLinkNameForMesh(vtkPolyData* polyData);
65  QString getBodyOrFrameName(int body_or_frame_id);
66 
67  void setAlpha(double alpha);
68  double alpha() const;
69 
70  void setUrdfColors();
71 
72  void setTexturesEnabled(bool enabled);
73  bool texturesEnabled() const;
74 
75  void setVisible(bool visible);
76  bool visible() const;
77 
78  QColor color() const;
79  void setColor(const QColor& color);
80 
81  void setLinkColor(const QString& linkName, const QColor& color);
82  QColor getLinkColor(const QString& linkName) const;
83 
84  static void addPackageSearchPath(const QString& searchPath);
85  static QString findPackageDirectory(const QString& packageName);
86 
87 signals:
88 
89  void modelChanged();
90  void displayChanged();
91 
92 protected:
93 
94  class ddInternal;
95  ddInternal* Internal;
96 
97  Q_DISABLE_COPY(ddDrakeModel);
98 };
99 
100 #endif
ddInternal * Internal
Definition: ddDrakeModel.h:94
#define DD_APP_EXPORT