You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using your code as base of a robot specific plugin. I've realized that you are doing a share_ptr dynamic conversion between BasePtr and ModelPtr. I think you have to avoid that. It generates dangerous memory issues.
I think you sould change:
"""
physics::BasePtr b1 = this->world->ModelByName(model1);
if (b1 == NULL){
ROS_ERROR_STREAM(model1 << " model was not found");
return false;
}
ROS_DEBUG_STREAM("Casting into ModelPtr");
physics::ModelPtr m1(dynamic_cast<physics::Model*>(b1.get()));
j.m1 = m1;
"""
Directly to
"""
physics::ModelPtr m1 = this->world->ModelByName(model1);
if(!m1){ROS_ERROR_STREAM(model1 << " model was not found");
return false;
"""
If you do not have a list of attached joints, the pluging would delete the module, because of the BasePtr shared_pointer.
The text was updated successfully, but these errors were encountered:
Hello Miguel,
Feel free to file a PR with the change if it works the same for you :) I
won't be able to look into it up until the end of August as I'm finishing
my thesis. But I'm keen to improve it!
When I wrote this plugin I lacked (not that I do know much more now) a lot
of understanding about how the Gazebo plugin system worked. And I needed
something hacky that worked. I'm sorry if the quality of the code offended
you!
On Thu, Jul 30, 2020, 22:48 Miguel Hernando ***@***.***> wrote:
I'm using your code as base of a robot specific plugin. I've realized that
you are doing a share_ptr dynamic conversion between BasePtr and ModelPtr.
I think you have to avoid that. It generates dangerous memory issues.
I think you sould change:
"""
physics::BasePtr b1 = this->world->ModelByName(model1);
if (b1 == NULL){
ROS_ERROR_STREAM(model1 << " model was not found");
return false;
}
ROS_DEBUG_STREAM("Casting into ModelPtr");
physics::ModelPtr m1(dynamic_cast<physics::Model*>(b1.get()));
j.m1 = m1;
"""
Directly to
"""
physics::ModelPtr m1 = this->world->ModelByName(model1);
if(!m1){ROS_ERROR_STREAM(model1 << " model was not found");
return false;
"""
If you do not have a list of attached joints, the pluging would delete the
module, because of the BasePtr shared_pointer.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#13>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANEK5CLVO57KXLGBSWM7FLR6FT2LANCNFSM4PNVNXSQ>
.
I'm using your code as base of a robot specific plugin. I've realized that you are doing a share_ptr dynamic conversion between BasePtr and ModelPtr. I think you have to avoid that. It generates dangerous memory issues.
I think you sould change:
"""
physics::BasePtr b1 = this->world->ModelByName(model1);
"""
Directly to
"""
physics::ModelPtr m1 = this->world->ModelByName(model1);
if(!m1){ROS_ERROR_STREAM(model1 << " model was not found");
return false;
"""
If you do not have a list of attached joints, the pluging would delete the module, because of the BasePtr shared_pointer.
The text was updated successfully, but these errors were encountered: