Skip to content

Commit

Permalink
Fix getCollisionItems method (issue #165)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdm-dev committed Jan 31, 2025
1 parent f4bd3e2 commit a52eb34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions C++/robodk_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2863,22 +2863,19 @@ int RoboDK::Collision(Item item1, Item item2){
return ncollisions;
}

QList<Item> RoboDK::getCollisionItems(QList<int> link_id_list)
{
QList<Item> RoboDK::getCollisionItems(QList<int>& link_id_list) {
link_id_list.clear();
QList<Item> itemList;

_check_connection();
_send_Line("Collision Items");
_send_Line("Collision_Items");
int nitems = _recv_Int();
QList<Item> itemList = QList<Item>();
if (!link_id_list.isEmpty()){
link_id_list.clear();
}
for (int i = 0; i < nitems; i++){
itemList.reserve(nitems);
link_id_list.reserve(nitems);
for (int i = 0; i < nitems; i++) {
itemList.append(_recv_Item());
int linkId = _recv_Int();
if (!link_id_list.isEmpty()){
link_id_list.append(linkId);
}
int collisionTimes = _recv_Int();
link_id_list.append(_recv_Int());
_recv_Int(); // Number of objects it is in collisions with (unused)
}
_check_status();
return itemList;
Expand Down
2 changes: 1 addition & 1 deletion C++/robodk_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ class ROBODK RoboDK {
/// </summary>
/// <param name="link_id_list">List of robot link IDs that are in collision (0 for objects and tools).</param>
/// <returns>List of items that are in a collision state.</returns>
QList<Item> getCollisionItems(QList<int> link_id_list);
QList<Item> getCollisionItems(QList<int>& link_id_list);

/// <summary>
/// Sets the current simulation speed. Set the speed to 1 for a real-time simulation. The slowest speed allowed is 0.001 times the real speed. Set to a high value (>100) for fast simulation results.
Expand Down

0 comments on commit a52eb34

Please sign in to comment.