xArm-Developer / xArm-CPLUS-SDK

C++ SDK for UFACTORY robots, 850, xArm5/6/7, and Lite6.
https://www.ufactory.cc/
BSD 3-Clause "New" or "Revised" License
41 stars 28 forks source link

Record Trajectory #4

Closed rjs5327 closed 2 years ago

rjs5327 commented 4 years ago

So i am having difficulties with the record trajectory, I have modified the code to c# and know the state and mode portion is working since i can move the robot and operate regular. But i want to allow for a person to move robot and teach positions. So from what i read in the limited documentation is that state =0 and mode =2 but when i set to that the robot is stiff and fights back when trying to move.

In the manual it shows not available but in the src/wrapper/api.cc file you show it in use as mode 2 so what is going on there?

vimior commented 4 years ago

For the trajectory, you can refer to example/3002-record_trajectory.cc and example/3003-playback_trajectory.cc in the routine

rjs5327 commented 4 years ago

So I

Connect XArmAPI *arm = new XArmAPI(port);

wait and clear errors sleep_milliseconds(500); if (arm->error_code != 0) arm->clean_error(); if (arm->warn_code != 0) arm->clean_warn();

enable and setup like i was doing regular move arm->motion_enable(true); arm->set_mode(0); arm->set_state(0); sleep_milliseconds(500);

Clear errors and set to mode 2 arm->reset(true); arm->set_mode(2); <= Right here is set to mode 2 that should make arm movable but it does not. arm->set_state(0); ret = arm->start_record_trajectory(); // I tried this but it made no difference.

I want to put in mode 2 and be able to move to a position i dont need to record for say. I just need the coordinates in respect to the robot joint angles. Since the inverse trajectory does not work.

vimior commented 4 years ago
  1. Set the state every time you switch modes
  2. Mode 2 is to enter the manual drag mode, this mode can not be exercised through the API
  3. If you want to control the movement through the API, you must switch to mode 0
  4. You can get the current Cartesian position through the get_position interface or directly read the attribute position
  5. You can get the current joint position through the get_servo_angle interface or directly read the angles property
rjs5327 commented 4 years ago

Exactly. So when i : arm->reset(true); arm->set_mode(2); <= Right here is set to mode 2 that should make arm movable but it does not. arm->set_state(0);

the arm should go to drag mode which i can move by hand. But the arm is solid like motors are holding back since the brakes have slop and it is very tight meaning motors are engaged. If i do mode 0 and state 0 i can send a angle command or xyz command and the arm moves fine. So what i want to do is move arm by hand, save joint angles, move next position and save joint angles and so on. Then repeat the joint angles but i am looking to do that in software since inverse kinematics is broke. And i will be saving the setups in my oversight software.

In the programming manual it states state 2 is not available at moment. xarm studio does not communicate on port 502 modbus. it is using some other port since i sniffed it with wire shark to look into the issue. I have confirmed my packets are being generated in accordance to the programming manual. If you would like i can give you the hex commands (packets) by line and you can show me where im wrong. Problem with the XYZ movements is the robot does not handle a complex move well and will go joint speed exceeded. but if i make exact same move with move joint command it moves fast with no problems. So i am looking to abandon xyz movement unless it is a small move.

vimior commented 4 years ago
  1. xarmstudio does not directly use port 502
  2. Are you using the package according to the agreement or using the SDK directly?
  3. You can try xarmstudio first to see if you can use drag and drop mode
rjs5327 commented 4 years ago

Xarm studio works fine.

I translated the C++ to C# since i dont know how to bring the API in. So I can make everything work except for the drag mode and fw and rev kinematics. The fw and rev kinematics is a documented issue that ustudio acknowledges. The state function has to be working and packets have to be working fine since i can set the arm to move. and handle those moves. I follow the programming guide packet construction and send it to the socket.

I tried it both synchronous and asynchronous. So that leads me to that the arm does not like code 2 for drag. I can try to build and send from a PLC but your modbus protocol is not the IEEE. The packet construction is slightly different. I know this because before i wrote the SCADA driver for the robot. I tried hitting it directly with a modbus sender. And i got illegal character alarms.

What aggrement do you speak of?

rjs5327 commented 4 years ago

Command looks like this
MainID , Follow ID, 00, 02, Length[1], length[0], regester, DATA

00,0A,00,02,00,02,13,02

Length is 2 not 1 due to the protocol the manual calls out is Register plus Data so since regester is u8 that is 1 byte meaning +1.

vimior commented 4 years ago

I compared it, the data sent should be normal, can you capture the reply content of the command, and can I see the test program?