-
Notifications
You must be signed in to change notification settings - Fork 41
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
Integrate bullet into ign-physics3 #208
Conversation
When testing vehicles availables from the subt simulation files, I found that some of those have overlapping parts (by checking the collision model), is this expected from the models? This causes problems with With 55dd0f9 I added a workaround, a collision group for each model, this way links added to the same model won't crash with each other. Although this will work only for .sdf files with a maximum of 31 models in total. |
e864fd9
to
16bc0bc
Compare
With 6742e5d it was added the changes proposed in |
16bc0bc
to
60b50a9
Compare
Codecov Report
@@ Coverage Diff @@
## ign-physics3 #208 +/- ##
================================================
- Coverage 83.27% 74.49% -8.78%
================================================
Files 106 115 +9
Lines 3951 4661 +710
================================================
+ Hits 3290 3472 +182
- Misses 661 1189 +528
Continue to review full report at Codecov.
|
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.
Still reviewing, but so far I see a lot of manual memory management with raw pointers. I think we should generally avoid this in new code unless there is a very specific reason. Is there one in this case?
bullet/src/Base.hh
Outdated
/// GenerateIdentity. | ||
/// 3) Hold explicit copies of raw pointers that can be deallocated | ||
|
||
// todo(anyone): Handle cleaning these pointers |
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 think this should be addressed now. There is a strong chance of leaking these.
I think these could be made std::unique_ptrs
.
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 think the same as you, I think those can be std::unique_ptrs
as well, but I implemented those with std::shared_ptrs
to copy the same pattern used with dart
implementation. I have in this commit in a test branch: Smart pointers.
However, when I add this, the program crashes when it's closed, showing a malloc_consolidate
error. or a free pointer, invalid chunk size
. I think bullet has problem when the things are not deleted in reverse order and there is no guarantee with ignition on its own.
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.
Never mind, I was able to use shared_ptrs
in this PR, take a look to bd154bb. With this I think we've addressed your comments, let me know if this is OK
bullet/src/Base.hh
Outdated
struct LinkInfo | ||
{ | ||
std::string name; | ||
btRigidBody* link; |
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.
If this is the only owner, prefer a smart pointer.
public: using WorldInfoPtr = std::shared_ptr<WorldInfo>; | ||
public: using ModelInfoPtr = std::shared_ptr<ModelInfo>; | ||
public: using LinkInfoPtr = std::shared_ptr<LinkInfo>; | ||
public: using CollisionInfoPtr = std::shared_ptr<CollisionInfo>; | ||
public: using JointInfoPtr = std::shared_ptr<JointInfo>; |
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.
Any reason for shared
vs unique
here?
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.
Those in particular can't be changed because the GenerateIdentity
templated function from ignition takes a shared pointer to generate new identities.
bullet/src/Base.hh
Outdated
} | ||
} | ||
} |
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.
} | |
} | |
} | |
} // namespace bullet | |
} // namespace physics | |
} // namespace ignition |
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.
Added all missing with ab71031
std::unordered_map<std::size_t, LinkInfoPtr>::iterator it = | ||
this->links.begin(); |
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.
std::unordered_map<std::size_t, LinkInfoPtr>::iterator it = | |
this->links.begin(); | |
auto it = this->links.begin(); |
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.
Changed all similar iterators with 607b609
bullet/src/JointFeatures.cc
Outdated
const JointInfoPtr &jointInfo = this->joints.at(_id.id); | ||
const int jointType = jointInfo->constraintType; | ||
// Check the type of joint and act accordignly | ||
if (jointInfo->constraintType == |
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.
Is the intent to handle other constraints? In that case I think a switch makes more sense here.
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.
Yes, I changed it to a switch statement with 7d6d9d2
@mjcarroll There is no specific reason to use raw pointers, thanks for the comments, I'll address them today. |
Added some extra commits:
|
d8e91bc
to
607b609
Compare
@Lobotuerk As this branch does not include smart pointers for memory management (at least yet) I added the missing delete with 607b609 |
Signed-off-by: Jorge Perez <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: claireyywang <[email protected]> Signed-off-by: Ian Chen <[email protected]> Co-authored-by: Ian Chen <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Louise Poubel <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Jorge Perez <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Jorge Perez <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Jorge Perez <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Jorge Perez <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Nate Koenig <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Nate Koenig <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Louise Poubel <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Jorge Perez <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Jorge Perez <[email protected]> Signed-off-by: Tomas Lorente <[email protected]>
Signed-off-by: Tomas Lorente <[email protected]>
371fbea
to
2592a48
Compare
2 approvals, 10/10 checks passing, merging. Thanks a lot to all reviewers! 🚀 |
This PR includes bullet integration into ign-physics, supporting the set of basic features described here:
The following elements are available:
Unit tests are not included in this PR, the elements in this PR were tested with the following example from gazebo4:
shapes.sdf
,joint_controller.sdf
,joint_position_controller.sdf
. Meshes were tested on their own with #178.Revolute joints and ground vehicles were tested with a modified version of
diff_drive.sdf
(replacing the ball joint with a fixed one). And using the subt simulation with the model X1_SENSOR_CONFIG_1. This test was run with the command:ign launch -v4 cave_circuit.ign circuit:=cave worldName:=simple_cave_01 robotName1:=X1 robotConfig1:=X1_SENSOR_CONFIG_1 engine:=bullet
And using this subt fork:
https://github.com/Lobotuerk/subt/tree/bullet_test
.Known issues:
The angle getter from bullet resets its initial count if the angle difference between two consecutive readings is higher than a hardcoded threshold. To address this issue in the joint controllers a threshold in the max torque was set. (An extra eyes into the best approach to address this would be appreciated). Link to the threshold applied in bullet Im talking about.
Fixed joints are not fixing all the possible degrees of freedom, @Lobotuerk ran into this testing flying vehicles.