SimObject.cpp
Go to the documentation of this file.
1#ifdef MUJOCO_PHYSICS_WORLD
2#include "SimObject.h"
3
4#include <VirtualRobot/math/Helpers.h>
5
7
8#include <MujocoX/libraries/Simulation/Data.h>
9
10
11using namespace mujoco;
12
14{
15}
16
17SimObject::SimObject(const std::string& name) : body(name), geom(name)
18{
19}
20
21SimObject::SimObject(VirtualRobot::SceneObjectPtr sceneObject) :
22 body(sceneObject->getName()), geom(sceneObject->getName()), sceneObject(sceneObject)
23{
24}
25
26void
27SimObject::update(Model& model)
28{
29 body.update(model);
30 geom.update(model);
31}
32
33void
34SimObject::updateSceneObjectPose(const Data& data, float lengthScaling)
35{
36 ARMARX_CHECK(sceneObject);
37 Eigen::Matrix4f pose = data.getBodyPose(body);
38 math::Helpers::Position(pose) *= lengthScaling;
39 sceneObject->setGlobalPose(pose);
40}
41
42const std::string&
43SimObject::name() const
44{
45 return body.name();
46}
47
48
49#endif
uint8_t data[1]
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
const std::string & name() const
void updateSceneObjectPose(const Data &data, float lengthScaling=1.)
void update(mujoco::Model &model)