Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
logger.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
9
19#include "momentum/math/mesh.h"
20
21#include <axel/Bvh.h>
22#include <fmt/format.h>
23#include <rerun.hpp>
24
25#include <array>
26#include <vector>
27
28namespace momentum {
29
30namespace {
31
32template <typename Derived>
33std::array<float, 3> toStdArray3f(const Eigen::MatrixBase<Derived>& vec3) {
34 return {static_cast<float>(vec3[0]), static_cast<float>(vec3[1]), static_cast<float>(vec3[2])};
35}
36
37template <typename Derived>
38rerun::Position3D toRerunPosition3D(const Eigen::MatrixBase<Derived>& vec3) {
39 return rerun::Position3D(vec3[0], vec3[1], vec3[2]);
40}
41
42template <typename Derived>
43rerun::HalfSize3D toRerunHalfSizes3D(const Eigen::MatrixBase<Derived>& vec3) {
44 return rerun::HalfSize3D(vec3[0], vec3[1], vec3[2]);
45}
46
47} // namespace
48
49namespace detail {
50
52 const CollisionGeometry& collisionGeometry,
53 const SkeletonState& skeletonState) {
55 data.centers.reserve(collisionGeometry.size());
56 data.halfSizes.reserve(collisionGeometry.size());
57 data.quaternions.reserve(collisionGeometry.size());
58
59 for (const auto& cg : collisionGeometry) {
60 if (cg.type != CollisionPrimitiveType::Ellipsoid) {
61 continue;
62 }
63
64 const Transform parentTransform = (cg.parent == kInvalidIndex)
65 ? Transform()
66 : skeletonState.jointState.at(cg.parent).transform;
67 const Transform tf = parentTransform * cg.transformation;
68
69 data.centers.push_back(tf.translation);
70 // Radii are scaled by the parent joint scale only (matches CollisionGeometryStateT::update).
71 data.halfSizes.emplace_back(cg.ellipsoidRadii * parentTransform.scale);
72 data.quaternions.push_back(tf.rotation);
73 }
74
75 return data;
76}
77
79 const CollisionGeometry& collisionGeometry,
80 const SkeletonState& skeletonState) {
82 data.centers.reserve(collisionGeometry.size());
83 data.halfSizes.reserve(collisionGeometry.size());
84 data.quaternions.reserve(collisionGeometry.size());
85
86 for (const auto& cg : collisionGeometry) {
87 if (cg.type != CollisionPrimitiveType::Box) {
88 continue;
89 }
90
91 const Transform parentTransform = (cg.parent == kInvalidIndex)
92 ? Transform()
93 : skeletonState.jointState.at(cg.parent).transform;
94 const Transform tf = parentTransform * cg.transformation;
95
96 data.centers.push_back(tf.translation);
97 data.halfSizes.emplace_back(cg.boxHalfExtents * parentTransform.scale);
98 data.quaternions.push_back(tf.rotation);
99 }
100
101 return data;
102}
103
104} // namespace detail
105
107 const rerun::RecordingStream& rec,
108 const std::string& streamName,
109 const Mesh& mesh,
110 std::optional<rerun::Color> color) {
111 auto rerunMesh = rerun::Mesh3D(mesh.vertices).with_triangle_indices(mesh.faces);
112 if (color.has_value()) {
113 rerunMesh = std::move(rerunMesh).with_albedo_factor(rerun::AlbedoFactor(color.value()));
114 } else if (mesh.colors.size() == mesh.vertices.size()) {
115 rerunMesh = std::move(rerunMesh).with_vertex_colors(mesh.colors);
116 }
117
118 if (mesh.normals.size() == mesh.vertices.size()) {
119 rerunMesh = std::move(rerunMesh).with_vertex_normals(mesh.normals);
120 }
121
122 safeLog(rec, streamName, rerunMesh);
123}
124
126 const rerun::RecordingStream& rec,
127 const std::string& streamName,
128 const Skeleton& skeleton,
129 const JointStateList& jointStates) {
130 const rerun::Color kGrey(180, 180, 180);
131 const auto names = skeleton.getJointNames();
132 std::vector<std::string> labels;
133 std::vector<std::vector<std::array<float, 3>>> lines;
134 labels.reserve(names.size());
135 lines.reserve(names.size());
136 for (size_t iJoint = 0; iJoint < jointStates.size(); ++iJoint) {
137 if (iJoint >= skeleton.joints.size()) {
138 break;
139 }
140 const size_t parentIdx = skeleton.joints[iJoint].parent;
141 if (parentIdx != kInvalidIndex && parentIdx < jointStates.size()) {
142 lines.push_back(
143 {toStdArray3f(jointStates[parentIdx].transform.translation),
144 toStdArray3f(jointStates[iJoint].transform.translation)});
145 labels.push_back(names[iJoint]);
146 }
147 safeLog(
148 rec,
149 streamName + "/" + names[iJoint],
150 rerun::Transform3D()
151 .with_mat3x3(
152 rerun::datatypes::Mat3x3(jointStates[iJoint].transform.toRotationMatrix().data()))
153 .with_translation(
154 rerun::datatypes::Vec3D(jointStates[iJoint].transform.translation.data()))
155#if !defined(RERUN_VERSION_GE) || !RERUN_VERSION_GE(0, 24, 0)
156 .with_axis_length(rerun::components::AxisLength(10))
157#endif
158 );
159 }
160 safeLog(
161 rec,
162 streamName,
163 rerun::LineStrips3D(lines).with_radii(0.2f).with_colors(kGrey).with_labels(labels));
164}
165
167 const rerun::RecordingStream& rec,
168 const std::string& streamName,
169 std::span<const Marker> markers) {
170 const rerun::Color kPurple(120, 120, 255);
171 std::vector<rerun::Position3D> points3d;
172 std::vector<std::string> labels;
173 points3d.reserve(markers.size());
174 labels.reserve(markers.size());
175
176 for (const auto& marker : markers) {
177 if (marker.occluded) {
178 continue;
179 }
180 points3d.push_back(toRerunPosition3D(marker.pos));
181 labels.push_back(marker.name);
182 }
183
184 // TODO: make radius and color configurable
185 safeLog(
186 rec,
187 streamName,
188 rerun::Points3D(points3d).with_radii(0.5f).with_colors(kPurple).with_labels(labels));
189}
190
192 const rerun::RecordingStream& rec,
193 const std::string& streamName,
194 const LocatorList& locators,
195 const LocatorState& locatorState) {
196 if (locators.empty()) {
197 return;
198 }
199
200 const rerun::Color kGreen(100, 255, 100);
201 std::vector<std::string> labels;
202 std::vector<rerun::Position3D> points3d;
203 std::vector<rerun::Color> colors;
204 points3d.reserve(locatorState.position.size());
205 labels.reserve(locatorState.position.size());
206 colors.reserve(locatorState.position.size());
207
208 for (size_t i = 0; i < locatorState.position.size(); ++i) {
209 const auto& locator = locatorState.position[i];
210 points3d.push_back(toRerunPosition3D(locator));
211 labels.push_back(locators[i].name);
212 rerun::Color color{};
213 if (locators.at(i).name.find("Floor_") != std::string::npos) {
214 color = kGreen;
215 } else {
216 float intensity = 255.0f * locators[i].weight * 0.6f;
217 color = rerun::Color(
218 static_cast<uint8_t>(intensity),
219 static_cast<uint8_t>(intensity),
220 static_cast<uint8_t>(intensity * 0.5f));
221 }
222 colors.push_back(color);
223 }
224
225 // TODO: make radius and color configurable
226 safeLog(
227 rec,
228 streamName,
229 rerun::Points3D(points3d).with_radii(0.5f).with_colors(colors).with_labels(labels));
230}
231
233 const rerun::RecordingStream& rec,
234 const std::string& streamName,
235 const std::map<std::string, size_t>& locatorLookup,
236 const LocatorState& locatorState,
237 std::span<const Marker> markers,
238 const float kPositionErrorThreshold) {
239 if (locatorLookup.empty()) {
240 // No correspondence provided.
241 return;
242 }
243 std::vector<std::string> labels;
244 std::vector<std::vector<std::array<float, 3>>> lines;
245 std::vector<rerun::components::Color> colors;
246 std::vector<rerun::components::Radius> radius;
247 lines.reserve(markers.size());
248 labels.reserve(markers.size());
249 colors.reserve(markers.size());
250 radius.reserve(markers.size());
251
252 const rerun::components::Color kGreenColor(50, 255, 128);
253 const rerun::components::Color kRedColor(255, 100, 100);
254 const rerun::components::Radius kDefaultRadius(0.1f);
255 const rerun::components::Radius kLargeRadius(0.5f);
256
257 for (const auto& marker : markers) {
258 if (!marker.occluded && (locatorLookup.count(marker.name) != 0)) {
259 const auto locatorIdx = locatorLookup.at(marker.name);
260 const auto locator = locatorState.position.at(locatorIdx);
261
262 lines.push_back({toStdArray3f(marker.pos), toStdArray3f(locator)});
263 labels.push_back(marker.name);
264
265 // TODO: expose marker error computation?
266 const auto error = (marker.pos.cast<float>() - locator).squaredNorm();
267 if (error > kPositionErrorThreshold) {
268 colors.push_back(kRedColor);
269 radius.push_back(kLargeRadius);
270 } else {
271 colors.push_back(kGreenColor);
272 radius.push_back(kDefaultRadius);
273 }
274 }
275
276 safeLog(
277 rec,
278 streamName,
279 rerun::LineStrips3D(lines).with_labels(labels).with_colors(colors).with_radii(radius));
280 }
281}
282
284 const rerun::RecordingStream& rec,
285 const std::string& worldPrefix,
286 const std::string& posePrefix,
287 std::span<const std::string> names,
288 const Eigen::VectorXf& params) {
289 // TODO: check names and params have the same size
290 const size_t nParams = params.size();
291
292 for (size_t iParam = 0; iParam < nParams; ++iParam) {
293 if (names[iParam].find("root") != std::string::npos) {
294 safeLog(rec, fmt::format("{}/{}", worldPrefix, names[iParam]), makeScalar(params[iParam]));
295 } else {
296 safeLog(rec, fmt::format("{}/{}", posePrefix, names[iParam]), makeScalar(params[iParam]));
297 }
298 }
299}
300
302 const rerun::RecordingStream& rec,
303 const std::string& worldPrefix,
304 const std::string& posePrefix,
305 std::span<const std::string> names,
306 const Eigen::VectorXf& params) {
307 // TODO: check names vs params size
308
309 for (size_t iJoint = 0; iJoint < names.size(); ++iJoint) {
310 for (size_t jParam = 0; jParam < kParametersPerJoint; ++jParam) {
311 const std::string channelName = names[iJoint] + "_" + kJointParameterNames[jParam];
312 const size_t paramIdx = iJoint * kParametersPerJoint + jParam;
313 if (names[iJoint].find("world") != std::string::npos ||
314 names[iJoint].find("root") != std::string::npos) {
315 safeLog(rec, fmt::format("{}/{}", worldPrefix, channelName), makeScalar(params[paramIdx]));
316 } else {
317 safeLog(rec, fmt::format("{}/{}", posePrefix, channelName), makeScalar(params[paramIdx]));
318 }
319 }
320 }
321}
322
324 const rerun::RecordingStream& rec,
325 const std::string& worldPrefix,
326 const std::string& posePrefix,
327 std::span<const std::string> names) {
328 for (const auto& name : names) {
329 if (name.find("root") != std::string::npos) {
330 safeLogStatic(rec, fmt::format("{}/{}", worldPrefix, name), makeSeriesLineWithName(name));
331 } else {
332 safeLogStatic(rec, fmt::format("{}/{}", posePrefix, name), makeSeriesLineWithName(name));
333 }
334 }
335}
336
338 const rerun::RecordingStream& rec,
339 const std::string& worldPrefix,
340 const std::string& posePrefix,
341 std::span<const std::string> names) {
342 for (const auto& name : names) {
343 for (const auto& jointParameterName : kJointParameterNames) {
344 const std::string channelName = name + "_" + jointParameterName;
345 if (name.find("world") != std::string::npos || name.find("root") != std::string::npos) {
347 rec,
348 fmt::format("{}/{}", worldPrefix, channelName),
349 makeSeriesLineWithName(channelName));
350 } else {
352 rec,
353 fmt::format("{}/{}", posePrefix, channelName),
354 makeSeriesLineWithName(channelName));
355 }
356 }
357 }
358}
359
361 const rerun::RecordingStream& rec,
362 const std::string& worldPrefix,
363 const std::string& posePrefix,
364 std::span<const std::string> names,
365 const Eigen::MatrixXf& allParams,
366 std::span<const int64_t> frameIndices,
367 std::span<const double> times) {
368 const auto nFrames = static_cast<size_t>(allParams.cols());
369 if (nFrames == 0) {
370 return;
371 }
372
373 // Build time columns (reused for all parameters)
374 auto frameIndexColumn = makeSequenceTimeColumn(
375 "frame_index",
376 rerun::Collection<int64_t>::borrow(frameIndices.data(), frameIndices.size()),
377 rerun::SortingStatus::Sorted);
378 auto timeColumn = makeDurationSecondsTimeColumn(
379 "time",
380 rerun::Collection<double>::borrow(times.data(), times.size()),
381 rerun::SortingStatus::Sorted);
382 const std::vector<rerun::TimeColumn> timeColumns = {
383 std::move(frameIndexColumn), std::move(timeColumn)};
384
385 const size_t nParams = std::min(static_cast<size_t>(allParams.rows()), names.size());
386 for (size_t iParam = 0; iParam < nParams; ++iParam) {
387 // Build scalar values for this parameter across all frames
388 std::vector<double> scalarValues(nFrames);
389 for (size_t iFrame = 0; iFrame < nFrames; ++iFrame) {
390 scalarValues[iFrame] = static_cast<double>(allParams(iParam, iFrame));
391 }
392
393 auto scalarColumns = makeScalarColumns(std::move(scalarValues));
394
395 if (names[iParam].find("root") != std::string::npos) {
396 rec.send_columns(
397 fmt::format("{}/{}", worldPrefix, names[iParam]), timeColumns, scalarColumns);
398 } else {
399 rec.send_columns(fmt::format("{}/{}", posePrefix, names[iParam]), timeColumns, scalarColumns);
400 }
401 }
402}
403
405 const rerun::RecordingStream& rec,
406 const std::string& worldPrefix,
407 const std::string& posePrefix,
408 std::span<const std::string> names,
409 const Eigen::MatrixXf& allJointParams,
410 std::span<const int64_t> frameIndices,
411 std::span<const double> times) {
412 const auto nFrames = static_cast<size_t>(allJointParams.cols());
413 if (nFrames == 0) {
414 return;
415 }
416
417 // Build time columns (reused for all parameters)
418 auto frameIndexColumn = makeSequenceTimeColumn(
419 "frame_index",
420 rerun::Collection<int64_t>::borrow(frameIndices.data(), frameIndices.size()),
421 rerun::SortingStatus::Sorted);
422 auto timeColumn = makeDurationSecondsTimeColumn(
423 "time",
424 rerun::Collection<double>::borrow(times.data(), times.size()),
425 rerun::SortingStatus::Sorted);
426 const std::vector<rerun::TimeColumn> timeColumns = {
427 std::move(frameIndexColumn), std::move(timeColumn)};
428
429 // Bounds check: ensure we don't read beyond allJointParams rows
430 const size_t nJoints =
431 std::min(names.size(), static_cast<size_t>(allJointParams.rows()) / kParametersPerJoint);
432 for (size_t iJoint = 0; iJoint < nJoints; ++iJoint) {
433 for (size_t jParam = 0; jParam < kParametersPerJoint; ++jParam) {
434 const std::string channelName = names[iJoint] + "_" + kJointParameterNames[jParam];
435 const size_t paramIdx = iJoint * kParametersPerJoint + jParam;
436
437 // Build scalar values for this joint parameter across all frames
438 std::vector<double> scalarValues(nFrames);
439 for (size_t iFrame = 0; iFrame < nFrames; ++iFrame) {
440 scalarValues[iFrame] = static_cast<double>(allJointParams(paramIdx, iFrame));
441 }
442
443 auto scalarColumns = makeScalarColumns(std::move(scalarValues));
444
445 if (names[iJoint].find("world") != std::string::npos ||
446 names[iJoint].find("root") != std::string::npos) {
447 rec.send_columns(
448 fmt::format("{}/{}", worldPrefix, channelName), timeColumns, scalarColumns);
449 } else {
450 rec.send_columns(fmt::format("{}/{}", posePrefix, channelName), timeColumns, scalarColumns);
451 }
452 }
453 }
454}
455
457 const rerun::RecordingStream& rec,
458 const std::string& streamName,
459 const CollisionGeometry& collisionGeometry,
460 const SkeletonState& skeletonState) {
461 // Compute collision state
462 CollisionGeometryState collisionState;
463 collisionState.update(skeletonState, collisionGeometry);
464
465 // Compute AABBs
466 const auto n = collisionGeometry.size();
467 std::vector<axel::BoundingBoxf> aabbs(n);
468 for (size_t i = 0; i < n; ++i) {
469 auto& aabb = aabbs[i];
470 aabb.id = static_cast<axel::Index>(i);
471 updateAabb(aabb, collisionState, i);
472 }
473
474 // Construct BVH
475 axel::Bvhf bvh;
476 bvh.setBoundingBoxes(aabbs);
477 const auto& bvs = bvh.getPrimitives();
478
479 // Log BVH
480 std::vector<rerun::Position3D> centers;
481 std::vector<rerun::HalfSize3D> halfSizes;
482 centers.reserve(bvs.size());
483 halfSizes.reserve(bvs.size());
484 for (const auto& bv : bvs) {
485 centers.push_back(toRerunPosition3D(bv.center()));
486 halfSizes.push_back(toRerunHalfSizes3D((bv.max() - bv.min()) / 2.0f));
487 }
488
489 // TODO: make radius configurable
490 // TODO: use different colors by the depth of BVH nodes
491 safeLog(
492 rec,
493 streamName,
494 rerun::Boxes3D::from_centers_and_half_sizes(centers, halfSizes)
495 .with_radii(0.1f)
496 .with_colors(rerun::Color(64, 128, 64)));
497}
498
500 const rerun::RecordingStream& rec,
501 const std::string& streamName,
502 const CollisionGeometry& collisionGeometry,
503 const SkeletonState& skeletonState) {
504 std::vector<rerun::Position3D> capsuleTranslations;
505 std::vector<rerun::Quaternion> capsuleQuaternions;
506 std::vector<float> capsuleLengths;
507 std::vector<float> capsuleRadii;
508
509 capsuleTranslations.reserve(collisionGeometry.size());
510 capsuleQuaternions.reserve(collisionGeometry.size());
511 capsuleLengths.reserve(collisionGeometry.size());
512 capsuleRadii.reserve(collisionGeometry.size());
513
514 for (const auto& cg : collisionGeometry) {
516 continue;
517 }
518 const Transform parentTransform = (cg.parent == kInvalidIndex)
519 ? Transform()
520 : skeletonState.jointState.at(cg.parent).transform;
521 const Transform tf = parentTransform * cg.transformation;
522
523 const Quaternionf& q = tf.rotation * Eigen::AngleAxisf(0.5f * pi(), Vector3f::UnitY());
524 capsuleTranslations.push_back(toRerunPosition3D(tf.translation));
525 capsuleQuaternions.emplace_back(rerun::Quaternion::from_xyzw(q.x(), q.y(), q.z(), q.w()));
526 // Match CollisionGeometryStateT::update: length runs along the composed-transform
527 // X axis (scaled by the full transform scale), radius is scaled by the parent joint
528 // scale only.
529 capsuleLengths.emplace_back(cg.length * tf.scale);
530 // TODO: Rerun doesn't support capsules with different radii (i.e. tapered capsule) yet
531 capsuleRadii.emplace_back(cg.radius.maxCoeff() * parentTransform.scale);
532 }
533
534 if (!capsuleLengths.empty()) {
535 safeLog(
536 rec,
537 streamName + "/capsules",
538 rerun::Capsules3D::from_lengths_and_radii(capsuleLengths, capsuleRadii)
539 .with_translations(capsuleTranslations)
540 .with_quaternions(capsuleQuaternions)
541 .with_colors(rerun::Color(128, 64, 64))
542 .with_fill_mode(rerun::FillMode::Solid));
543 }
544
545 const auto ellipsoidLogData =
546 detail::makeCollisionEllipsoidLogData(collisionGeometry, skeletonState);
547 if (!ellipsoidLogData.halfSizes.empty()) {
548 std::vector<rerun::Position3D> ellipsoidCenters;
549 std::vector<rerun::HalfSize3D> ellipsoidHalfSizes;
550 std::vector<rerun::Quaternion> ellipsoidQuaternions;
551 ellipsoidCenters.reserve(ellipsoidLogData.centers.size());
552 ellipsoidHalfSizes.reserve(ellipsoidLogData.halfSizes.size());
553 ellipsoidQuaternions.reserve(ellipsoidLogData.quaternions.size());
554
555 for (size_t i = 0; i < ellipsoidLogData.halfSizes.size(); ++i) {
556 const Quaternionf& q = ellipsoidLogData.quaternions[i];
557 ellipsoidCenters.push_back(toRerunPosition3D(ellipsoidLogData.centers[i]));
558 ellipsoidHalfSizes.push_back(toRerunHalfSizes3D(ellipsoidLogData.halfSizes[i]));
559 ellipsoidQuaternions.emplace_back(rerun::Quaternion::from_xyzw(q.x(), q.y(), q.z(), q.w()));
560 }
561
562 safeLog(
563 rec,
564 streamName + "/ellipsoids",
565 rerun::Ellipsoids3D::from_centers_and_half_sizes(ellipsoidCenters, ellipsoidHalfSizes)
566 .with_quaternions(ellipsoidQuaternions)
567 .with_colors(rerun::Color(128, 64, 64))
568 .with_fill_mode(rerun::FillMode::Solid));
569 }
570
571 const auto boxLogData = detail::makeCollisionBoxLogData(collisionGeometry, skeletonState);
572 if (!boxLogData.halfSizes.empty()) {
573 std::vector<rerun::Position3D> boxCenters;
574 std::vector<rerun::HalfSize3D> boxHalfSizes;
575 std::vector<rerun::Quaternion> boxQuaternions;
576 boxCenters.reserve(boxLogData.centers.size());
577 boxHalfSizes.reserve(boxLogData.halfSizes.size());
578 boxQuaternions.reserve(boxLogData.quaternions.size());
579
580 for (size_t i = 0; i < boxLogData.halfSizes.size(); ++i) {
581 const Quaternionf& q = boxLogData.quaternions[i];
582 boxCenters.push_back(toRerunPosition3D(boxLogData.centers[i]));
583 boxHalfSizes.push_back(toRerunHalfSizes3D(boxLogData.halfSizes[i]));
584 boxQuaternions.emplace_back(rerun::Quaternion::from_xyzw(q.x(), q.y(), q.z(), q.w()));
585 }
586
587 safeLog(
588 rec,
589 streamName + "/boxes",
590 rerun::Boxes3D::from_centers_and_half_sizes(boxCenters, boxHalfSizes)
591 .with_quaternions(boxQuaternions)
592 .with_colors(rerun::Color(128, 64, 64))
593 .with_fill_mode(rerun::FillMode::Solid));
594 }
595
596 logBvh(rec, streamName + "/bvh", collisionGeometry, skeletonState);
597}
598
600 const rerun::RecordingStream& rec,
601 const std::string& charStreamName,
602 const Character& character,
603 const CharacterState& characterState,
604 const rerun::Color& color) {
605 if (characterState.meshState != nullptr) {
606 logMesh(rec, charStreamName + "/mesh", *characterState.meshState, color);
607 }
608 if (!character.locators.empty()) {
609 logLocators(rec, charStreamName + "/locators", character.locators, characterState.locatorState);
610 }
611
612 logJoints(
613 rec, charStreamName + "/joints", character.skeleton, characterState.skeletonState.jointState);
614
615 if (const auto& collision = character.collision) {
617 rec, charStreamName + "/collision_geometry", *collision, characterState.skeletonState);
618 }
619}
620
621} // namespace momentum
CollisionBoxLogData makeCollisionBoxLogData(const CollisionGeometry &collisionGeometry, const SkeletonState &skeletonState)
Extracts world-space box collision geometry from the current skeleton state.
Definition logger.cpp:78
CollisionEllipsoidLogData makeCollisionEllipsoidLogData(const CollisionGeometry &collisionGeometry, const SkeletonState &skeletonState)
Extracts world-space ellipsoid collision geometry from the current skeleton state.
Definition logger.cpp:51
void logModelParams(const rerun::RecordingStream &rec, const std::string &worldPrefix, const std::string &posePrefix, std::span< const std::string > names, const Eigen::VectorXf &params)
Definition logger.cpp:283
TransformT< float > Transform
Definition fwd.h:77
CollisionGeometryT< float > CollisionGeometry
SkeletonT< float > Skeleton
Definition fwd.h:263
CollisionGeometryStateT< float > CollisionGeometryState
Definition fwd.h:130
Quaternion< float > Quaternionf
Definition types.h:386
rerun::TimeColumn makeSequenceTimeColumn(std::string timelineName, rerun::Collection< int64_t > values, rerun::SortingStatus sortingStatus=rerun::SortingStatus::Unknown)
void logMarkers(const rerun::RecordingStream &rec, const std::string &streamName, std::span< const Marker > markers)
Definition logger.cpp:166
CharacterStateT< float > CharacterState
Definition fwd.h:92
auto makeSeriesLineWithName(const std::string &name)
rerun::TimeColumn makeDurationSecondsTimeColumn(std::string timelineName, rerun::Collection< double > values, rerun::SortingStatus sortingStatus=rerun::SortingStatus::Unknown)
ParameterSet allParams()
Creates a ParameterSet with all parameters set to active.
Definition utility.h:37
JointStateListT< float > JointStateList
void logJoints(const rerun::RecordingStream &rec, const std::string &streamName, const Skeleton &skeleton, const JointStateList &jointStates)
Definition logger.cpp:125
void logCharacter(const rerun::RecordingStream &rec, const std::string &charStreamName, const Character &character, const CharacterState &characterState, const rerun::Color &color)
Definition logger.cpp:599
void logJointParamNames(const rerun::RecordingStream &rec, const std::string &worldPrefix, const std::string &posePrefix, std::span< const std::string > names)
Definition logger.cpp:337
MeshT< float > Mesh
Definition fwd.h:20
auto makeScalar(T value)
constexpr std::array< const char *, kParametersPerJoint > kJointParameterNames
Definition types.h:24
void logMesh(const rerun::RecordingStream &rec, const std::string &streamName, const Mesh &mesh, std::optional< rerun::Color > color)
Definition logger.cpp:106
void logModelParamsColumns(const rerun::RecordingStream &rec, const std::string &worldPrefix, const std::string &posePrefix, std::span< const std::string > names, const Eigen::MatrixXf &allParams, std::span< const int64_t > frameIndices, std::span< const double > times)
Log model parameters for all frames at once using send_columns.
Definition logger.cpp:360
void logBvh(const rerun::RecordingStream &rec, const std::string &streamName, const CollisionGeometry &collisionGeometry, const SkeletonState &skeletonState)
Definition logger.cpp:456
void logMarkerLocatorCorrespondence(const rerun::RecordingStream &rec, const std::string &streamName, const std::map< std::string, size_t > &locatorLookup, const LocatorState &locatorState, std::span< const Marker > markers, const float kPositionErrorThreshold)
Definition logger.cpp:232
SkeletonStateT< float > SkeletonState
Definition fwd.h:282
void updateAabb(axel::BoundingBox< T > &aabb, const Vector3< T > &originA, const Vector3< T > &direction, const Vector2< T > &radii)
Updates an axis-aligned bounding box to encompass a tapered capsule.
void logCollisionGeometry(const rerun::RecordingStream &rec, const std::string &streamName, const CollisionGeometry &collisionGeometry, const SkeletonState &skeletonState)
Definition logger.cpp:499
constexpr size_t kParametersPerJoint
Definition types.h:21
void logModelParamNames(const rerun::RecordingStream &rec, const std::string &worldPrefix, const std::string &posePrefix, std::span< const std::string > names)
Definition logger.cpp:323
rerun::Collection< rerun::ComponentColumn > makeScalarColumns(std::vector< double > values)
void logJointParams(const rerun::RecordingStream &rec, const std::string &worldPrefix, const std::string &posePrefix, std::span< const std::string > names, const Eigen::VectorXf &params)
Definition logger.cpp:301
void logJointParamsColumns(const rerun::RecordingStream &rec, const std::string &worldPrefix, const std::string &posePrefix, std::span< const std::string > names, const Eigen::MatrixXf &allJointParams, std::span< const int64_t > frameIndices, std::span< const double > times)
Log joint parameters for all frames at once using send_columns.
Definition logger.cpp:404
constexpr size_t kInvalidIndex
Sentinel value indicating an invalid or unset size_t index.
Definition types.h:182
void safeLog(const rerun::RecordingStream &rec, std::string_view entityPath, const T &archetype)
Safe wrapper for RecordingStream::log that skips empty archetypes.
constexpr T pi() noexcept
Returns the mathematical constant pi.
Definition constants.h:50
void logLocators(const rerun::RecordingStream &rec, const std::string &streamName, const LocatorList &locators, const LocatorState &locatorState)
Definition logger.cpp:191
void safeLogStatic(const rerun::RecordingStream &rec, std::string_view entityPath, const T &archetype)
Safe wrapper for RecordingStream::log_static that skips empty archetypes.
std::vector< Locator > LocatorList
A collection of locators attached to a skeleton.
Definition locator.h:79
Mesh_u meshState
Skinned mesh; null when constructed/updated with updateMesh=false or when the reference character has...
A character model with skeletal structure, mesh, and optional components.
Definition character.h:32
LocatorList locators
Points of interest attached to joints.
Definition character.h:49
Skeleton skeleton
Skeletal structure defining the character's joints and hierarchy.
Definition character.h:36
CollisionGeometry_u collision
Collision volumes for the character.
Definition character.h:64
void update(const SkeletonStateT< T > &skeletonState, const CollisionGeometry &collisionGeometry)
Updates the state based on a given skeleton state and collision geometry.
Tracks the current world positions of locators in a skeleton.
std::vector< Vector3f > position
World-space positions of all locators, updated when the skeleton moves.
std::vector< Eigen::Vector3< T > > vertices
List of mesh vertices in 3D space.
Definition mesh.h:22
std::vector< Eigen::Vector3< T > > normals
List of vertex normals (same size as vertices when computed).
Definition mesh.h:25
std::vector< Eigen::Vector3i > faces
List of triangular faces defined by vertex indices.
Definition mesh.h:28
std::vector< Eigen::Vector3b > colors
List of per-vertex RGB colors (0-255 for each channel).
Definition mesh.h:35
JointStateListT< T > jointState
Computed joint states for all joints in the skeleton.
JointList joints
The list of joints in this skeleton, ordered such that every joint's parent appears earlier in the li...
Definition skeleton.h:25
std::vector< std::string > getJointNames() const
Definition skeleton.cpp:35
T scale
Uniform scale factor applied before rotation and translation.
Definition transform.h:42
Vector3< T > translation
Definition transform.h:40
Quaternion< T > rotation
Unit quaternion encoding the rotation.
Definition transform.h:39
World-space box collision primitive data prepared for Rerun box logging.
Definition logger.h:41
std::vector< Quaternionf > quaternions
Definition logger.h:44
std::vector< Vector3f > halfSizes
Definition logger.h:43
std::vector< Vector3f > centers
Definition logger.h:42
World-space ellipsoid collision primitive data prepared for Rerun ellipsoid logging.
Definition logger.h:29
std::vector< Quaternionf > quaternions
Definition logger.h:32
std::vector< Vector3f > halfSizes
Definition logger.h:31
std::vector< Vector3f > centers
Definition logger.h:30