-
Notifications
You must be signed in to change notification settings - Fork 13
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
jazzy-dev #20
base: main
Are you sure you want to change the base?
jazzy-dev #20
Conversation
LitheshSari
commented
Oct 22, 2024
- modify CMakelists.txt to support source-build Mujoco, in this case, ENV_PATH is not necessarily added to bash file manually.
- In ros2-control Jazzy, the function load_urdf is removed from resource manager, so robot_desciprtion callback is used to get robot urdf.
- support imu and test it in the diff_drive demo.
1. add the MJResourceManager class. 2. the robot_description is now read from topic. 3. fix the controller configuration failure. 4. modify CMakeLists to support the source-build mujoco.
1. modify the demo launch.py
1. IMU support 2. modify MJCF and URDF for demos 3. fix a typo in CMakeLists.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, firstly thank you for your effort. i actually am not maintainer of this repository and i have no knowledge about controller_interface. But i have wanted to review your PR. If my review does'nt make sense to you (and @sangteak601 ), just ignore this. Btw i think it's better to divide this PR into sub PRs (for instance: Imu added, upgrated to jazzy etc.) but it's definitely not problem at the moment. The last word definitely belongs to @sangteak601
Edit: pre-commit would fit well for this PR.
mujoco_ros2_control/include/mujoco_ros2_control/mujoco_ros2_control.hpp
Outdated
Show resolved
Hide resolved
1. return value in main function; 2. format in .gitignore; 3. modify the construction function of `MujocoRos2Control`.
1. use destructor to handle the release of the rendering resource; 2. allocate the mj_data and mj_model in RM member method(not in constructor) and deallocate them in destructor.
1. rewrite the sensors, they are now inherited from SensorBase class; 2. fix the bugs of FTSensor example.
stop_cm_thread_ = true; | ||
cm_executor_->remove_node(controller_manager_); | ||
cm_executor_->cancel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether we need this variable. with cancel
method, you can finalize spin
method's execution. Corresponding Documentation
mj_deleteModel(mujoco_model); | ||
|
||
return 1; | ||
RCLCPP_INFO(node->get_logger(), "Mujoco Sim Stop ..."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rclcpp::shutdown may be good practice here.
mjModel* mj_model_ = nullptr; | ||
mjData* mj_data_ = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To move this initializations to constructor's initialization section may be good. Because in case you try to copy this object, mj_model will not be copied [link]. In the future, this may turn back with trouble in debugging phase. What do you think?
mj_deleteModel(mj_model_); | ||
mj_deleteData(mj_data_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to check if mj_model
is null or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionaly, if we are freeing some memory, nullify address to avoid dangling reference (if mj_deleteModel itself doesn't do it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly, thank you for your patient.
I made some nitpick comments. However, the important review here is that your PR throws out segmentation fault when i close the rendering window. I have tried to find it yesterday, unfortunately i am yet to find the bug. If i find it, i will write.
I have tried to change the definition order of some variables inside MujocoRos2Control
like below. (In your PR, executor crashes)
rclcpp::executors::MultiThreadedExecutor::SharedPtr cm_executor_;
std::shared_ptr<controller_manager::ControllerManager> controller_manager_;
But IMO, in destructor of unique ptr, std::default_delete cannot find MujocoSystemInterface
's destructor. This is my backtrace.
Additionaly, you should also modify dockerfile to upgrade jazzy. I use this dockerfile Don't hesitate to use it in your PR: ) Finally would you add xacro
with exec_depend
tag? Thus it can be installed automatically.
EDIT: My hardware_interface
version is 4.18.0
. which version do you use? If your PR doesn't throw out segfault, it may be related to version difference.
Oops, I use EDIT: #0 0x00007ffff79af284 in hardware_interface::ResourceManager::~ResourceManager() () from /opt/ros/jazzy/lib/libhardware_interface.so
#1 0x00005555555ac697 in mujoco_ros2_control::MJResourceManager::~MJResourceManager (this=0x5555559a6b90, __in_chrg=<optimized out>) at /home/colcon_ws/src/mujoco_ros2_control/mujoco_ros2_control/src/mujoco_ros2_control.cpp:58
#2 mujoco_ros2_control::MJResourceManager::~MJResourceManager (this=0x5555559a6b90, __in_chrg=<optimized out>) at /home/colcon_ws/src/mujoco_ros2_control/mujoco_ros2_control/src/mujoco_ros2_control.cpp:58
#3 0x00007ffff7f637a1 in ?? () from /opt/ros/jazzy/lib/libcontroller_manager.so
#4 0x00007ffff7f63925 in ?? () from /opt/ros/jazzy/lib/libcontroller_manager.so
#5 0x000055555557dc5e in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release_last_use (this=0x555555b31aa0) at /usr/include/c++/13/bits/shared_ptr_base.h:175
#6 std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release_last_use_cold (this=0x555555b31aa0) at /usr/include/c++/13/bits/shared_ptr_base.h:199
#7 0x0000555555582f81 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x55555575b900, __in_chrg=<optimized out>) at /usr/include/c++/13/bits/shared_ptr_base.h:1071
#8 std::__shared_ptr<controller_manager::ControllerManager, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x55555575b8f8, __in_chrg=<optimized out>) at /usr/include/c++/13/bits/shared_ptr_base.h:1524
#9 std::shared_ptr<controller_manager::ControllerManager>::~shared_ptr (this=0x55555575b8f8, __in_chrg=<optimized out>) at /usr/include/c++/13/bits/shared_ptr.h:175
#10 mujoco_ros2_control::MujocoSimROS2ControlPluginPrivate::~MujocoSimROS2ControlPluginPrivate (this=0x55555575b8c0, __in_chrg=<optimized out>) at /home/pan/colcon_ws/src/mujoco_ros2_control/mujoco_ros2_control/src/mujoco_ros2_control.cpp:9
#11 std::default_delete<mujoco_ros2_control::MujocoSimROS2ControlPluginPrivate>::operator() (this=<optimized out>, __ptr=0x55555575b8c0) at /usr/include/c++/13/bits/unique_ptr.h:99
#12 std::default_delete<mujoco_ros2_control::MujocoSimROS2ControlPluginPrivate>::operator() (__ptr=0x55555575b8c0, this=<optimized out>) at /usr/include/c++/13/bits/unique_ptr.h:93
#13 std::unique_ptr<mujoco_ros2_control::MujocoSimROS2ControlPluginPrivate, std::default_delete<mujoco_ros2_control::MujocoSimROS2ControlPluginPrivate> >::~unique_ptr (this=0x7fffffffa5a8, __in_chrg=<optimized out>) at /usr/include/c++/13/bits/unique_ptr.h:404
#14 mujoco_ros2_control::MujocoRos2Control::~MujocoRos2Control (this=0x7fffffffa270, __in_chrg=<optimized out>) at /home/colcon_ws/src/mujoco_ros2_control/mujoco_ros2_control/src/mujoco_ros2_control.cpp:141
#15 0x000055555557d4a6 in main (argc=<optimized out>, argv=<optimized out>) at /home/colcon_ws/src/mujoco_ros2_control/mujoco_ros2_control/src/mujoco_ros2_control_node.cpp:50 Looks like the code of part |
Hello @LitheshSari , sorry for turning back to you lately, i have solved bug, now we can end process without segfault but i have no idea about how it crashes and my solution is not proper solution. Just to debug better. I've removed plugin loader from code and all segfaults are fixed. Here is my changes. Just to inform you. Unfortunately i have not so much time to go dive into it at the moment(but i may go dive into it in my free times), but please don't hesitate to tag me in any updates Sincerely, C. EDIT: I found something here. But i have still no solution for this. (e.g. i cannot create unique_ptr with custom_deleter function)
|
@LitheshSari Thank you for your contribution, and I apologize for the delayed response. Overall, it looks good, but I think it will be better to divide this into multiple smaller PRs. I will work on this and request your review. |