Skip to content
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

Develop #70

Merged
merged 6 commits into from
Dec 22, 2021
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
27 changes: 13 additions & 14 deletions RASDK.Arm/Hiwin/RoboticArm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace RASDK.Arm.Hiwin
{
public class RoboticArm : RASDK.Arm.RoboticArm
{
private static unsafe bool* _waiting;
private static volatile bool _waiting;
private readonly string _ip;
private int _id;

Expand Down Expand Up @@ -214,12 +214,9 @@ private void WaitForMotionComplete(bool needWait, int returnCode)
{
if (needWait && ReturnCodeCheck.IsSuccessful(returnCode))
{
unsafe
{
*_waiting = true;
while (*_waiting)
{ /* None. */ }
}
_waiting = true;
while (_waiting)
{ /* Do nothing. */ }
}
}

Expand All @@ -229,6 +226,7 @@ private void WaitForMotionComplete(bool needWait, int returnCode)

private static readonly HRobot.CallBackFun _callBackFun = EventFun;

// FIXME: HRobot.network_get_state(_id) always return 0, so Connected always false.
public override bool Connected
{
get
Expand Down Expand Up @@ -263,7 +261,9 @@ public override bool Connect()
ShowUnsuccessfulConnectMessage();
}

return Connected;
// FIXME: HRobot.network_get_state(_id) always return 0, so the Connected always false.
//return Connected;
return true;
}

public override bool Disconnect()
Expand Down Expand Up @@ -292,7 +292,9 @@ public override bool Disconnect()
$"錯誤代碼: {alarmState}";
_message.Show(text, "斷線", MessageBoxButtons.OK, MessageBoxIcon.None);

return !Connected;
// FIXME: HRobot.network_get_state(_id) always return 0, so the Connected always false.
//return !Connected;
return true;
}

private static void EventFun(UInt16 cmd, UInt16 rlt, ref UInt16 Msg, int len)
Expand Down Expand Up @@ -334,11 +336,8 @@ private static void EventFun(UInt16 cmd, UInt16 rlt, ref UInt16 Msg, int len)
$"Coor:{infos[14]},{infos[15]},{infos[16]},{infos[17]},{infos[18]},{infos[19]}\r\n" +
$"Joint:{infos[20]},{infos[21]},{infos[22]},{infos[23]},{infos[24]},{infos[25]}\r\n");

unsafe
{
// Motion state=1: Idle.
*_waiting = (infos[8] != "1");
}
// Motion state=1: Idle.
_waiting = (infos[8] != "1");
break;

case 4011 when rlt != 0:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Robotic Arm SDK

[![dotnet](https://github.com/nfu-irs-lab/robotic-arm-sdk/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/nfu-irs-lab/robotic-arm-sdk/actions/workflows/dotnet.yml?query=branch%3Amain)
[![GitHub release](https://img.shields.io/github/release/nfu-irs-lab/robotic-arm-sdk.svg)](https://github.com/nfu-irs-lab/robotic-arm-sdk/releases)
[![GitHub repo size](https://img.shields.io/github/repo-size/nfu-irs-lab/robotic-arm-sdk)](https://github.com/nfu-irs-lab/robotic-arm-sdk)
[![GitHub issues](https://img.shields.io/github/issues/nfu-irs-lab/robotic-arm-sdk.svg)](https://github.com/nfu-irs-lab/robotic-arm-sdk/issues)

機械手臂 SDK。目前主要支援:
Expand Down