scds_pso_tuple.cpp
Go to the documentation of this file.
1 
24 
25 namespace micros_swarm{
26 
28  {
31  }
32 
34  {
37  }
38 
40  {
41  if(this == &t) {
42  return *this;
43  }
46  return *this;
47  }
48 
50  {
51  rth_.reset();
52  mqm_.reset();
53  }
54 
55  void SCDSPSOTuple::put(const std::string& key, const SCDSPSODataTuple& data)
56  {
57  rth_->insertOrUpdateSCDSPSOValue(key, data);
58 
59  gsdf_msgs::SCDSPSOPut scds_put;
60  scds_put.key = key;
61  scds_put.pos = data.pos;
62  scds_put.val = data.val;
63  scds_put.robot_id = data.robot_id;
64  scds_put.gen = data.gen;
65  scds_put.timestamp = data.timestamp;
66  std::vector<uint8_t> scds_put_vec = serialize_ros(scds_put);
67 
68  gsdf_msgs::CommPacket p;
69  p.header.source = rth_->getRobotID();
70  p.header.type = SCDS_PSO_PUT;
71  p.header.data_len = scds_put_vec.size();
72  p.header.version = 1;
73  p.header.checksum = 0;
74  p.content.buf = scds_put_vec;
75  std::vector<uint8_t> msg_data = serialize_ros(p);
76  mqm_->getOutMsgQueue("scds_pso")->push(msg_data);
77  }
78 
79  SCDSPSODataTuple SCDSPSOTuple::get(const std::string& key)
80  {
81  SCDSPSODataTuple data;
82  if (!rth_->getSCDSPSOValue(key, data)) {
83  std::cout<<"scds pso tuple, "<<key<<" is not exist."<<std::endl;
84  exit(-1);
85  }
86 
87  gsdf_msgs::SCDSPSOGet scds_get;
88  scds_get.key = key;
89  scds_get.pos = data.pos;
90  scds_get.val = data.val;
91  scds_get.robot_id = data.robot_id;
92  scds_get.gen = data.gen;
93  scds_get.timestamp = data.timestamp;
94  std::vector<uint8_t> scds_get_vec = serialize_ros(scds_get);
95 
96  gsdf_msgs::CommPacket p;
97  p.header.source = rth_->getRobotID();
98  p.header.type = SCDS_PSO_GET;
99  p.header.data_len = scds_get_vec.size();
100  p.header.version = 1;
101  p.header.checksum = 0;
102  p.content.buf = scds_get_vec;
103  std::vector<uint8_t> msg_data = serialize_ros(p);
104  mqm_->getOutMsgQueue("scds_pso")->push(msg_data);
105 
106  return data;
107  }
108 }
SCDSPSODataTuple get(const std::string &key)
std::vector< float > pos
Definition: data_type.h:170
SCDSPSOTuple & operator=(const SCDSPSOTuple &t)
std::vector< uint8_t > serialize_ros(T t)
Definition: serialize.h:39
static boost::shared_ptr< T > getSingleton()
Definition: singleton.h:70
void put(const std::string &key, const SCDSPSODataTuple &data)
boost::shared_ptr< RuntimeHandle > rth_
boost::shared_ptr< MsgQueueManager > mqm_


micros_swarm
Author(s):
autogenerated on Mon Jun 10 2019 14:02:06