Skip to content

Commit 3e03530

Browse files
authored
feat: add new instruction types and CollisionActivePairList method (PR #185)
2 parents d0100bc + d24774d commit 3e03530

File tree

6 files changed

+122
-8
lines changed

6 files changed

+122
-8
lines changed

C#/API/IRoboDk.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,16 @@ IItem AddCurve(Mat curvePoints, IItem referenceObject = null, bool addToRef = fa
554554
/// <summary>
555555
/// 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).
556556
/// </summary>
557-
/// <returns></returns>
557+
/// <returns>List of items that are in a collision state</returns>
558558
List<CollisionPair> GetCollisionPairs();
559559

560+
/// <summary>
561+
/// Returns the list of pairs of items that are in the collision map.
562+
/// Items that are not visible will still be included, regardless of the "Include hidden objects" option.
563+
/// </summary>
564+
/// <returns>List of items that are in the collision map</returns>
565+
List<CollisionPair> CollisionActivePairList();
566+
560567
/// <summary>
561568
/// Set the simulation speed. A simulation speed of 5 (default) means that 1 second of simulation
562569
/// time equals to 5 seconds in a real application. The slowest speed ratio allowed is 0.001.

C#/API/Model/InstructionType.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,27 @@
4040

4141

4242

43+
using System;
44+
4345
namespace RoboDk.API.Model
4446
{
4547
// Instruction types
4648
public enum InstructionType
4749
{
4850
Invalid = -1,
4951
Move = 0,
50-
Movec = 1,
51-
Changespeed = 2,
52-
Changeframe = 3,
53-
Changetool = 4,
54-
Changerobot = 5,
52+
MoveC = 1,
53+
ChangeSpeed = 2,
54+
ChangeFrame = 3,
55+
ChangeTool = 4,
56+
ChangeRobot = 5,
5557
Pause = 6,
5658
Event = 7,
5759
Code = 8,
58-
Print = 9
60+
Print = 9,
61+
Rounding = 10,
62+
IO = 11,
63+
Custom = 12
5964
}
6065
}
6166

C#/API/RoboDK.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,25 @@ public List<CollisionPair> GetCollisionPairs()
12961296
return list_items;
12971297
}
12981298

1299+
/// <inheritdoc />
1300+
public List<CollisionPair> CollisionActivePairList()
1301+
{
1302+
check_connection();
1303+
send_line("Collision_GetPairList");
1304+
int nitems = rec_int();
1305+
List<CollisionPair> list_items = new List<CollisionPair>(nitems);
1306+
for (int i = 0; i < nitems; i++)
1307+
{
1308+
IItem item1 = rec_item();
1309+
int id1 = rec_int();
1310+
IItem item2 = rec_item();
1311+
int id2 = rec_int();
1312+
CollisionPair collisionPair = new CollisionPair(item1, id1, item2, id2);
1313+
list_items.Add(collisionPair);
1314+
}
1315+
check_status();
1316+
return list_items;
1317+
}
12991318

13001319
/// <inheritdoc />
13011320
public void SetSimulationSpeed(double speed)

C#/Example/RoboDKSampleProject/RoboDK.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,9 @@ public RDKException(string Message)
17151715
public const int INS_TYPE_EVENT = 7;
17161716
public const int INS_TYPE_CODE = 8;
17171717
public const int INS_TYPE_PRINT = 9;
1718+
public const int INS_TYPE_ROUNDING = 10;
1719+
public const int INS_TYPE_IO = 11;
1720+
public const int INS_TYPE_CUSTOM = 12;
17181721

17191722
// Move types
17201723
public const int MOVE_TYPE_INVALID = -1;
@@ -3934,6 +3937,28 @@ public List<Item> CollisionItems(List<int> link_id_list = null)
39343937
return item_list;
39353938
}
39363939

3940+
/// <summary>
3941+
/// Returns the list of pairs of items that are in the collision map.
3942+
/// Items that are not visible will still be included, regardless of the "Include hidden objects" option.
3943+
/// </summary>
3944+
/// <returns>List of items that are in the collision map</returns>
3945+
public List<Tuple<Item, Item, int, int>> CollisionActivePairList()
3946+
{
3947+
_check_connection();
3948+
_send_Line("Collision_GetPairList");
3949+
int nitems = _recv_Int();
3950+
List<Tuple<Item, Item, int, int>> list_items = new List<Tuple<Item, Item, int, int>>(nitems);
3951+
for (int i = 0; i < nitems; i++)
3952+
{
3953+
Item item1 = _recv_Item();
3954+
int id1 = _recv_Int();
3955+
Item item2 = _recv_Item();
3956+
int id2 = _recv_Int();
3957+
list_items.Add(new Tuple<Item, Item, int, int>(item1, item2, id1, id2));
3958+
}
3959+
_check_status();
3960+
return list_items;
3961+
}
39373962

39383963
/// <summary>
39393964
/// 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.

C++/robodk_api.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,6 +3196,45 @@ int RoboDK::Collision(Item item1, Item item2)
31963196
return ncollisions;
31973197
}
31983198

3199+
/// <summary>
3200+
/// Returns the pairs of objects that are currently in a collision state.
3201+
/// </summary>
3202+
/// <param name="item1">List of the first colliding objects</param>
3203+
/// <param name="item2">List of the second colliding objects</param>
3204+
/// <param name="id1">List of Joint IDs for the first colliding objects</param>
3205+
/// <param name="id2">List of Joint IDs for the second colliding objects</param>
3206+
void RoboDK::CollisionActivePairList(QList<Item>& item1, QList<Item>& item2, QList<int>& id1, QList<int>& id2)
3207+
{
3208+
_check_connection();
3209+
_send_Line("Collision_GetPairList");
3210+
int nitems = _recv_Int();
3211+
3212+
item1.clear();
3213+
item2.clear();
3214+
id1.clear();
3215+
id2.clear();
3216+
3217+
item1.reserve(nitems);
3218+
item2.reserve(nitems);
3219+
id1.reserve(nitems);
3220+
id2.reserve(nitems);
3221+
3222+
for (int i = 0; i < nitems; ++i)
3223+
{
3224+
item1.append(_recv_Item());
3225+
id1.append(_recv_Int());
3226+
item2.append(_recv_Item());
3227+
id2.append(_recv_Int());
3228+
}
3229+
3230+
_check_status();
3231+
}
3232+
3233+
/// <summary>
3234+
/// 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.
3235+
/// </summary>
3236+
/// <param name="link_id_list">List of robot link IDs that are in collision (0 for objects and tools).</param>
3237+
/// <returns>List of items that are in a collision state.</returns>
31993238
QList<Item> RoboDK::getCollisionItems(QList<int>& link_id_list)
32003239
{
32013240
link_id_list.clear();

C++/robodk_api.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,16 @@ class ROBODK RoboDK {
10681068
/// <returns>0 if no collisions are found.</returns>
10691069
int Collision(Item item1, Item item2);
10701070

1071+
/// <summary>
1072+
/// Returns the pairs of objects that are currently in the collision map.
1073+
/// Items that are not visible will still be included, regardless of the "Include hidden objects" option.
1074+
/// </summary>
1075+
/// <param name="item1">List of the first colliding objects</param>
1076+
/// <param name="item2">List of the second colliding objects</param>
1077+
/// <param name="id1">List of Joint IDs for the first colliding objects</param>
1078+
/// <param name="id2">List of Joint IDs for the second colliding objects</param>
1079+
void CollisionActivePairList(QList<Item>& item1, QList<Item>& item2, QList<int>& id1, QList<int>& id2);
1080+
10711081
/// <summary>
10721082
/// 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.
10731083
/// </summary>
@@ -1406,7 +1416,16 @@ class ROBODK RoboDK {
14061416
INS_TYPE_CODE = 8,
14071417

14081418
/// Display message on the teach pendant.
1409-
INS_TYPE_PRINT = 9
1419+
INS_TYPE_PRINT = 9,
1420+
1421+
/// Rounding instruction.
1422+
INS_TYPE_ROUNDING = 10,
1423+
1424+
/// Set or Wait I/O instruction.
1425+
INS_TYPE_IO = 11,
1426+
1427+
/// Custom instruction.
1428+
INS_TYPE_CUSTOM = 12
14101429
};
14111430

14121431
/// Movement types

0 commit comments

Comments
 (0)