Hello, I am using DYNAMIXEL SDK 3.7.51 with Python, on the Windows 10 operating system. I am using U2D2 USB serial converter.
My motor is XC430-W240. I searched about this issue. I found some suggestions but none of them worked for me.
I have oak camera as well as XC430-W240 motor. I want to have my robot move based on certain coordination given by the camera. Therefore, I extract output from the camera’s function as an input to dynamixel function. Furthermore, I defined the movement function as a thread. this is the code that I am using: movement.py - Google Drive
Issue #1:
everything worked perfectly before coordination detection( getting into Movement() function). then this error message has appeared: NameError: name ‘dynamixel’ is not defined
before getting into this function there is no such an error!
What is the source of this error?
Issue #2:
I want to give the coordination in the degree unit as I did using Arduino. but I couldn’t find the proper way.
At first you used “packetHandler” to access the DXL functions, then you switched to “dynamixel”. You need to decide on which parameter name to use consistently throughout your program.
From this link I saw that their code is using two important statements , see pic below
Where they append one file and import its functions as “dynamixel”. It looks like you need to learn more Python Programming Concepts on your own. This forum is not really set up for teaching Python per se.
You can use such resources as this one for “dxl_goal_position” which is a numerical array:
I saw them too. unfortunately, I couldn’t find this library anywhere.
I don’t want to learn Python. I have been already using it for four years. I didn’t ask about what the array means. I said that: the goal position is only one value, right? I should send one value to the motor to move according to it. That was what I used to send when I worked with Dynamixel Shield and Arduino. My question was: Why is this value here as an array with two values inside? I changed it to an integer and the compiler didn’t accept it.
OK, I think that I have figured out what is going on.
First, the example code as shown in the e-manual and as shared by you in Post 4 IS NO LONGER APPLICABLE - this is the one using dynamixel instead of packetHandler - and this is not the first time that I found that codes listed on the ROBOTIS e-manual website WAS OBSOLETE and DID NOT ALWAYS WORK FOR ME.
The read_write.py example that comes with the SDK 3.7.51 only uses packetHandler, so if you want to use code snippets that contains dynamixel, you’ll have to do a “search & replace” operation on your favorite editor to change “dynamixel” to “packetHandler” in your original program movement.py.
I also see another syntax issue with the way you used dxl_goal_position, first you used it as a simple variable
But later you used it as a list with “index” undefined.
Regarding your question about using “degrees” to set Goal Position like in Arduino: sorry to disappoint you, but the Dynamixel SDK is at the “nuts and bolts” level, so you will have to write your own conversion code from “degrees” to “raw” goal position values [0-4095]. If you look into the source codes of the Dynamixel2Arduino library, you can see how ROBOTIS programmers did it for Arduino, but it is quite involved.
Perhaps you can do some kind of linear mapping function whereas 0 degree corresponds to 0 raw, and 360 degrees corresponds to 4096 raw (and not 4095 - see pictures below captured from Dynamixel Wizard 2).