用C++在drake可视化工具中可视化线条



这个问题与是否有一种在drake可视化工具中可视化线条的方法有关,我曾问过如何在drake直观工具中可视化一条线条(大约3年前,它在v0.10.0中运行良好(。我正试图通过新的API实现同样的效果,并想知道是否有任何示例/文档可以指导我如何将线条发布到可视化工具。我以前发布一行的方法看起来像:

void publishLine(const std::vector<std::vector<double>>& pts,
const std::vector<std::string>& path, lcm::DrakeLcm& lcm,
std::vector<double> color) {
long long int now = getUnixTime() * 1000 * 1000;
nlohmann::json j = {{"timestamp", now},
{
"setgeometry",
{{{"path", path},
{"geometry",
{
{"type", "line"},
{"points", pts},
{"color", color},
{"radius", 0.1},
}}}},
},
{"settransform", nlohmann::json({})},
{"delete", nlohmann::json({})}};
auto msg = robotlocomotion::viewer2_comms_t();
msg.utime = now;
msg.format = "treeviewer_json";
msg.format_version_major = 1;
msg.format_version_minor = 0;
msg.data.clear();
for (auto& c : j.dump()) msg.data.push_back(c);
msg.num_bytes = j.dump().size();
// Use channel 0 for remote viewer communications.
lcm.get_lcm_instance()->publish("DIRECTOR_TREE_VIEWER_REQUEST_<0>", &msg);
}

您可以使用Meshcat::SetLineMeshcat::SetLineSegmentshttps://drake.mit.edu/doxygen_cxx/classdrake_1_1geometry_1_1_meshcat.html#aa5b082d79e267c040cbd066a11cdcb54

需要注意的是,许多浏览器/webGL实现不支持ThreeJS中的linewidth属性。对于粗线,请考虑使用SetObject添加圆柱体。

最新更新