PDA

View Full Version : Mx28 : Need help to control the goal position.



danyboy
06-18-2013, 09:54 PM
I'm using RS485 serial comm to the dynamixel mx28 servo motor. for the software, im using microsoft visual studio and the source code are in C++.
I need help to control the motor to turn to a certain position.

Th232
06-18-2013, 10:00 PM
Will need more information. Are you having trouble with the code provided in the SDK, are you writing it from scratch, what can you do at the moment with the servo...?

danyboy
06-18-2013, 10:21 PM
im not using the SDK. i wrote it from scratch. Currently, i managed to open to com port and reading the id. I did something like inserting the id,length,instruction,parameters and it will calculate a checksum for me(which is using the instruction packets).

Th232
06-18-2013, 11:44 PM
Just want to confirm one thing, can you use the Dynamixel Wizard to get the servo moving? Just want to make sure that it's definitely something in your code.

Also, is the result of your code just that the servo isn't moving? Posting your code here may also help.

Gertlex
06-19-2013, 02:27 PM
One possible option is to verify that you're sending correct packets with PyDyPackets (https://github.com/erelson/PyDyPackets).

Basically, you would (after cloning the PyDyPackets repo):


Connect computer to a Dynamixel bus (i.e. the RS485 connection) so that your packets are sent back to the computer, and save bytes using PyDyLogger.py (You will also need to create a config file and set the serial port/baud rate)
Feed the output file into PyDyParser.py with various flags (-t -> human readable output)
Read the filtered output file in a text editor

danyboy
06-23-2013, 12:07 AM
Hi all, i have something like this to send the packets.

bool CDynamixelServo::movepos(uint8_t id,uint8_t& data){
mTxBuf[OFFSET_PREAMBLE0]=0xff;
mTxBuf[OFFSET_PREAMBLE1]=0xff;
mTxBuf[OFFSET_ID]=id;
mTxBuf[OFFSET_LENGTH]=6;
mTxBuf[OFFSET_INSTRUCTION]=0x03;
mTxBuf[OFFSET_PAYLOAD+0]=0x1E;
mTxBuf[OFFSET_PAYLOAD+1]=0x02;
mTxBuf[OFFSET_PAYLOAD+1]=0x10;
mTxBuf[OFFSET_PAYLOAD+1]=0x00;
mTxBuf[OFFSET_PAYLOAD+2]=chkSum();

Please advise. Thanks.

Gertlex
06-23-2013, 01:31 AM
There are [ code ] [ /code ] tags.

You're assigning the same byte here multiple times:

mTxBuf[OFFSET_PAYLOAD+1]=0x02;
mTxBuf[OFFSET_PAYLOAD+1]=0x10;
mTxBuf[OFFSET_PAYLOAD+1]=0x00;

And it's not clear why you're setting the two "goal position" bytes, and then setting the low byte for "torque limit"

I think your goal position bytes are backwards too; Putting them in that order is requesting a goal position of 0x1002 = 4098... the maximum acceptable goal position is of course 4096... So you're probably forming a bad packet, too.

danyboy
06-23-2013, 11:32 PM
Thanks all. i think i had solved how to move the position.
Now i need a while loop to read the "moving" address: 0x2E while the motor is moving to a assigned position.

Gertlex
06-23-2013, 11:57 PM
Thanks all. i think i had solved how to move the position.

You should verify this by actually making servos move. Then do the fancier stuff :)

Th232
06-23-2013, 11:59 PM
Now i need a while loop to read the "moving" address: 0x2E while the motor is moving to a assigned position.

I believe this is precisely what's described in the ReadWrite example code. Converting it to C++ should be fairly easy.

danyboy
07-01-2013, 02:42 AM
Thanks all.:wink:
Another problem inverse kinematics. Anybody out there know how it works.

Th232
07-01-2013, 03:16 AM
Bit of a vague question. Anything in particular about it?