79 int robot_id =
rth_->getRobotID();
82 gsdf_msgs::JoinSwarm js;
83 js.robot_id = robot_id;
87 gsdf_msgs::CommPacket p;
88 p.header.source = robot_id;
90 p.header.data_len = js_vec.size();
92 p.header.checksum = 0;
93 p.content.buf = js_vec;
95 mqm_->getOutMsgQueue(
"swarm")->push(msg_data);
100 int robot_id =
rth_->getRobotID();
103 gsdf_msgs::LeaveSwarm ls;
104 ls.robot_id = robot_id;
108 gsdf_msgs::CommPacket p;
109 p.header.source = robot_id;
111 p.header.data_len = ls_vec.size();
112 p.header.version = 1;
113 p.header.checksum = 0;
114 p.content.buf = ls_vec;
116 mqm_->getOutMsgQueue(
"swarm")->push(msg_data);
166 std::set<int> result;
172 rth_->getSwarmMembers(s.
id(), b);
174 std::set_intersection(a.begin(), a.end(), b.begin(), b.end(),
175 std::insert_iterator<std::set<int> >(result, result.begin()));
177 Swarm result_swarm(new_swarm_id);
179 int robot_id=
rth_->getRobotID();
181 std::set<int>::iterator it;
182 it = result.find(robot_id);
183 if(it != result.end()) {
192 std::set<int> result;
198 rth_->getSwarmMembers(s.
id(), b);
200 std::set_union(a.begin(), a.end(), b.begin(), b.end(),
201 std::insert_iterator<std::set<int> >(result, result.begin()));
203 Swarm result_swarm(new_swarm_id);
205 int robot_id =
rth_->getRobotID();
207 std::set<int>::iterator it;
208 it = result.find(robot_id);
209 if(it != result.end()) {
218 std::set<int> result;
223 rth_->getSwarmMembers(s.
id(), b);
225 std::set_difference(a.begin(), a.end(), b.begin(), b.end(),
226 std::insert_iterator<std::set<int> >(result, result.begin()));
228 Swarm result_swarm(new_swarm_id);
230 int robot_id =
rth_->getRobotID();
232 std::set<int>::iterator it;
233 it = result.find(robot_id);
234 if(it != result.end()) {
243 Swarm result_swarm(new_swarm_id);
246 int robot_id =
rth_->getRobotID();
248 std::set<int>::iterator it;
249 it = a.find(robot_id);
262 int robot_id =
rth_->getRobotID();
264 std::set<int>::iterator it;
265 std::cout<<
"swarm "<<
swarm_id_<<
" members: "<<std::endl;
266 for(it = s.begin(); it != s.end(); it++) {
267 std::cout<<*it<<
", ";
269 std::cout<<std::endl;
boost::shared_ptr< micros_swarm::RuntimeHandle > rth_
Swarm & operator=(const Swarm &s)
const std::set< int > members()
void execute(const boost::function< void()> &f)
void unselect(const boost::function< bool()> &bf)
const Swarm negation(int new_swarm_id)
std::vector< uint8_t > serialize_ros(T t)
static boost::shared_ptr< T > getSingleton()
const Swarm difference(const Swarm &s, int new_swarm_id)
boost::shared_ptr< micros_swarm::MsgQueueManager > mqm_
const Swarm swarm_union(const Swarm &s, int new_swarm_id)
void select(const boost::function< bool()> &bf)
const Swarm intersection(const Swarm &s, int new_swarm_id)