MATLAB API: hx_read_sensors() bug

Discussion in 'HAPTIX' started by Jake George, Jun 19, 2015.

  1. In version 1.0.0, the MATLAB API function hx_read_sensors() is returning an error: "Bad data size."

    I am trying to read joint sensor angles, velocities and contact sensor forces. Before version 1.0.0, I was able to use this function to read in the sensors values as a struct. From there, I could easily select the contact values though the contact field, etc.

    In version 1.0.0 it seems like the only way to access this same data is to use mjhx('get_sensor'). However, the data returned from this function is not indexed in any coherent way, and changes if any fields are added to <sensor> in the .xml file.

    For version 1.0.0, is there a way to use the hx_read_sensors() function from the previous version? Or is there a more consistent and intuitive way to read the values of joint and contact sensors?

    Thanks,
    Jake
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    This is a change that needs to be documented. The standard ("hx_") API was unfortunately designed to have a hidden state, namely the result from the last hx_robot_info call. This is used to determine the correct sizes of all arrays. Previously, this call was made automatically within hx_connect, but that is not a good idea because the user may load a different model without disconnecting/reconnecting. So, call hx_robot_info after hx_connect and again when you load a new model. Reloading the same model does not require this call because the array sizes are the same.
     
  3. That did the trick. Thanks for the quick reply.

    When can we expect the documentation to be updated?
     
    Last edited: Jun 22, 2015
  4. Emo Todorov

    Emo Todorov Administrator Staff Member

    About a week from now. I may post intermediate versions though.