using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
mc.SendOneAngle(1,20,50); //把一关节移动20,速度50
Thread.Sleep(5000);
mc.Close();
}
}
}
GetAngles()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
var recv = mc.GetAngles();//获取角度信息
foreach (var v in recv)
{
Console.WriteLine(v);
}
mc.Close();
}
}
}
SendAngles()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
mc.SendOneAngle(1,0, 70);
Thread.Sleep(100);
mc.Close();
}
}
}
GetCoords()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
var recv = mc.GetCoords();
foreach (var v in recv)
{
Console.WriteLine(v);
}
Thread.Sleep(100);
mc.Close();
}
}
}
SendCoords()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
int[] coords = new[] {160, 160, 160, 0, 0, 0}; //参数1:坐标,2:速度,3模式
mc.SendCoords(coords, 90, 1);
Thread.Sleep(100);
mc.Close();
}
}
}
SendOneCoord()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
mc.SendOneAngle(1,0, 70);
Thread.Sleep(100);
mc.Close();
}
}
}
SetDigitalOut()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
mc.SetDigitalOut(23, 0);
Thread.Sleep(100);
mc.SetDigitalOut(33, 0);
Thread.Sleep(100);
mc.Close();
}
}
}
GetDigitalIn()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
int num = GetDigitalIn(23);
mc.Close();
}
}
}
setGripperValue()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
mc.SetGripperMode(0);//透传
Thread.Sleep(1000);
mc.setGripperValue(0,10)
mc.Close();
}
}
}
getGripperValue()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
mc.SetGripperMode(0);//透传
Thread.Sleep(1000);
int num = mc.getGripperValue();
mc.Close();
}
}
}
SetBasicOut()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
mc.SetBasicOut(2, 1);
Thread.Sleep(100);
mc.SetBasicOut(5, 1);
Thread.Sleep(100);
mc.SetBasicOut(26, 1);
Thread.Sleep(100);
mc.Close();
}
}
}
GetBasicIn()
using System;
using System.Threading;
namespace Mycobot.csharp
{
class Test
{
static void Main(string[] args)
{
MyCobot mc = new MyCobot("COM57");//树莓派机械臂串口名称:/dev/ttyAMA0
mc.Open();
Thread.Sleep(5000);//windows打开串口后,需要等待5s,Windows打开串口底部basic会重启
int num = mc.GetBasicIn(35);
mc.Close();
}
}
}