Results 1 to 5 of 5

Thread: Reading Wrong Position Values from AX-12 (C++)

  1. Reading Wrong Position Values from AX-12 (C++)

    Hi All,

    I'm reading the wrong current pos values from my AX-12s. (Pan and tilt) It keeps spitting back the same value (- 52.17, +52.17) Even though I'm able to send it commands and move it.

    Any ideas what could be wrong? My code for reading pos is as follows:

    get_position(int id){

    struct DXL_inst_packet instPacket;
    struct DXL_status_packet statPacket;
    instPacket.id = id;
    instPacket.length = 4; /* Read length */
    instPacket.instruction = INST_READ;
    instPacket.address = P_PRESENT_POSITION_L;
    instPacket.parameter[0]= 2; /* I want to read two bytes */

    send_packet(&instPacket);

    if(read_packet(&statPacket)!=-1)
    {
    int position_read_from_servo_hex = ((statPacket.parameter[1]<<8)| statPacket.parameter[0]);
    if(id==PAN_ID)
    return ((position_read_from_servo_hex-CENTRE_HEX_PAN)*POSITION_HEX_xTHIS_GIVES_POSITION_ RADIANS); // Return radians
    else if(id==TILT_ID)
    return ((position_read_from_servo_hex-CENTRE_HEX_TILT)*POSITION_HEX_xTHIS_GIVES_POSITION _RADIANS); // Return radians
    }
    return -1;
    }

    Any help would be much appreciated! I'm using Ubuntu to compile all this

    Thanks again!

  2. #2

    Re: Reading Wrong Position Values from AX-12 (C++)

    I would suspect the code for read_packet, rather than the code that picks the packet apart. Did that come from the library, or did you write that?
    If it's from the library, does it need something to know how big a packet to receive? Just passing in a random pointer seems... dangerous, but I don't know the Dynamixel stuff specifically.

  3. Re: Reading Wrong Position Values from AX-12 (C++)

    Hi,

    I didn't write the read_packet code, it was written by other people on the project, but I think it might have been pulled from a library. And yes, I tell it the packet length. I went through the code and there's nothing wrong with read_packet.

    This code was initially built for RX series and I'm using it with AX dynamixels. Maybe there's some key difference that I'm missing?

    Any ideas would be appreciated.

    Cheers

  4. #4
    Join Date
    Sep 2010
    Location
    ಠ_ಠ
    Posts
    2,258
    Images
    27
    Rep Power
    273

    Re: Reading Wrong Position Values from AX-12 (C++)

    Quote Originally Posted by robotpanda View Post
    I went through the code and there's nothing wrong with read_packet.
    How do you know? Have you successfully retrieved values from other registers? All else fails, try using the Robotis dynamixel SDK instead of your homebrewed version.

    Quote Originally Posted by robotpanda View Post
    This code was initially built for RX series and I'm using it with AX dynamixels. Maybe there's some key difference that I'm missing?
    The only difference is in the electrical specs of the UART comms (half-duplex RS-485 instead of half-duplex 5V 'TTL').

    Have you tried returning the retrieved value as an integer instead of a float (just return the raw values instead of the conversion to radians)? I have had some problems in the past with inconsistent/bogus output when casting signed/unsigned integers to floating point (avr-gcc).
    Please pardon the pedantry... and the profanity... and the convoluted speech pattern...
    "You have failed me, Brain!"
    bleh

  5. Re: Reading Wrong Position Values from AX-12 (C++)

    Okay, so now it works, and all I've done is plug it into a different USB port and unplug other USB accessories. I'm pretty baffled too, any explanation as to how this happened would be awesome.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Bioloid Dynamixels stuck reading 1023 or 0 rotational values
    By coasterman in forum Humanoids, Walkers & Crawlers
    Replies: 0
    Last Post: 01-13-2012, 07:31 PM
  2. Question(s) Reading Dynamixel's position in Wheel Mode
    By pauljurczak in forum DYNAMIXEL & Robot Actuators
    Replies: 3
    Last Post: 10-28-2011, 03:04 PM
  3. Bioloid something wrong with bioloid
    By imay in forum Humanoids, Walkers & Crawlers
    Replies: 19
    Last Post: 02-10-2010, 03:02 AM
  4. Question(s) Whats wrong with my python code?
    By ROBOTMAN in forum Software and Programming
    Replies: 8
    Last Post: 02-21-2009, 08:30 PM
  5. Bioloid I have no idea what I'm doing wrong!
    By The Doctor in forum Humanoids, Walkers & Crawlers
    Replies: 7
    Last Post: 07-08-2008, 03:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •