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

Mnaveau/use shared pointer #2

Merged
merged 18 commits into from
Apr 6, 2021
Merged

Conversation

MaximilienNaveau
Copy link
Contributor

Description

Modify the API to use std::shared_ptr. This should prevent potential memory missuses.

How I Tested

I import the python bindings and tested the addresses.
TODO test on a real robot!

I fulfilled the following requirements

  • All new code is formatted according to our style guide (for C++ run clang-format, for Python, run flake8 and fix all warnings).
  • All new functions/classes are documented and existing documentation is updated according to changes.
  • No commented code from testing/debugging is kept (unless there is a good reason to keep it).

@MaximilienNaveau MaximilienNaveau added the enhancement New feature or request label Feb 19, 2021
@MaximilienNaveau MaximilienNaveau self-assigned this Feb 19, 2021
@MaximilienNaveau
Copy link
Contributor Author

@Lhumd and @jviereck can I ask you guys to test the python bindings on solo12?
There is a demos/demo_solo12 file implemented by @jviereck that should work.

Can you let me know?

@jviereck
Copy link
Contributor

Thanks for your changes @MaximilienNaveau .

After compiling and sourcing the workspace, I am getting this error:

$ ipython
In [1]: run demo_solo12.py
if_name: enp5s0f1
Using Ethernet (enp5s0f1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/dev/blmc_testing/workspace/src/odri_control_interface/demos/demo_solo12.py in <module>
     23 # Read the values once here. The returned values are views on the data and
     24 # update after the call to `robot.parse_sensor_data()`.
---> 25 imu_attitude = robot.imu.attitude_euler
     26 positions = robot.joints.positions
     27 velocities = robot.joints.velocities

TypeError: No Python class registered for C++ class std::shared_ptr<odri_control_interface::IMU>

@MaximilienNaveau
Copy link
Contributor Author

Ok I know what the problem is

@MaximilienNaveau
Copy link
Contributor Author

MaximilienNaveau commented Feb 20, 2021

This commit should fix the issue, sorry that was a dumb mistake.
Let me know when you have the chance to check this back

@MaximilienNaveau
Copy link
Contributor Author

@jviereck @Lhumd this is finally mature, can you take look at the code an see if I didn't do something too crazy?
Thanks

@Lhumd
Copy link
Member

Lhumd commented Mar 3, 2021

@jviereck @Lhumd this is finally mature, can you take look at the code an see if I didn't do something too crazy?
Thanks

There is a problem with reading IMU data and I think it comes from here. It would be better to have a successful test on Bolt and then merge it.

Copy link
Contributor

@jviereck jviereck left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

Did you check if the code works with the python bindings/python examples? Should I try it on the real robot?

double safety_damping
);
JointModules(const std::shared_ptr<MasterBoardInterface>& robot_if,
ConstRefVectorXi motor_numbers,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you check if the python bindings work? I had troubles when I wanted to use the integers before as it looks like the python binding was expecting long as type. That's why I implemented the motor_numbers as RefVectorX[l] before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok you should try it and let me know if the python bindings are working or not.
If not I will provide a setter/accessor for VectorXl in the python bindings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The yaml parsing goes well and the objects are returned properly in python at least.
I am checking the construction of the robot by hand.

@jviereck
Copy link
Contributor

jviereck commented Mar 4, 2021

Trying the latest branch, I am getting this error now:

In [1]: run demo_solo12_from_yaml.py
if_name: enp5s0f1
Using Ethernet (enp5s0f1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/dev/blmc_testing/workspace/src/odri_control_interface/demos/demo_solo12_from_yaml.py in <module>
     32 # update after the call to `robot.parse_sensor_data()`.
     33 imu_attitude = robot.imu.attitude_euler
---> 34 positions = robot.joints.positions
     35 velocities = robot.joints.velocities
     36 

TypeError: No to_python (by-value) converter found for C++ type: Eigen::Ref<Eigen::Matrix<double, -1, 1, 0, -1, 1> const, 0, Eigen::InnerStride<1> >

@MaximilienNaveau
Copy link
Contributor Author

@jviereck can you check again?

@jviereck
Copy link
Contributor

jviereck commented Mar 5, 2021

With the above change (see last commit from me) I am able to run the python example on the real robot!

@MaximilienNaveau
Copy link
Contributor Author

Cool, python bindings are working, hence we need to figure out why the imu is buggy on bolt.

@jviereck
Copy link
Contributor

jviereck commented Mar 7, 2021

hence we need to figure out why the imu is buggy on bolt.

Shall this PR be merged already or do you want to figure out what's the problem on bolt first?

@MaximilienNaveau
Copy link
Contributor Author

I want to know if the imu behavior comes from the master_board_sdk or the odri, investigation happens here:
open-dynamic-robot-initiative/bolt#5

@MaximilienNaveau
Copy link
Contributor Author

MaximilienNaveau commented Apr 6, 2021

Things work fine on bolt Debug and Release!
So I think we should merge and fix further bugs with additional PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants