Skip to content

feat(lcmt_generators) : Add standard LCM generators for C3 Output and Contact Descriptions#10

Merged
Meow404 merged 19 commits intomainfrom
stephen/dairlib-plate-balancing-example
Apr 9, 2026
Merged

feat(lcmt_generators) : Add standard LCM generators for C3 Output and Contact Descriptions#10
Meow404 merged 19 commits intomainfrom
stephen/dairlib-plate-balancing-example

Conversation

@Meow404
Copy link
Copy Markdown
Collaborator

@Meow404 Meow404 commented Jun 23, 2025

Fixes : #11, #36
Support for : DAIRLab/dairlib#376

This change is Reviewable

@Meow404 Meow404 changed the base branch from main to stephen/lcs-drake-factory-leaf-system June 23, 2025 16:40
@Meow404 Meow404 linked an issue Jun 23, 2025 that may be closed by this pull request
@Meow404 Meow404 force-pushed the stephen/dairlib-plate-balancing-example branch from 57cd440 to 1bcc69c Compare June 26, 2025 01:07
@Meow404 Meow404 force-pushed the stephen/lcs-drake-factory-leaf-system branch from 3c1e562 to bbd5e25 Compare June 26, 2025 17:05
@Meow404 Meow404 force-pushed the stephen/dairlib-plate-balancing-example branch from 1bcc69c to e1f2869 Compare June 26, 2025 17:11
@xuanhien070594
Copy link
Copy Markdown
Contributor

core/configs/solve_options_default.hpp line 3 at r1 (raw file):

#pragma once
#include <string>
const std::string default_solver_options =

I'm confused about why we use yaml string here instead of normal yaml.

@xuanhien070594
Copy link
Copy Markdown
Contributor

systems/publishers/output_publisher.h line 46 at r1 (raw file):

              c3::lcmt_output* output) const;

  //  void OutputNextC3Input(const drake::systems::Context<double>& context,

Pls remove commented codes.

@xuanhien070594
Copy link
Copy Markdown
Contributor

systems/publishers/force_publisher.h line 16 at r1 (raw file):

namespace systems {
namespace publishers {
class ContactForcePublisher : public drake::systems::LeafSystem<double> {

Missing documentation

@xuanhien070594
Copy link
Copy Markdown
Contributor

systems/publishers/force_publisher.cc line 16 at r1 (raw file):

namespace systems {
namespace publishers {
ContactForcePublisher::ContactForcePublisher() {

We'll need some documentation for input ports and output ports.

@Meow404 Meow404 force-pushed the stephen/dairlib-plate-balancing-example branch from e1f2869 to 720d12b Compare June 27, 2025 21:49
@Meow404 Meow404 changed the base branch from stephen/lcs-drake-factory-leaf-system to main June 27, 2025 22:58
@Meow404 Meow404 self-assigned this Jun 29, 2025
@xuanhien070594
Copy link
Copy Markdown
Contributor

systems/publishers/output_publisher.h line 17 at r2 (raw file):

namespace publishers {
/// Converts a OutputVector object to LCM type lcmt_robot_output
class C3OutputPublisher : public drake::systems::LeafSystem<double> {

Pls add documentation.

@xuanhien070594
Copy link
Copy Markdown
Contributor

systems/publishers/force_publisher.cc line 46 at r2 (raw file):

  MatrixXd J_c = contact_info->first;
  int contact_force_start = solution->lambda_sol_.rows() - J_c.rows();
  bool using_stewart_and_trinkle_model = contact_force_start > 0;

Using the difference in dimension of lambda and number of force basis to determine the contact model is generally not a safe way. Could we store the type of contact model in the C3Solution?

@Meow404 Meow404 force-pushed the stephen/dairlib-plate-balancing-example branch from a1a373d to 80dd8e5 Compare June 30, 2025 13:48
@Meow404
Copy link
Copy Markdown
Collaborator Author

Meow404 commented Jun 30, 2025

FYI, building with different drake versions doesnt seem to be an issue so far between dairlib and c3.

Copy link
Copy Markdown
Collaborator Author

@Meow404 Meow404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 19 files reviewed, 6 unresolved discussions (waiting on @xuanhien070594)


systems/publishers/force_publisher.h line 16 at r1 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

Missing documentation

Done.


systems/publishers/force_publisher.cc line 16 at r1 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

We'll need some documentation for input ports and output ports.

Done.


systems/publishers/output_publisher.h line 46 at r1 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

Pls remove commented codes.

Done.


systems/publishers/output_publisher.h line 17 at r2 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

Pls add documentation.

Done.

@xuanhien070594
Copy link
Copy Markdown
Contributor

lcmtypes/lcmt_forces.lcm line 1 at r3 (raw file):

package c3;

Should the name be lcmt_contact_forces.lcm?

@Meow404 Meow404 force-pushed the stephen/dairlib-plate-balancing-example branch 3 times, most recently from cff8615 to 0ff39d9 Compare July 9, 2025 17:55
@Meow404 Meow404 marked this pull request as ready for review July 9, 2025 18:01
@Meow404 Meow404 changed the title [WIP] feat(plate-balancing) : Support plate-balancing example in dairlib feat(plate-balancing) : Support plate-balancing example in dairlib Jul 9, 2025
@Meow404 Meow404 requested a review from xuanhien070594 July 9, 2025 18:02
@Meow404 Meow404 force-pushed the stephen/dairlib-plate-balancing-example branch from 0ff39d9 to 207d6ab Compare July 10, 2025 16:18
@xuanhien070594
Copy link
Copy Markdown
Contributor

multibody/geom_geom_collider.cc line 197 at r5 (raw file):

  if (num_friction_directions < 1) {
    // Planar contact: basis is constructed from the contact and planar normals.
    return ComputePlanarForceBasis(-query_result.signed_distance_pair.nhat_BA_W,

Should we add few lines in documentation to tell the user which forces we are calculating (i.e forces that object A acts on object B or object B acts on object A)?

@xuanhien070594
Copy link
Copy Markdown
Contributor

multibody/geom_geom_collider.cc line 197 at r5 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

Should we add few lines in documentation to tell the user which forces we are calculating (i.e forces that object A acts on object B or object B acts on object A)?

Since you're using minus sign here, it seems that we're calculating the forces that object A acting on object B.

@Meow404 Meow404 force-pushed the stephen/dairlib-plate-balancing-example branch from 1ab4ccd to b1d6983 Compare April 1, 2026 19:44
Copy link
Copy Markdown
Collaborator Author

@Meow404 Meow404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Meow404 made 1 comment and resolved 5 discussions.
Reviewable status: 14 of 52 files reviewed, 10 unresolved discussions (waiting on alinasarmiento and xuanhien070594).


core/c3.cc line 461 at r6 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

I think we should skip storing QP results if QP fails to solve, since failed solves often give extreme large numbers. It is not safe for downstream usage.

What behavior do you think makes sense?
In particular i'm not sure what behavior is expected when the user tried to get a solution

@xuanhien070594
Copy link
Copy Markdown
Contributor

core/c3.cc line 461 at r6 (raw file):

Previously, Meow404 (Thomas Stephen Felix) wrote…

What behavior do you think makes sense?
In particular i'm not sure what behavior is expected when the user tried to get a solution

I think if the QP fails to give solution, we can set the x solutions to current state of the robot, and u solutions to 0. If doing this, we need a few lines in the document to explain the expected behaviors. What do you think?

@xuanhien070594
Copy link
Copy Markdown
Contributor

core/c3_options.h line 79 at r7 (raw file):

  std::vector<double> g_lambda;
  std::vector<double> g_u;
  std::vector<double> g_eta_vector;

Sorry, I forgot why do we need g_eta_vector and u_eta_vector.

@xuanhien070594
Copy link
Copy Markdown
Contributor

multibody/contact_evaluator.h line 141 at r7 (raw file):

  Eigen::Matrix<double, Eigen::Dynamic, 3> CalcForceBasis(
      const drake::systems::Context<T>& context) const override {
    // For planar contact, pass num_friction_directions = 0 to trigger planar

I thought num_friction_directions=1 for planar contact?

@xuanhien070594
Copy link
Copy Markdown
Contributor

systems/test/generators_test.cc line 371 at r7 (raw file):

}  // namespace test
}  // namespace systems
}  // namespace c3

missing end line

xuanhien070594
xuanhien070594 previously approved these changes Apr 8, 2026
Copy link
Copy Markdown
Contributor

@xuanhien070594 xuanhien070594 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have a few comments. Otherwise, :lgtm:

@xuanhien070594 partially reviewed 50 files and all commit messages, made 1 comment, and resolved 8 discussions.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on alinasarmiento and Meow404).

Copy link
Copy Markdown
Collaborator Author

@Meow404 Meow404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Meow404 made 4 comments.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on alinasarmiento and xuanhien070594).


core/c3.cc line 461 at r6 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

I think if the QP fails to give solution, we can set the x solutions to current state of the robot, and u solutions to 0. If doing this, we need a few lines in the document to explain the expected behaviors. What do you think?

Done.


core/c3_options.h line 79 at r7 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

Sorry, I forgot why do we need g_eta_vector and u_eta_vector.

Done.


multibody/contact_evaluator.h line 141 at r7 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

I thought num_friction_directions=1 for planar contact?

Planar contact means only the direction normal to contact plane, no friction directions are included.


systems/test/generators_test.cc line 371 at r7 (raw file):

Previously, xuanhien070594 (Hien Bui) wrote…

missing end line

Done.

@Meow404 Meow404 requested a review from xuanhien070594 April 8, 2026 18:25
Copy link
Copy Markdown
Contributor

@xuanhien070594 xuanhien070594 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@xuanhien070594 reviewed 6 files and all commit messages, made 1 comment, and resolved 5 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on alinasarmiento).

@Meow404 Meow404 merged commit 223b60f into main Apr 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug (?) with counting contacts in lcs_factory_options.h Merge Outstanding plate-balancing C3 Pull Request Plate-balancing example

2 participants