Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unrelated python and c++ examples with the same name #2377

Closed
ZeinBarhoum opened this issue Aug 17, 2024 · 3 comments
Closed

unrelated python and c++ examples with the same name #2377

ZeinBarhoum opened this issue Aug 17, 2024 · 3 comments

Comments

@ZeinBarhoum
Copy link

Bug description

In the Overview page of pinocchio. The overview-urdf.cpp and overview-urdf.py are completely unrelated. This causes a false impression that doing in c++ what's in python is complicated while it is NOT (especially taking into account the complexity of the existing c++ code for newcomers).

Expected behavior

I understand that the overview can include examples of different functionalities in different languages, but the fact that 1) first examples in the page are identical in functionalities between c++ and python, and 2) the existing urdf-examples have the same identical name , make it expected that they both do the same.
A simple code like this in c++ can be used for example to replicate the python code.

#include "pinocchio/algorithm/joint-configuration.hpp"
#include "pinocchio/algorithm/kinematics.hpp"
#include "pinocchio/multibody/fwd.hpp"
#include "pinocchio/parsers/urdf.hpp"

#ifndef PINOCCHIO_MODEL_DIR
#define PINOCCHIO_MODEL_DIR "path_to_the_model_dir"
#endif

int main(int argc, char **argv) {
  // You should change here to set up your own URDF file or just pass it as an
  // argument of this example.
  std::string model_path;
  if (argc < 2) {
    model_path = PINOCCHIO_MODEL_DIR
        "/example-robot-data/robots/ur_description/urdf/ur5_robot.urdf";
  } else {
    model_path = argv[1];
  }

  // Load the urdf model
  pinocchio::Model model;
  pinocchio::urdf::buildModel(model_path, model);
  std::cout << "model name: " << model.name << std::endl;

  // Create data required by the algorithms
  pinocchio::Data data(model);

  // Sample a random configuration
  Eigen::VectorXd q = pinocchio::randomConfiguration(model);
  std::cout << "q: " << q.transpose() << std::endl;

  // Perform the forward kinematics over the kinematic tree
  pinocchio::forwardKinematics(model, data, q);

  // Print out the placement of each joint of the kinematic tree
  for (int i = 0; i < model.names.size(); ++i) {
    std::cout << model.names[i] << " " << data.oMi[i].translation().transpose()
              << std::endl;
  }

  return 0;
}

Sorry if this is not the right place for this comment, I started using pinocchio very recently and it's my first time raising an Issue here.

@ZeinBarhoum
Copy link
Author

Apparently they were the same, check the old one here
The change was made in commit 53272f3

jcarpent added a commit to jcarpent/pinocchio that referenced this issue Aug 25, 2024
@jcarpent
Copy link
Contributor

Thanks, @ZeinBarhoum, for raising this issue and pointing out this inconsistency.
We really appreciate it.
I have just opened this PR (#2384) to fix this issue.

@jcarpent
Copy link
Contributor

Solved via #2384.

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

No branches or pull requests

2 participants