-
Notifications
You must be signed in to change notification settings - Fork 480
/
Entity.cc
793 lines (680 loc) · 22.7 KB
/
Entity.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <boost/bind/bind.hpp>
#include <boost/function.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include "gazebo/msgs/msgs.hh"
#include "gazebo/common/Assert.hh"
#include "gazebo/common/Events.hh"
#include "gazebo/common/Console.hh"
#include "gazebo/common/Animation.hh"
#include "gazebo/common/KeyFrame.hh"
#include "gazebo/transport/Publisher.hh"
#include "gazebo/transport/TransportIface.hh"
#include "gazebo/transport/Node.hh"
#include "gazebo/physics/RayShape.hh"
#include "gazebo/physics/Collision.hh"
#include "gazebo/physics/Model.hh"
#include "gazebo/physics/Light.hh"
#include "gazebo/physics/Link.hh"
#include "gazebo/physics/World.hh"
#include "gazebo/physics/PhysicsEngine.hh"
#include "gazebo/physics/Entity.hh"
using namespace gazebo;
using namespace physics;
//////////////////////////////////////////////////
Entity::Entity(BasePtr _parent)
: Base(_parent)
{
this->isStatic = false;
this->isCanonicalLink = false;
this->node = transport::NodePtr(new transport::Node());
this->AddType(ENTITY);
this->visualMsg = new msgs::Visual;
this->visualMsg->set_id(this->id);
if (this->world)
this->visualMsg->set_parent_name(this->world->Name());
else
{
gzerr << "No world set when constructing an Entity.\n";
this->visualMsg->set_parent_name("no_world_name");
}
if (this->parent && this->parent->HasType(ENTITY))
{
this->parentEntity = boost::dynamic_pointer_cast<Entity>(this->parent);
this->visualMsg->set_parent_name(this->parentEntity->GetScopedName());
this->SetStatic(this->parentEntity->IsStatic());
}
this->setWorldPoseFunc = &Entity::SetWorldPoseDefault;
this->scale = ignition::math::Vector3d::One;
}
//////////////////////////////////////////////////
Entity::~Entity()
{
this->Fini();
}
//////////////////////////////////////////////////
void Entity::Load(sdf::ElementPtr _sdf)
{
Base::Load(_sdf);
this->node->Init(this->GetWorld()->Name());
this->poseSub = this->node->Subscribe("~/pose/modify",
&Entity::OnPoseMsg, this);
this->visPub = this->node->Advertise<msgs::Visual>("~/visual", 200);
this->requestPub = this->node->Advertise<msgs::Request>("~/request");
this->visualMsg->set_name(this->GetScopedName());
{
if (this->parent && this->parentEntity)
{
this->worldPose =
this->parentEntity->worldPose * this->SDFPoseRelativeToParent();
}
else
{
this->worldPose = this->SDFPoseRelativeToParent();
}
this->initialRelativePose = this->SDFPoseRelativeToParent();
}
if (this->parent)
{
this->visualMsg->set_parent_name(this->parent->GetScopedName());
this->visualMsg->set_parent_id(this->parent->GetId());
}
else
{
this->visualMsg->set_parent_name(this->world->Name());
this->visualMsg->set_parent_id(0);
}
msgs::Set(this->visualMsg->mutable_pose(), this->RelativePose());
if (this->HasType(Base::MODEL))
this->visualMsg->set_type(msgs::Visual::MODEL);
if (this->HasType(Base::LINK))
this->visualMsg->set_type(msgs::Visual::LINK);
if (this->HasType(Base::COLLISION))
this->visualMsg->set_type(msgs::Visual::COLLISION);
this->visPub->Publish(*this->visualMsg);
if (this->HasType(Base::MODEL))
this->setWorldPoseFunc = &Entity::SetWorldPoseModel;
else if (this->IsCanonicalLink())
this->setWorldPoseFunc = &Entity::SetWorldPoseCanonicalLink;
else
this->setWorldPoseFunc = &Entity::SetWorldPoseDefault;
}
//////////////////////////////////////////////////
void Entity::SetName(const std::string &_name)
{
// TODO: if an entitie's _name is changed, then the old visual is never
// removed. Should add in functionality to modify/update the visual
Base::SetName(_name);
}
//////////////////////////////////////////////////
void Entity::SetStatic(const bool &_s)
{
Base_V::iterator iter;
this->isStatic = _s;
for (iter = this->children.begin(); iter != this->children.end(); ++iter)
{
EntityPtr e = boost::dynamic_pointer_cast<Entity>(*iter);
if (e)
e->SetStatic(_s);
}
}
//////////////////////////////////////////////////
bool Entity::IsStatic() const
{
return this->isStatic;
}
//////////////////////////////////////////////////
void Entity::SetInitialRelativePose(const ignition::math::Pose3d &_p)
{
this->initialRelativePose = _p;
}
//////////////////////////////////////////////////
ignition::math::Pose3d Entity::InitialRelativePose() const
{
return this->initialRelativePose;
}
//////////////////////////////////////////////////
ignition::math::AxisAlignedBox Entity::BoundingBox() const
{
return ignition::math::AxisAlignedBox(
ignition::math::Vector3d::Zero, ignition::math::Vector3d::One);
}
//////////////////////////////////////////////////
void Entity::SetCanonicalLink(bool _value)
{
this->isCanonicalLink = _value;
}
//////////////////////////////////////////////////
void Entity::SetAnimation(common::PoseAnimationPtr _anim)
{
this->animationStartPose = this->worldPose;
this->prevAnimationTime = this->world->SimTime();
this->animation = _anim;
this->onAnimationComplete.clear();
using namespace boost::placeholders;
this->animationConnection = event::Events::ConnectWorldUpdateBegin(
boost::bind(&Entity::UpdateAnimation, this, _1));
}
//////////////////////////////////////////////////
void Entity::SetAnimation(const common::PoseAnimationPtr &_anim,
boost::function<void()> _onComplete)
{
this->animationStartPose = this->worldPose;
this->prevAnimationTime = this->world->SimTime();
this->animation = _anim;
this->onAnimationComplete = _onComplete;
using namespace boost::placeholders;
this->animationConnection = event::Events::ConnectWorldUpdateBegin(
boost::bind(&Entity::UpdateAnimation, this, _1));
}
//////////////////////////////////////////////////
void Entity::StopAnimation()
{
this->animation.reset();
this->onAnimationComplete.clear();
this->animationConnection.reset();
}
//////////////////////////////////////////////////
void Entity::PublishPose()
{
GZ_ASSERT(this->GetParentModel() != NULL,
"An entity without a parent model should not happen");
this->world->PublishModelPose(this->GetParentModel());
}
//////////////////////////////////////////////////
ignition::math::Pose3d Entity::RelativePose() const
{
// We return the initialRelativePose for COLLISION objects because they
// cannot move relative to their parent link.
// \todo Look into storing relative poses for all objects instead of world
// poses. It may simplify pose updating.
if (this->IsCanonicalLink() || this->HasType(COLLISION))
{
return this->initialRelativePose;
}
else if (this->parent && this->parentEntity)
{
return this->WorldPose() - this->parentEntity->WorldPose();
}
else
{
return this->WorldPose();
}
}
//////////////////////////////////////////////////
void Entity::SetRelativePose(const ignition::math::Pose3d &_pose,
const bool _notify, const bool _publish)
{
if (this->parent && this->parentEntity)
this->SetWorldPose(_pose + this->parentEntity->WorldPose(), _notify,
_publish);
else
this->SetWorldPose(_pose, _notify, _publish);
}
//////////////////////////////////////////////////
void Entity::SetWorldTwist(const ignition::math::Vector3d &_linear,
const ignition::math::Vector3d &_angular, const bool _updateChildren)
{
if (this->HasType(LINK) || this->HasType(MODEL))
{
if (this->HasType(LINK))
{
Link* link = dynamic_cast<Link*>(this);
link->SetLinearVel(_linear);
link->SetAngularVel(_angular);
}
if (_updateChildren)
{
// force an update of all children
for (Base_V::iterator iter = this->children.begin();
iter != this->children.end(); ++iter)
{
if ((*iter)->HasType(ENTITY))
{
EntityPtr entity = boost::static_pointer_cast<Entity>(*iter);
entity->SetWorldTwist(_linear, _angular, _updateChildren);
}
}
}
}
}
//////////////////////////////////////////////////
void Entity::SetWorldPoseModel(
const ignition::math::Pose3d &_pose,
const bool _notify, const bool _publish)
{
ignition::math::Pose3d oldModelWorldPose = this->worldPose;
// initialization: (no children?) set own worldPose
this->worldPose = _pose;
this->worldPose.Correct();
// (OnPoseChange uses GetWorldPose)
if (_notify)
this->UpdatePhysicsPose(false);
//
// user deliberate setting: lock and update all children's wp
//
// force an update of all children
// update all children pose, moving them with the model.
// The outer loop updates all the links.
for (Base_V::iterator iter = this->children.begin();
iter != this->children.end(); ++iter)
{
if ((*iter)->HasType(ENTITY))
{
EntityPtr entity = boost::static_pointer_cast<Entity>(*iter);
if (entity->HasType(LINK))
{
if (entity->IsCanonicalLink())
entity->worldPose = (entity->initialRelativePose + _pose);
else
{
entity->worldPose = ((entity->worldPose - oldModelWorldPose) + _pose);
// Publish only for non-canonical links,
// since local pose of the canonical link does not change,
// so there is no need to keep telling everyone about it.
// The canonical link will automatically move as the model moves
if (_publish)
entity->PublishPose();
}
if (_notify)
entity->UpdatePhysicsPose(false);
// Tell collisions that their current world pose is dirty (needs
// updating). We set a dirty flag instead of directly updating the
// value to improve performance.
for (Base_V::iterator iterC = (*iter)->children.begin();
iterC != (*iter)->children.end(); ++iterC)
{
if ((*iterC)->HasType(COLLISION))
{
CollisionPtr entityC =
boost::static_pointer_cast<Collision>(*iterC);
entityC->SetWorldPoseDirty();
}
else if ((*iterC)->HasType(LIGHT))
{
LightPtr entityC =
boost::static_pointer_cast<Light>(*iterC);
entityC->SetWorldPoseDirty();
}
}
}
else if (entity->HasType(MODEL))
{
// set pose of nested models
entity->SetWorldPoseModel(
(entity->worldPose - oldModelWorldPose) + _pose, _notify, _publish);
}
else
{
gzerr << "SetWorldPoseModel error: unknown type of entity in Model."
<< std::endl;
}
}
}
}
//////////////////////////////////////////////////
void Entity::SetWorldPoseCanonicalLink(
const ignition::math::Pose3d &_pose,
const bool _notify, const bool _publish)
{
this->SetWorldPoseDefault(_pose, _notify, _publish);
if (!this->parentEntity->HasType(MODEL))
{
gzerr << "SetWorldPose for Canonical Body [" << this->GetName()
<< "] but parent[" << this->parentEntity->GetName()
<< "] is not a MODEL!" << std::endl;
return;
}
EntityPtr parentEnt = this->parentEntity;
ignition::math::Pose3d relativePose = this->initialRelativePose;
ignition::math::Pose3d updatePose = _pose;
// recursively update parent model pose based on new canonical link pose
while (parentEnt && parentEnt->HasType(MODEL))
{
// setting parent Model world pose from canonical link world pose
// where _pose is the canonical link's world pose
parentEnt->worldPose = ignition::math::Pose3d(-relativePose) + updatePose;
parentEnt->worldPose.Correct();
if (_notify)
parentEnt->UpdatePhysicsPose(false);
if (_publish)
this->parentEntity->PublishPose();
updatePose = parentEnt->worldPose;
relativePose = parentEnt->InitialRelativePose();
parentEnt = boost::dynamic_pointer_cast<Entity>(parentEnt->GetParent());
}
}
//////////////////////////////////////////////////
void Entity::SetWorldPoseDefault(const ignition::math::Pose3d &_pose,
const bool _notify, const bool /*_publish*/)
{
this->worldPose = _pose;
this->worldPose.Correct();
if (_notify)
this->UpdatePhysicsPose(true);
if (this->HasType(LINK))
{
// Tell collisions that their current world pose is dirty (needs
// updating). We set a dirty flag instead of directly updating the
// value to improve performance.
for (auto &childPtr : this->children)
{
if (childPtr->HasType(COLLISION))
{
CollisionPtr entityC = boost::static_pointer_cast<Collision>(childPtr);
entityC->SetWorldPoseDirty();
}
else if (childPtr->HasType(LIGHT))
{
LightPtr entityC = boost::static_pointer_cast<Light>(childPtr);
entityC->SetWorldPoseDirty();
}
}
}
}
//////////////////////////////////////////////////
// The entity stores an initialRelativePose and dynamic worldPose
// When calling SetWorldPose (SWP) or SetRelativePose on an entity
// that is a Model (M), Canonical Body (CB) or Body (B), different
// considerations need to be taken.
// Below is a table that summarizes the current code.
// +----------------------------------------------------------+
// | | M | CB | B |
// |----------------------------------------------------------|
// |SWP | Lock | Lock | Set BWP |
// | | Update MWP | Set CBWP | |
// | | SWP Children | SWP M = CB-CBRP | |
// |----------------------------------------------------------|
// |SRP | WP = RP + PP | WP = RP + PP | WP = RP + PP |
// |----------------------------------------------------------|
// |GWP | return WP | return WP | return WP |
// |----------------------------------------------------------|
// |GRP | RP = WP - RP | return CBRP | RP = WP - RP |
// +----------------------------------------------------------+
// Legends
// M - Model
// CB - Canonical Body
// B - Non-Canonical Body
// *WP - *WorldPose
// *RP - *RelativePose (relative to parent)
// SWP - SetWorldPose
// GWP - GetWorldPose
// MWP - Model World Pose
// CBRP - Canonical Body Relative (to Model) Pose
//
void Entity::SetWorldPose(const ignition::math::Pose3d &_pose,
const bool _notify, const bool _publish)
{
{
std::lock_guard<std::mutex> lock(this->GetWorld()->WorldPoseMutex());
(*this.*setWorldPoseFunc)(_pose, _notify, _publish);
}
if (_publish)
this->PublishPose();
}
//////////////////////////////////////////////////
void Entity::UpdatePhysicsPose(bool _updateChildren)
{
this->OnPoseChange();
/// if children update is requested
if (_updateChildren)
{
for (Base_V::iterator iter = this->children.begin();
iter != this->children.end(); ++iter)
{
if ((*iter)->HasType(LINK))
{
// call child Link::OnPoseChange()
boost::static_pointer_cast<Link>(*iter)->OnPoseChange();
}
}
}
/// Static Collision objects have no corresponding ODE body
/// So if one calls MyStaticModel.SetWorldPose(p),
/// we should force children update
if (this->IsStatic())
{
for (Base_V::iterator iter = this->children.begin();
iter != this->children.end(); ++iter)
{
CollisionPtr coll = boost::static_pointer_cast<Collision>(*iter);
if (coll && (*iter)->HasType(COLLISION))
{
// update collision pose
// to model's world pose + it's intial relative pose
coll->worldPose.Pos() = this->worldPose.Pos() +
this->worldPose.Rot().RotateVector(coll->initialRelativePose.Pos());
coll->worldPose.Rot() = this->worldPose.Rot() *
coll->initialRelativePose.Rot();
coll->OnPoseChange();
}
else
{
// not static or not a Collision type, do nothing
}
}
}
}
//////////////////////////////////////////////////
ModelPtr Entity::GetParentModel()
{
BasePtr p;
if (this->HasType(MODEL))
return boost::dynamic_pointer_cast<Model>(shared_from_this());
p = this->parent;
GZ_ASSERT(p, "Parent of an entity is NULL");
while (p->GetParent() && p->GetParent()->HasType(MODEL))
p = p->GetParent();
return boost::dynamic_pointer_cast<Model>(p);
}
//////////////////////////////////////////////////
CollisionPtr Entity::GetChildCollision(const std::string &_name)
{
BasePtr base = this->GetByName(_name);
if (base)
return boost::dynamic_pointer_cast<Collision>(base);
return CollisionPtr();
}
//////////////////////////////////////////////////
LinkPtr Entity::GetChildLink(const std::string &_name)
{
BasePtr base = this->GetByName(_name);
if (base)
return boost::dynamic_pointer_cast<Link>(base);
return LinkPtr();
}
//////////////////////////////////////////////////
void Entity::OnPoseMsg(ConstPosePtr &_msg)
{
if (_msg->name() == this->GetScopedName())
{
ignition::math::Pose3d p = msgs::ConvertIgn(*_msg);
this->SetWorldPose(p);
}
}
//////////////////////////////////////////////////
void Entity::Fini()
{
// TODO: put this back in
// this->GetWorld()-Physics()->RemoveEntity(this);
if (this->requestPub)
{
auto msg = msgs::CreateRequest("entity_delete", this->GetScopedName());
this->requestPub->Publish(*msg, true);
delete msg;
}
// Clean transport
{
this->posePub.reset();
this->requestPub.reset();
this->visPub.reset();
this->poseSub.reset();
if (this->node)
this->node->Fini();
this->node.reset();
}
this->animationConnection.reset();
this->connections.clear();
if (this->visualMsg)
delete this->visualMsg;
this->visualMsg = NULL;
this->parentEntity.reset();
Base::Fini();
}
//////////////////////////////////////////////////
void Entity::Reset()
{
this->SetRelativePose(this->initialRelativePose);
}
//////////////////////////////////////////////////
void Entity::UpdateParameters(sdf::ElementPtr _sdf)
{
Base::UpdateParameters(_sdf);
ignition::math::Pose3d parentPose;
if (this->parent && this->parentEntity)
parentPose = this->parentEntity->worldPose;
// TODO(addisu) Check if this needs semantic pose
ignition::math::Pose3d newPose = _sdf->Get<ignition::math::Pose3d>("pose");
if (newPose != this->RelativePose())
{
this->SetRelativePose(newPose);
}
}
//////////////////////////////////////////////////
void Entity::UpdateAnimation(const common::UpdateInfo &_info)
{
common::PoseKeyFrame kf(0);
this->animation->AddTime((_info.simTime - this->prevAnimationTime).Double());
this->animation->GetInterpolatedKeyFrame(kf);
ignition::math::Pose3d offset;
offset.Pos() = kf.Translation();
offset.Rot() = kf.Rotation();
this->SetWorldPose(offset);
this->prevAnimationTime = _info.simTime;
if (this->animation->GetLength() <= this->animation->GetTime())
{
this->animationConnection.reset();
if (this->onAnimationComplete)
{
this->onAnimationComplete();
}
}
}
//////////////////////////////////////////////////
const ignition::math::Pose3d &Entity::DirtyPose() const
{
return this->dirtyPose;
}
//////////////////////////////////////////////////
ignition::math::AxisAlignedBox Entity::CollisionBoundingBox() const
{
BasePtr base = boost::const_pointer_cast<Base>(shared_from_this());
return this->CollisionBoundingBoxHelper(base);
}
//////////////////////////////////////////////////
ignition::math::AxisAlignedBox Entity::CollisionBoundingBoxHelper(
BasePtr _base) const
{
if (_base->HasType(COLLISION))
return boost::dynamic_pointer_cast<Collision>(_base)->BoundingBox();
ignition::math::AxisAlignedBox box;
for (unsigned int i = 0; i < _base->GetChildCount(); i++)
{
box += this->CollisionBoundingBoxHelper(_base->GetChild(i));
}
return box;
}
//////////////////////////////////////////////////
void Entity::PlaceOnEntity(const std::string &_entityName)
{
EntityPtr onEntity = this->GetWorld()->EntityByName(_entityName);
ignition::math::AxisAlignedBox box = this->CollisionBoundingBox();
ignition::math::AxisAlignedBox onBox = onEntity->CollisionBoundingBox();
ignition::math::Pose3d p = onEntity->WorldPose();
p.Pos().Z() = onBox.Max().Z() + box.ZLength()*0.5;
this->SetWorldPose(p);
}
//////////////////////////////////////////////////
void Entity::GetNearestEntityBelow(double &_distBelow,
std::string &_entityName)
{
this->GetWorld()->Physics()->InitForThread();
RayShapePtr rayShape = boost::dynamic_pointer_cast<RayShape>(
this->GetWorld()->Physics()->CreateShape("ray", CollisionPtr()));
ignition::math::AxisAlignedBox box = this->CollisionBoundingBox();
ignition::math::Vector3d start = this->WorldPose().Pos();
ignition::math::Vector3d end = start;
start.Z() = box.Min().Z() - 0.00001;
end.Z() -= 1000;
rayShape->SetPoints(start, end);
rayShape->GetIntersection(_distBelow, _entityName);
_distBelow += 0.00001;
}
//////////////////////////////////////////////////
void Entity::PlaceOnNearestEntityBelow()
{
double dist;
std::string entityName;
this->GetNearestEntityBelow(dist, entityName);
if (dist > 0.0)
{
ignition::math::Pose3d p = this->WorldPose();
p.Pos().Z() -= dist;
this->SetWorldPose(p);
}
}
//////////////////////////////////////////////////
ignition::math::Vector3d Entity::RelativeLinearVel() const
{
return ignition::math::Vector3d::Zero;
}
//////////////////////////////////////////////////
ignition::math::Vector3d Entity::WorldLinearVel() const
{
return ignition::math::Vector3d::Zero;
}
//////////////////////////////////////////////////
ignition::math::Vector3d Entity::RelativeAngularVel() const
{
return ignition::math::Vector3d::Zero;
}
//////////////////////////////////////////////////
ignition::math::Vector3d Entity::WorldAngularVel() const
{
return ignition::math::Vector3d::Zero;
}
//////////////////////////////////////////////////
ignition::math::Vector3d Entity::RelativeLinearAccel() const
{
return ignition::math::Vector3d::Zero;
}
//////////////////////////////////////////////////
ignition::math::Vector3d Entity::WorldLinearAccel() const
{
return ignition::math::Vector3d::Zero;
}
//////////////////////////////////////////////////
ignition::math::Vector3d Entity::RelativeAngularAccel() const
{
return ignition::math::Vector3d::Zero;
}
//////////////////////////////////////////////////
ignition::math::Vector3d Entity::WorldAngularAccel() const
{
return ignition::math::Vector3d::Zero;
}