PDA

View Full Version : [Question(s)] Com between raspberry pi and arbotix m



andyandy26
02-16-2016, 07:14 PM
Hello!

So I've been looking at the communication "protocol" of the virtual commander for the arbotix and found it to be sending 8 bytes of data; a start byte, 6 bytes of info then a checksum for a rough error checking.

I was wondering that for my own program if it was possible to do a similar thing but with 10 bit unsigned integers (18 AX12 servo positions). I'm thinking that to send a 10 bit, I would need 2 bytes. Then I could send 18 * 2 bytes plus a starting bytes(s) and error checking, similar to the virtual commander.

The goal here is for the arbotix to simply act as a servo controller for the AX12s with the RPI doing all of my IK calculations.

I was just wondering as to the feasibility of it as I have little experience with communication and have been using my hexapod as a learning platform (I love it to bits).

Also, would it be possible for the arbotix to also read the servo positions from all the AX12s at the same 60Hz? This is where I am doubting its capabilities due to the baud rate but want a second opinion :)

Thanks for any help! :tongue::veryhappy:

KevinO
02-16-2016, 07:31 PM
You might want to look at how the USB2AX does it. I ended up using that for all my projects that have onboard computers.

Zenta
02-17-2016, 12:42 AM
Hi,
You forgot a ";" in your signature..:tongue:

KurtEck
02-17-2016, 09:28 AM
As Kevin mentioned you can look at how Linux boxes talk to the USB2AX. Likewise to the Arbotix Pro.

Short answer is you are free to setup your communications however you like.

General description of how these servo controllers work:

they basically wait for standard dynamixel serial packets from the host, as described in the Robotis Manuals (http://support.robotis.com/en/techsupport_eng.htm#product/dynamixel/ax_series/dxl_ax_actuator.htm),
Which look like: ff ff <id> <len> <instruction> <params...> <checksum>

The servo controller has it's own id, which for example on the Arbotix Pro or CM-730 is 200. If the message has their ID, it directly responds back to the controller, again using a standard response packet. If the packet is not meant for them, it switches the serial port associated with the AX-Buss to write, echoes the packet out over this serial port, switches back to input and then if it receives any data back from the AX-BUSS, it send that data packet back to the host.

So, if you want the RPI to tell all 18 servos to move to new positions, you can do it several ways, like doing individual writes to each of the 18 servos. Or you can use the SYNC_WRITE command, where you can tell many servos to write new values to some registers (in this case likely goal position) as one command. This is for example what the Phoenix code base uses.

Now how to read in the current position for 18 servos?

Short answer: is you issue Read commands to read the current position for each of the servos.

Longer answer: The answer may depend on how you connect the RPI2 to the Arbotix-M.

If you are doing this through some USB to serial adapter like the FTDI cable, then you run into USB latency issues. I won't go into too much here, but more details up on the Debugging RPI to Arbotix Pro thread (http://forums.trossenrobotics.com/showthread.php?7617-Trying-to-debug-HROS1-with-RPI-talking-to-Arbotix-Pro). To help deal with this, several of these Servo controllers introduced a new packet SYNC_READ, where your RPI issues a request to the controller object, with which register to start retrieving data from and how many bytes, and a list of which servos. The controller issues a READ request to each of the servos in the list, and collects their answers and then responds back to the RPI2 with one USB packet (Actually internally USB may break this up into multiple internal USB packets). So this reduces the USB latency overhead for this...

However if instead of using USB, on the RPI you use the Serial port who has pins on the expansion connector and you setup this Serial port for some high speed like: 1000000, then you may not gain anything using the SYNC_READ approach. I am currently experimenting with this approach for talking to the Arbotix Pro (with some firmware changes I am playing with). Again more details about this in the thread I linked to above.

Not sure how much it would help here, but I am slowly working on an Arduino sketch (https://github.com/KurtE/Teensy_Arbotix_Pro), for one of my own custom boards, where I try to make a Teensy 3.2 act sort of like an Arbotix Pro. Some of the basics are working, like the communications and the like, but I don't have the IMU that I used on the last board setup yet to properly emulate the appropriate logical registers of the Arbotix Pro or CM-730.
Also again I am using a Teensy here. There are parts of it that won't work for the Arbotix, but...

Hope that helps

Kurt

andyandy26
02-17-2016, 08:27 PM
Wow! thanks for the help! As for my setup, I am using the onboard serial on the RPI2 through a logic level converter. I do intend to also use the arbotix for interfacing sensors and the like, thus I may think up my own communication to make it easier to add functionality later. So from what Kurt said, can I use the RPI to 'talk' to the servos directly then? Because that sounds like the way to go to me :veryhappy:

Also, quick question, more to the electrical side but I'm curious about what voltage drops people are getting during load on the servos? I've found it difficult to make a nice "I'm low on power so I'll sit down now" for when the voltage gets low. perhaps the voltage drop is due to the small 2250mAh LiPos... they are 35c though...

Thanks for the very detailed response! ... I always forget to add the ;... lots of headaches from it :rolleyes:

tician
02-18-2016, 02:21 AM
Also, quick question, more to the electrical side but I'm curious about what voltage drops people are getting during load on the servos? I've found it difficult to make a nice "I'm low on power so I'll sit down now" for when the voltage gets low. perhaps the voltage drop is due to the small 2250mAh LiPos... they are 35c though...

The wires connecting the servos are 20AWG at best and the molex connectors are rated 3A. The wires inside the dynamixels connecting the pins of the two connectors together are closer to 24AWG. Since the servos are connected in a daisy chain, the current powering the furthest servo has to pass through each previous cable and servo in the chain. The more servos in the chain, and the higher the load of each previous servo in the chain, then the greater the increase in voltage drop at the later servos. If you are having servo brownouts and/or ID resets, then decreasing the number of servos on the chain is probably your best bet. Can be accomplished by making more direct connections to the hubs (especially of the servos experiencing heaviest loading) and possibly splicing in heavier gauge wires into the standard cables.

KurtEck
02-18-2016, 09:10 AM
As for my setup, I am using the onboard serial on the RPI2 through a logic level converter. I do intend to also use the arbotix for interfacing sensors and the like, thus I may think up my own communication to make it easier to add functionality later. So from what Kurt said, can I use the RPI to 'talk' to the servos directly then? Because that sounds like the way to go to me :veryhappy:

I have not tried this and not sure how easy it would be to do. It may be possible, but there may be complications and the ability may be specific to each processor and/or maybe some external hardware. Others can maybe explain this better than I can, but will give a shot, to describe the things that I would look at:

The AX-Buss is a Half Duplex protocol. So does the underlying USART on the RPI2 support half duplex?

If Yes: how do I control when it is in TX mode and when it is in RX mode. You need it to switch to TX just as you are sending out bytes, and then switch back to RX mode when the last bit of the last byte has been output. Can you detect this? And update state? Can you do this at normal program level or more likely do you need a custom device driver for this? ...

If No or some of the issues of Yes are too much of a pain: You can use external hardware. I believe DFRobot used to sell a unit to do, this, which I tried once. Again here you have several options: Something like shown on the AX or MX servo docs about building an interface, but again you need to control TX/RX lines. There are several places on the web which show how to do this, like:

http://www.instructables.com/id/How-to-drive-Dynamixel-AX-12A-servos-with-a-Raspbe/?ALLSTEPS

But again with the above you need to be able to control an IO pin to set the direction. Don't remember if wiringPi on RPI2 requires you to use sudo to do this (for memory mapped access) or if they have another user mode access...

But if you are again going to external hardware, then maybe better off with a Microcontroller. Need one with at least 2 USARTS... Something like the processor in the Arbotix-M or Arbotix-Pro (or Teensy 3.2)

jwatte
02-18-2016, 11:15 AM
does the underlying USART on the RPI2 support half duplex?

You can do half duplex with a full duplex USART if you can turn the transmitter on or off -- OR if you add a selectable buffer chip, such as the 74HCT125, on the TX line. Most people go for the latter; turn on the buffer/driver (pull the enable low) when transmitting, and pull it back high again when transmission is done.

If you wire the receive and the transmit together (perhaps through the buffer) then you will have to read back the data that you transmit, and you know you can disable the buffer when you've received all the bytes that you sent.

You can also control the input/output and high/low state of GPIO pins on the Raspberry Pi using the sysfs gpio feature!

tician
02-18-2016, 12:41 PM
Another very good reason to use a buffer IC for the full-duplex to half-duplex conversion is that the dynamixel buss is 5V, while the RPi pins are all 3.3V max. Connect the RPi pins directly to the dynamixel buss without any logic level conversion and you will destroy the pins.

jwatte
02-18-2016, 01:30 PM
Pffft! I love the smell of magic smoke! :-)

r3n33
02-18-2016, 03:19 PM
Did someone say magic smoke?

Sniff sniff :p

andyandy26
02-18-2016, 06:49 PM
So, I'm trying to play about a bit, looking at the bioloid and ax12 libraries and trying to figure out what the arbotix would send if it wanted to set servo id 1 to position 512... could someone explain with an example? What is the length variable? Also, is it possible to use the arbotix board as the full-to-half duplex buffer? (as is what would happen if I send these packets from the Pi to the arbotix board)

Kurt gave: ff ff <id> <len> <instruction> <params...> <checksum>
But I'm unsure what ^ ^ ^ should be... I was hoping that I could just set both of the servo's goal position registers (Hi and Lo bytes)

Thus far I've been using a very modified NUKE export... NUKE was great but I'd prefer to try to make my own kinematics engine. (which is why I'm trying to use the Pi as the processor for MOAR SPEED :P)

KurtEck
02-18-2016, 07:31 PM
Side Note:
As you probably already know, I have the full Phoenix code (actually a few different versions) base running on RPI as well as several other Linux boxes. This is in my Raspberry Pi project: https://github.com/KurtE/Raspberry_Pi

As part of this there is a directory: BioloidEx which is a port of the Arduino libraries, to talk to an USB2AX, or, Arbotix Pro, or my Teensy board. Also added support to play through the Serial ports instead of USB...

So with it you have the ability to set the Goal position register and the like the same way as you do in Arduino code...

Again the format of these messages is in the AX manuals.

So if you wish to set the Goal position of 1 servo, example id 1 to 512, the packet would be something like:

ff ff 01 03 1e 00 02 <chksum>

Got to run or would do checksum...

As could you use the Arbotix-M as your converter... Yes totally. As I mentioned I am doing that with a Teensy 3.2.. Although more super set as emulating Arbotix Pro... Again code up at: https://github.com/KurtE/Teensy_Arbotix_Pro
But again there is Teensy specific code here.

Edit: Got back after dinner and found that entered the above packet incorrectly. Forgot to put the length correctly...
Should look something like:
6452

andyandy26
02-18-2016, 11:05 PM
So, I've been looking at the instruction packet seen here: http://support.robotis.com/en/product/dynamixel/communication/dxl_packet.htm
With your example it has really cleared things up for me :)
So am I correct in seeing that the length is: the memory register + a lo byte + a hi byte + 2 = 5? are these the "parameters"?
Thanks for being so helpful :)

KurtEck
02-19-2016, 09:48 AM
Note I personally prefer looking at the other version of the manual, which I think Trossen used to have. I found a copy of the one (or similar) up at: http://www.generationrobots.com/media/Dynamixel-AX-12-user-manual.pdf

The top level description on Instruction and status registers starts at I believe page 10.

If you look at Page 19 in that version, you will see the format of the Write packet:
Where Length is set to number of registers to write plus 3, so we are writing 2 registers, so length = 5

The first parameter is the starting 8 bit register we are writing to. Page 12 has a table showing the different registers for the AX servos.

So to set the current position, you need to set the goal position. The goal position has a range of 0-1023, which will not fit in an 8 bit register, so it requires 2 registers: Register 30 (0x1e), is the goal position low and 31 is the goal position high.

So that is why the above packet shows: Register: 0x1e (Goal low), 2 bytes 0(low), 2(high), which 2*256+0=512

Hope that helps.