Zivid SDK 互操作性
To use Zivid SDK and Zivid Motion together in the same application, convert Zivid SDK point cloud coordinates from millimeters to meters before passing them to Zivid Motion.
In C++, also instantiate Application before Motion::Application.
These integration steps are manual for now; tighter interoperability between the two SDKs is planned for the future.
有关结合 Zivid Motion 和 Zivid SDK 的完整示例应用程序,请参阅 基于 Zivid 点云的障碍物 示例。
单位:毫米 VS 米
注意:
Zivid SDK 点云坐标的单位是毫米。
Zivid Motion 的几何形状和障碍物坐标以米为单位。
在利用 SDK 点云创建运动障碍物之前,务必将坐标从毫米转换为米。
const Zivid::Matrix4x4 millimetersToMetersTransform{ {
{ 0.001f, 0.f, 0.f, 0.f },
{ 0.f, 0.001f, 0.f, 0.f },
{ 0.f, 0.f, 0.001f, 0.f },
{ 0.f, 0.f, 0.f, 1.f },
} };
frame.pointCloud().transform(millimetersToMetersTransform);
millimeters_to_meters_transform = np.diag([0.001, 0.001, 0.001, 1])
frame.point_cloud().transform(millimeters_to_meters_transform)
C++ 集成细节
应用程序实例化顺序
When using Zivid SDK and Zivid Motion in the same C++ process, create a Application first and a Motion::Application application second, to avoid an initialization error.
请按以下顺序操作:
Zivid::Application zividApp;
Zivid::Motion::Application motionApp;
数据类型转换
SDK and Motion types are different C++ types, even when they represent the same concept.
例如:
PointXYZis an SDK point type.Zivid::Motion::Vector3fis the Motion point type.
从 SDK 点云数据创建运动障碍物时,需要显式转换:
// Ensure that the point cloud is in meters, not millimeters, before copying the XYZ data.
// Also, make sure to use an unorganized point cloud, as Motion always expects unorganized point clouds.
const auto xyzData = unorganizedPointCloud.copyPointsXYZ();
std::vector<Zivid::Motion::Vector3f> points;
points.reserve(xyzData.size());
for(const auto &p : xyzData)
{
points.emplace_back(Zivid::Motion::Vector3f{ p.x, p.y, p.z });
}
planner.setObstacles({ Zivid::Motion::Obstacle::fromPointCloud("point_cloud_obstacle", points) });
Python 集成详情
在Python中,互操作性更容易实现:
Zivid SDK 和 Zivid Motion 都能自然地与 NumPy 兼容的数据配合使用。
除了毫米到米的转换之外,不需要任何特殊的数据转换步骤。
zivid.Application()和zividmotion.Application()之间没有实例化顺序的限制。