Coordinate control

Coordinate control is to make the robot move to a specified point with a specified posture, which is divided into x, y, z, rx, ry, rz. X, Y, Z represent the position of the robot head in space (the coordinate system is a rectangular coordinate system), and rx, ry, rz represent the posture of the robot head at that point (the coordinate system is an Euler coordinate system).

Single parameter coordinates

Send single parameter coordinates

SendOneCoord(int coord, int value, int speed)
Return value: None
Parameter description: Parameter 1: Coordinate number (1-6 (x, y, z, rx, ry, rz)), Parameter 2: Coordinate (X, Y, Z value range -300-300.00 unit mm RX, RY, RZ, value range -180-180), Parameter 3: Speed ​​(0-100)
Example:
mc.SendOneCoord(1, 160,30);

Multi-parameter coordinates

Get all coordinates

GetCoords()
Return value: Returns int type array, int[], length: 6
Parameter description: None
Example:
var recv = mc.GetCoords();

Send multi-parameter coordinates

SendCoords(int[] coords, int speed, int mode)
Return value: None
Parameter description: Parameter 1: All coordinates (X, Y, Z value range -300-300.00 unit mm RX, RY, RZ, value range -180-180), Parameter 2: Speed ​​(0-100), Parameter 3: Mode (0 - angular, 1 - linear)
Example:
int[] coords = new[] {160, 160, 160, 0, 0, 0};
mc.SendCoords(coords ,30);

Complete Use Case

The program.cs in the project is a complete use case program, which can be modified as needed.
using System;

using System; // Introduce the System namespace, which contains the basic classes and functions commonly used in C# programs, such as Console for console input and output

namespace Mycobot.csharp // Define a namespace Mycobot.csharp to organize related classes
{
class Test // Define a class named Test, which is the main body of the program
{
static void Main(string[] args) // The Main method is the entry point of the program, static means it can be called without creating an instance of the class
{
MyCobot mc = new MyCobot("/dev/ttyUSB0"); // Create an instance of the MyCobot class mc, "/dev/ttyUSB0" is the serial port path for the robot to communicate with the computer
mc.Open(); // Call the Open method of the mc instance to open the connection with the robot

// The following lines of code are commented out, they demonstrate how to set a set of joint angles, wait for a response, and get and print these angles
// int[] angles = new[] {100, 100, 100, 100, 100, 100}; // Create an array of 6 joint angles
// mc.SendAngles(angles, 50); // Call the SendAngles method to send the angle array and speed parameters to the robot
// Thread.Sleep(5000); // Pause the program for 5 seconds and wait for the robot to respond
// var recv = mc.GetAngles(); // Call the GetAngles method to get the current angle from the robot
// foreach (var v in recv) // Traverse the received angle array
// {
// Console.WriteLine(v); // Print each angle to the console
// }

// The following lines of code are also commented out, they demonstrate how to set the coordinates, wait for a response, and get and print these coordinates
// int[] coords = new[] {160, 160, 160, 0, 0, 0}; // Create a coordinate array containing position and direction
// mc.SendCoords(coords, 90, 1); // Call the SendCoords method to send the coordinate array, speed and accuracy parameters to the robot
// Thread.Sleep(5000); // Pause the program for 5 seconds and wait for the robot to respond
// var recv = mc.GetCoords(); // Call the GetCoords method to get the current coordinates from the robot
// foreach (var v in recv) // Traverse the received coordinate array
// {
// Console.WriteLine(v); // Print each coordinate to the console
// }

mc.SendOneAngle(1, 100, 70); // Call the SendOneAngle method to set the angle of the first joint to 100 and the speed to 70

// byte[] setColor = {0xfe, 0xfe, 0x05, 0x6a, 0xff, 0x00, 0x00, 0xfa}; // This line of code is commented out, probably used to set the color of the LED on the robot
mc.Close(); // Call the Close method to close the connection with the robot
}
}
}

results matching ""

    No results matching ""