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
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.