moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
world_diff.h
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2011, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35/* Author: Acorn Pooley, Ioan Sucan, Sachin Chitta */
36
37#pragma once
38
41
42namespace collision_detection
43{
44MOVEIT_CLASS_FORWARD(WorldDiff); // Defines WorldDiffPtr, ConstPtr, WeakPtr... etc
45
48{
49public:
51 WorldDiff();
52
54 WorldDiff(const WorldPtr& world);
55
58
59 ~WorldDiff();
60
64 void setWorld(const WorldPtr& world);
65
68 void reset(const WorldPtr& world);
69
71 void reset();
72
74 const std::map<std::string, World::Action>& getChanges() const
75 {
76 return changes_;
77 }
78
79 using const_iterator = std::map<std::string, World::Action>::const_iterator;
82 {
83 return changes_.begin();
84 }
87 {
88 return changes_.end();
89 }
91 size_t size() const
92 {
93 return changes_.size();
94 }
96 const_iterator find(const std::string& id) const
97 {
98 return changes_.find(id);
99 }
101 void set(const std::string& id, World::Action val)
102 {
103 if (val)
104 {
105 changes_[id] = val;
106 }
107 else
108 {
109 changes_.erase(id);
110 }
111 }
112
114 void clearChanges();
115
116private:
118 void notify(const World::ObjectConstPtr& /*obj*/, World::Action /*action*/);
119
121 std::map<std::string, World::Action> changes_;
122
123 /* observer handle for world callback */
124 World::ObserverHandle observer_handle_;
125
126 /* used to unregister the notifier */
127 WorldWeakPtr world_;
128};
129} // namespace collision_detection
#define MOVEIT_CLASS_FORWARD(C)
Maintain a diff list of changes that have happened to a World.
Definition world_diff.h:48
const_iterator find(const std::string &id) const
Definition world_diff.h:96
void set(const std::string &id, World::Action val)
Definition world_diff.h:101
const_iterator begin() const
Definition world_diff.h:81
void setWorld(const WorldPtr &world)
Set which world to record. Records all objects in old world (if any) as DESTROYED and all objects in ...
void clearChanges()
Clear the internally maintained vector of changes.
const_iterator end() const
Definition world_diff.h:86
const std::map< std::string, World::Action > & getChanges() const
Return all the changes that have been recorded.
Definition world_diff.h:74
void reset()
Turn off recording and erase all previously recorded changes.
std::map< std::string, World::Action >::const_iterator const_iterator
Definition world_diff.h:79
Represents an action that occurred on an object in the world. Several bits may be set indicating seve...
Definition world.h:268