Skip to content

Commit 1b1ee08

Browse files
Merge pull request #26 from Arastookhajehee/kuka-online
Kuka online to master PR
2 parents 7a9141d + cef15b6 commit 1b1ee08

15 files changed

Lines changed: 2189 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ As of ~~v0.2.5~~ the latest version, Machina works for the following robotic arm
118118
ABB: [========= ] (pretty solid both online and offline)
119119
UR: [======== ] (also quite solid both online and offline)
120120
KUKA: [===== ] (recently launched online mode thanks to @Arastookhajehee! undertested, BE CAREFUL)
121+
(Known KUKA Bug: relative rotations result in unpredictable orientations! Avoid relative rotation!)
121122
```
122123

123124
Other devices are currently under active development.

src/Machina/Compilers/CompilerKUKA.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,8 @@ internal bool GenerateInstructionDeclaration(
812812
/// <returns></returns>
813813
internal string GetPositionTargetValue(RobotCursor cursor)
814814
{
815+
// adjusting the action's rotation to match the KUKA robot's convention
816+
cursor.rotation.RotateLocal(new Rotation(0, 1, 0, 90));
815817
YawPitchRoll euler = cursor.rotation.Q.ToYawPitchRoll(); // @TODO: does this actually work...?
816818

817819
// @TODO: E6POS: External Axes (Arastoo)
@@ -828,6 +830,8 @@ internal string GetPositionTargetValue(RobotCursor cursor)
828830

829831
internal string GetPositionTargetValue_Translation_Only(RobotCursor cursor)
830832
{
833+
// adjusting the action's rotation to match the KUKA robot's convention
834+
cursor.rotation.RotateLocal(new Rotation(0, 1, 0, 90));
831835
YawPitchRoll euler = cursor.rotation.Q.ToYawPitchRoll(); // @TODO: does this actually work...?
832836

833837
// @TODO: E6POS: External Axes (Arastoo)
@@ -867,6 +871,9 @@ internal string GetToolValue(RobotCursor cursor)
867871
throw new Exception("Cursor has no tool attached");
868872
}
869873

874+
// @To Do
875+
// adjusting the action's rotation to match the KUKA robot's convention
876+
//cursor.rotation.RotateLocal(new Rotation(0, 1, 0, 90));
870877
YawPitchRoll euler = cursor.tool.TCPOrientation.Q.ToYawPitchRoll();
871878

872879
return string.Format(CultureInfo.InvariantCulture,

src/Machina/Controllers/StreamControlManager.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ internal override void SetCommunicationObject()
3131
case RobotType.UR:
3232
_control.Driver = new DriverUR(_control);
3333
break;
34-
34+
35+
case RobotType.KUKA:
36+
_control.Driver = new DriverKUKA(_control);
37+
break;
38+
3539
default:
3640
throw new NotImplementedException();
3741
}

src/Machina/Drivers/Communication/Protocols/Base.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ public List<string> GetMessagesForNextAction(RobotCursor cursor)
2626

2727
return GetActionMessages(action, cursor); // this might be null if the action doesn't have a message representation here (e.g. PushSettings, Comment...)
2828
}
29+
//Machina.Drivers.Communication
30+
31+
public List<string> GetMessagesForNextAction_KUKA(RobotCursor cursor, out Action actionObj)
32+
{
33+
Action action;
34+
35+
if (!cursor.ApplyNextAction(out action))
36+
{
37+
actionObj = null;
38+
return null; // cursor buffer is empty
39+
}
40+
actionObj = action;
41+
return GetActionMessages(action, cursor); // this might be null if the action doesn't have a message representation here (e.g. PushSettings, Comment...)
42+
}
2943

3044
/// <summary>
3145
/// Given a (write cursor, apply next Action in the buffer and return a byte[] representation

src/Machina/Drivers/Communication/Protocols/Factory.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ internal static Base GetTranslator(Driver driver)
1818
case RobotType.UR:
1919
return new URCommunicationProtocol();
2020

21+
case RobotType.KUKA:
22+
return new KUKACommunicationProtocol();
23+
2124
default:
2225
throw new NotImplementedException();
2326
}

0 commit comments

Comments
 (0)