Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion C#/API/IRoboDk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,16 @@ IItem AddCurve(Mat curvePoints, IItem referenceObject = null, bool addToRef = fa
/// <summary>
/// Returns the list of pairs of items that are in a collision state. This call will run a check for collisions if collision checking is not activated (if SetCollisionActive is set to Off).
/// </summary>
/// <returns></returns>
/// <returns>List of items that are in a collision state</returns>
List<CollisionPair> GetCollisionPairs();

/// <summary>
/// Returns the list of pairs of items that are in the collision map.
/// Items that are not visible will still be included, regardless of the "Include hidden objects" option.
/// </summary>
/// <returns>List of items that are in the collision map</returns>
List<CollisionPair> CollisionActivePairList();

/// <summary>
/// Set the simulation speed. A simulation speed of 5 (default) means that 1 second of simulation
/// time equals to 5 seconds in a real application. The slowest speed ratio allowed is 0.001.
Expand Down
17 changes: 11 additions & 6 deletions C#/API/Model/InstructionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,27 @@



using System;

namespace RoboDk.API.Model
{
// Instruction types
public enum InstructionType
{
Invalid = -1,
Move = 0,
Movec = 1,
Changespeed = 2,
Changeframe = 3,
Changetool = 4,
Changerobot = 5,
MoveC = 1,
ChangeSpeed = 2,
ChangeFrame = 3,
ChangeTool = 4,
ChangeRobot = 5,
Pause = 6,
Event = 7,
Code = 8,
Print = 9
Print = 9,
Rounding = 10,
IO = 11,
Custom = 12
}
}

19 changes: 19 additions & 0 deletions C#/API/RoboDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,25 @@ public List<CollisionPair> GetCollisionPairs()
return list_items;
}

/// <inheritdoc />
public List<CollisionPair> CollisionActivePairList()
{
check_connection();
send_line("Collision_GetPairList");
int nitems = rec_int();
List<CollisionPair> list_items = new List<CollisionPair>(nitems);
for (int i = 0; i < nitems; i++)
{
IItem item1 = rec_item();
int id1 = rec_int();
IItem item2 = rec_item();
int id2 = rec_int();
CollisionPair collisionPair = new CollisionPair(item1, id1, item2, id2);
list_items.Add(collisionPair);
}
check_status();
return list_items;
}

/// <inheritdoc />
public void SetSimulationSpeed(double speed)
Expand Down
25 changes: 25 additions & 0 deletions C#/Example/RoboDKSampleProject/RoboDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,9 @@ public RDKException(string Message)
public const int INS_TYPE_EVENT = 7;
public const int INS_TYPE_CODE = 8;
public const int INS_TYPE_PRINT = 9;
public const int INS_TYPE_ROUNDING = 10;
public const int INS_TYPE_IO = 11;
public const int INS_TYPE_CUSTOM = 12;

// Move types
public const int MOVE_TYPE_INVALID = -1;
Expand Down Expand Up @@ -3934,6 +3937,28 @@ public List<Item> CollisionItems(List<int> link_id_list = null)
return item_list;
}

/// <summary>
/// Returns the list of pairs of items that are in the collision map.
/// Items that are not visible will still be included, regardless of the "Include hidden objects" option.
/// </summary>
/// <returns>List of items that are in the collision map</returns>
public List<Tuple<Item, Item, int, int>> CollisionActivePairList()
{
_check_connection();
_send_Line("Collision_GetPairList");
int nitems = _recv_Int();
List<Tuple<Item, Item, int, int>> list_items = new List<Tuple<Item, Item, int, int>>(nitems);
for (int i = 0; i < nitems; i++)
{
Item item1 = _recv_Item();
int id1 = _recv_Int();
Item item2 = _recv_Item();
int id2 = _recv_Int();
list_items.Add(new Tuple<Item, Item, int, int>(item1, item2, id1, id2));
}
_check_status();
return list_items;
}

/// <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
39 changes: 39 additions & 0 deletions C++/robodk_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3196,6 +3196,45 @@ int RoboDK::Collision(Item item1, Item item2)
return ncollisions;
}

/// <summary>
/// Returns the pairs of objects that are currently in a collision state.
/// </summary>
/// <param name="item1">List of the first colliding objects</param>
/// <param name="item2">List of the second colliding objects</param>
/// <param name="id1">List of Joint IDs for the first colliding objects</param>
/// <param name="id2">List of Joint IDs for the second colliding objects</param>
void RoboDK::CollisionActivePairList(QList<Item>& item1, QList<Item>& item2, QList<int>& id1, QList<int>& id2)
{
_check_connection();
_send_Line("Collision_GetPairList");
int nitems = _recv_Int();

item1.clear();
item2.clear();
id1.clear();
id2.clear();

item1.reserve(nitems);
item2.reserve(nitems);
id1.reserve(nitems);
id2.reserve(nitems);

for (int i = 0; i < nitems; ++i)
{
item1.append(_recv_Item());
id1.append(_recv_Int());
item2.append(_recv_Item());
id2.append(_recv_Int());
}

_check_status();
}

/// <summary>
/// Return the list of items that are in a collision state. This function can be used after calling Collisions() to retrieve the items that are in a collision state.
/// </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> RoboDK::getCollisionItems(QList<int>& link_id_list)
{
link_id_list.clear();
Expand Down
21 changes: 20 additions & 1 deletion C++/robodk_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,16 @@ class ROBODK RoboDK {
/// <returns>0 if no collisions are found.</returns>
int Collision(Item item1, Item item2);

/// <summary>
/// Returns the pairs of objects that are currently in the collision map.
/// Items that are not visible will still be included, regardless of the "Include hidden objects" option.
/// </summary>
/// <param name="item1">List of the first colliding objects</param>
/// <param name="item2">List of the second colliding objects</param>
/// <param name="id1">List of Joint IDs for the first colliding objects</param>
/// <param name="id2">List of Joint IDs for the second colliding objects</param>
void CollisionActivePairList(QList<Item>& item1, QList<Item>& item2, QList<int>& id1, QList<int>& id2);

/// <summary>
/// Return the list of items that are in a collision state. This function can be used after calling Collisions() to retrieve the items that are in a collision state.
/// </summary>
Expand Down Expand Up @@ -1406,7 +1416,16 @@ class ROBODK RoboDK {
INS_TYPE_CODE = 8,

/// Display message on the teach pendant.
INS_TYPE_PRINT = 9
INS_TYPE_PRINT = 9,

/// Rounding instruction.
INS_TYPE_ROUNDING = 10,

/// Set or Wait I/O instruction.
INS_TYPE_IO = 11,

/// Custom instruction.
INS_TYPE_CUSTOM = 12
};

/// Movement types
Expand Down