json
nlohmann的一个json.hpp
https://github.com/nlohmann/json
#include "nlohmann/json.hpp" using nlohmannJson = nlohmann::json; int main() { nlohmannJson j; j["msgType"] = "clearAll"; std::string msg = "<lxrobot>" + j.dump(); nlohmannJson j = { {"msgId", msgId}, {"msgType","GenerateObj"}, {"ObjType","robot"}, {"Name",robotName}, {"Pose", { {"Pos",{{"x",0},{"y",0},{"y",0}}}, {"Euler",{{"x",90},{"y",0},{"y",0}}} } }, {"scale", { {"x",1}, {"y",1}, {"z",1}, } } }; std::string msg = "<lxrobot>" + j.dump(); }
下面的例子的JSON格式如下:
<lxrobot>{ "msgId": 13, "msgType": "GenerateObj", "ObjType": "robot", // 对于机器人要加上 "Name":"abbIRB4600_40_255", //"Name":"abbIRB6700_150_320", //"Name":"abbIRB660", "Pose": { "Pos": { "x": 0, "y": 0, "z": 0 }, "Euler": { "x": 90, "y": 0, "z": 0 } }, "scale": { "x": 1, "y": 1, "z": 1 } }
random
effolkronium的一个random.hpp
https://github.com/effolkronium/random
#include "effolkronium/random.hpp" using Random = effolkronium::random_static; int main() { for (int i = 0; i < 5; i++) { int size = Random::get(100, 300); std::cout << "size "<<size<<std::endl; } return 0; }