本文整理汇总了C++中mongo::BSONObj::removeField方法的典型用法代码示例。如果您正苦于以下问题:C++ BSONObj::removeField方法的具体用法?C++ BSONObj::removeField怎么用?C++ BSONObj::removeField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mongo::BSONObj
的用法示例。
在下文中一共展示了BSONObj::removeField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: now
std::list<mongo::BSONObj> TransformComputable::compute_transform(mongo::BSONObj query, std::string collection)
{
//get positions in other frames
BSONObjBuilder query_other_frames;
query_other_frames.appendElements(query.removeField("frame").removeField("allow_tf"));
query_other_frames.append("frame", fromjson("{$exists:true}"));
QResCursor cur = robot_memory_->query(query_other_frames.obj(), collection);
//transform them is possible
std::list<mongo::BSONObj> res;
std::string target_frame = query.getField("frame").String();
while(cur->more())
{
BSONObj pos = cur->next();
if(pos.hasField("frame") && pos.hasField("translation") && pos.hasField("rotation"))
{
std::string src_frame = pos.getField("frame").String();
Time now(0, 0);
if(tf_->can_transform(target_frame.c_str(), src_frame.c_str(), now))
{
BSONObjBuilder res_pos;
std::vector<BSONElement> src_trans = pos.getField("translation").Array();
std::vector<BSONElement> src_rot = pos.getField("rotation").Array();
fawkes::tf::Transform pose_tf(fawkes::tf::Quaternion(src_rot[0].Double(), src_rot[1].Double(), src_rot[2].Double(), src_rot[3].Double()),
fawkes::tf::Vector3(src_trans[0].Double(), src_trans[1].Double(), src_trans[2].Double()));
fawkes::tf::Stamped<fawkes::tf::Pose> src_stamped_pose(pose_tf, Time(0, 0), src_frame.c_str());
fawkes::tf::Stamped<fawkes::tf::Pose> res_stamped_pose;
tf_->transform_pose(target_frame.c_str(), src_stamped_pose, res_stamped_pose);
res_pos.appendElements(pos.removeField("frame").removeField("translation").removeField("rotation").removeField("_id"));
res_pos.append("frame", target_frame);
res_pos.append("allow_tf", true);
BSONArrayBuilder arrb_trans;
arrb_trans.append(res_stamped_pose.getOrigin().x());
arrb_trans.append(res_stamped_pose.getOrigin().y());
arrb_trans.append(res_stamped_pose.getOrigin().z());
res_pos.append("translation", arrb_trans.arr());
BSONArrayBuilder arrb_rot;
arrb_rot.append(res_stamped_pose.getRotation().x());
arrb_rot.append(res_stamped_pose.getRotation().y());
arrb_rot.append(res_stamped_pose.getRotation().z());
arrb_rot.append(res_stamped_pose.getRotation().w());
res_pos.append("rotation", arrb_rot.arr());
res.push_back(res_pos.obj());
}
// else
// {
// logger_->log_info(name_, "Cant transform %s to %s", src_frame.c_str(), target_frame.c_str());
// }
}
}
return res;
}