Giter VIP home page Giter VIP logo

Comments (9)

8035mpg avatar 8035mpg commented on July 18, 2024 1

Okay, that worked. My emergency stop command in multi-turn mode is simply:

//give stop command in multi-turn mode
dxl_wb.itemWrite(ID, "Goal_Position", dxl_wb.itemRead(ID, "Present_Position"));

Thanks again for your help. I think you can go ahead and close this issue.

from opencm9.04.

OpusK avatar OpusK commented on July 18, 2024

Hi, @8035mpg.

First, the function you are using is not recommended.
Maybe you are using the old code. We recommend that you use the Arduino IDE and the latest firmware version.

Going back to the code, I think the return type of the readWord() function is unsigned.
Therefore, signed casting is required (int16_t).
And can I see the code that sets "multi turn mode"? It seems that multi turn mode is not activated and can not go down from zero.

from opencm9.04.

8035mpg avatar 8035mpg commented on July 18, 2024

I'm using the OpenCM IDE. I'll go download and install the Arduino IDE and give it a try. Can you give me the link to documentation on the different functions available with Arduino IDE for commanding dynamixels (like "readWord", "writeByte", etc.)?

Also, I tried casting the output of Dxl.readWord() to "int16_t" and got a compile error. Here's a screenshot:
typecastcompileerror

The code that sets multi-turn mode is as follows:

//set to multi-turn mode
Dxl.writeWord(ID, 6, 4095); //set CW angle limit
Dxl.writeWord(ID, 8, 4095); //set CCW angle limit
SerialUSB.println("Multi-turn Mode");

from opencm9.04.

8035mpg avatar 8035mpg commented on July 18, 2024

Also, if 'Dxl.readWord()' is not recommended, what can I use instead?

from opencm9.04.

OpusK avatar OpusK commented on July 18, 2024

You can refer to e-Manual for new APIs.

from opencm9.04.

8035mpg avatar 8035mpg commented on July 18, 2024

Ok, I changed over to Arduino IDE and it is now able to read negative positions. But two questions about the new API.
(1) I noticed in the examples that they always write this at the beginning:

//setup comm with OpenCM9.04 board
#if defined(__OPENCM904__)
  #define DEVICE_NAME "1" //Dynamixel on Serial1(USART1)  <-OpenCM9.04
#elif define(__OPENCR__)
  #define DEVICE_NAME ""
#endif

This is not necessary, right? I am assuming I don't have to do this and can just write:

#define SERIAL1 1

dxl_wb.begin(SERIAL1, 57600);

(2) What is the purpose of this line of code? Is it even necessary?:

dxl_wb.ping(ID);

For reference, here is an excerpt of the output when moving from positive position values to negative position values after I got it to work with Arduino IDE and APIs:

Position: 1171, Goal: -7000
Position: 1101, Goal: -7000
Position: 1027, Goal: -7000
Position: 960, Goal: -7000
Position: 891, Goal: -7000
Position: 820, Goal: -7000
Position: 750, Goal: -7000
Position: 675, Goal: -7000
Position: 608, Goal: -7000
Position: 539, Goal: -7000
Position: 466, Goal: -7000
Position: 396, Goal: -7000
Position: 323, Goal: -7000
Position: 256, Goal: -7000
Position: 186, Goal: -7000
Position: 115, Goal: -7000
Position: 45, Goal: -7000
Position: -27, Goal: -7000
Position: -95, Goal: -7000
Position: -163, Goal: -7000
Position: -234, Goal: -7000
Position: -303, Goal: -7000
Position: -377, Goal: -7000
Position: -444, Goal: -7000
Position: -514, Goal: -7000
Position: -585, Goal: -7000
Position: -655, Goal: -7000
Position: -729, Goal: -7000
Position: -796, Goal: -7000
Position: -866, Goal: -7000
Position: -938, Goal: -7000

And here are the parts of the code that set the dynamixel mode and print out the position and goal values:

  //set to multi-turn mode
  dxl_wb.itemWrite(ID, "CW_Angle_Limit", 4095); //CW limit
  dxl_wb.itemWrite(ID, "CCW_Angle_Limit", 4095); //CCW limit
  dxl_wb.itemWrite(ID, "Moving_Speed", 500); //set speed
  //move to new goal within while loop
  dxl_wb.itemWrite(ID, "Goal_Position", goal);
  while ( abs(goal - dxl_wb.itemRead(ID, "Present_Position")) > 50 )
  {
    Serial.print("Position: ");
    Serial.print(dxl_wb.itemRead(ID, "Present_Position"));
    Serial.print(", Goal: ");
    Serial.println(dxl_wb.itemRead(ID, "Goal_Position"));
  }

from opencm9.04.

OpusK avatar OpusK commented on July 18, 2024

(1) You can use it in your own way, but it must be a string. (e.g., "1", "2", "3")

(2) You can check the communication status with DXL through Ping command. Since the bool type is returned, the connection status can be checked by return value. (Similar to the function of Ping in Network)

And thank you for providing your code for reference :)

from opencm9.04.

8035mpg avatar 8035mpg commented on July 18, 2024

How do I give a STOP command when the Dynamixel is turning in multi-turn mode (before it reaches the goal position)? I cannot set the speed to '0' because '0'-speed means maximum speed in multi-turn mode.

from opencm9.04.

OpusK avatar OpusK commented on July 18, 2024

If you want to stop at a certain position, you should change "Goal Position" to that value.
Therefore, you should monitor the current position value and set the "Goal Position" to the desired value or the position value indicated by the current position.

from opencm9.04.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.