37 #include <gtest/gtest.h> 40 #include <boost/bind.hpp> 42 TEST(World, AddRemoveShape)
56 world.
addToObject(
"ball", ball, Eigen::Affine3d::Identity());
61 bool move_ok = world.
moveShapeInObject(
"ball", ball, Eigen::Affine3d(Eigen::Translation3d(0, 0, 9)));
84 world.
addToObject(
"ball", ball, Eigen::Affine3d::Identity());
92 std::vector<shapes::ShapeConstPtr>
shapes;
95 shapes.push_back(box);
96 shapes.push_back(cyl);
97 shapes.push_back(ball);
99 poses.push_back(Eigen::Affine3d(Eigen::Translation3d(0, 0, 1)));
100 poses.push_back(Eigen::Affine3d(Eigen::Translation3d(0, 0, 2)));
101 poses.push_back(Eigen::Affine3d(Eigen::Translation3d(0, 0, 3)));
116 world.
addToObject(
"ball2", ball, Eigen::Affine3d(Eigen::Translation3d(0, 0, 4)));
141 collision_detection::World::ObjectConstPtr obj = world.
getObject(
"mix1");
144 ASSERT_EQ(2, obj->shapes_.size());
145 ASSERT_EQ(2, obj->shape_poses_.size());
148 EXPECT_EQ(1.0, obj->shape_poses_[0](2, 3));
149 EXPECT_EQ(3.0, obj->shape_poses_[1](2, 3));
151 move_ok = world.
moveShapeInObject(
"mix1", ball, Eigen::Affine3d(Eigen::Translation3d(0, 0, 5)));
154 collision_detection::World::ObjectConstPtr obj2 = world.
getObject(
"mix1");
155 EXPECT_EQ(2, obj2.use_count());
156 EXPECT_EQ(1, obj.use_count());
158 EXPECT_EQ(1.0, obj2->shape_poses_[0](2, 3));
159 EXPECT_EQ(5.0, obj2->shape_poses_[1](2, 3));
161 EXPECT_EQ(1.0, obj->shape_poses_[0](2, 3));
162 EXPECT_EQ(3.0, obj->shape_poses_[1](2, 3));
165 EXPECT_EQ(3, box.use_count());
166 EXPECT_EQ(1, cyl.use_count());
167 EXPECT_EQ(5, ball.use_count());
171 EXPECT_EQ(2, world.
size());
174 EXPECT_EQ(3, box.use_count());
175 EXPECT_EQ(1, cyl.use_count());
176 EXPECT_EQ(5, ball.use_count());
182 collision_detection::World::ObjectConstPtr obj3 = world.
getObject(
"abc");
246 world.
addToObject(
"obj1", ball, Eigen::Affine3d::Identity());
253 bool move_ok = world.
moveShapeInObject(
"obj1", ball, Eigen::Affine3d(Eigen::Translation3d(0, 0, 1)));
261 world.
addToObject(
"obj1", box, Eigen::Affine3d::Identity());
272 world.
addToObject(
"obj2", cyl, Eigen::Affine3d::Identity());
283 world.
addToObject(
"obj3", box, Eigen::Affine3d::Identity());
361 world.
addToObject(
"obj4", box, Eigen::Affine3d::Identity());
368 int main(
int argc,
char** argv)
370 testing::InitGoogleTest(&argc, argv);
371 return RUN_ALL_TESTS();
bool removeObject(const std::string &id)
Remove a particular object. If there are no external pointers to the corresponding instance of Object...
std::vector< Eigen::Affine3d, Eigen::aligned_allocator< Eigen::Affine3d > > vector_Affine3d
void clearObjects()
Clear all objects. If there are no other pointers to corresponding instances of Objects, the memory is freed.
std::vector< shapes::ShapeConstPtr > shapes_
All the shapes making up this object.
ObserverHandle addObserver(const ObserverCallbackFn &callback)
register a callback function for notification of changes. callback will be called right after any cha...
Maintain a representation of the environment.
Represents an action that occurred on an object in the world. Several bits may be set indicating seve...
void addToObject(const std::string &id, const std::vector< shapes::ShapeConstPtr > &shapes, const EigenSTL::vector_Affine3d &poses)
Add shapes to an object in the map. This function makes repeated calls to addToObjectInternal() to ad...
std::shared_ptr< Shape > ShapePtr
bool hasObject(const std::string &id) const
Check if a particular object exists in the collision world.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW std::string id_
The id for this object.
#define EXPECT_FALSE(args)
A representation of an object.
TEST(World, AddRemoveShape)
void removeObserver(const ObserverHandle observer_handle)
remove a notifier callback
bool removeShapeFromObject(const std::string &id, const shapes::ShapeConstPtr &shape)
Remove shape from object. Shape equality is verified by comparing pointers. Ownership of the object i...
collision_detection::World::Action action_
ObjectConstPtr getObject(const std::string &id) const
Get a particular object.
bool moveShapeInObject(const std::string &id, const shapes::ShapeConstPtr &shape, const Eigen::Affine3d &pose)
Update the pose of a shape in an object. Shape equality is verified by comparing pointers. Returns true on success.
EigenSTL::vector_Affine3d shape_poses_
The poses of the corresponding entries in shapes_.
int main(int argc, char **argv)
#define EXPECT_TRUE(args)
static void TrackChangesNotify(TestAction *ta, const collision_detection::World::ObjectConstPtr &obj, collision_detection::World::Action action)
collision_detection::World::Object obj_