Pass additional inputs to controller callback

Discussion in 'Priority support' started by Isaac, Aug 2, 2019.

  1. Hello,
    I have a class for my robot and want to use it in my controller callback. How can I do that? I mean is it possible to pass other variables or objects into controller callback? I saw in another question that somebody suggested using mjdata.userdata but I don't know how to pass an object with it.
    Last edited: Aug 2, 2019
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    In general, passing C++ objects from/to shared libraries cannot be done directly. Instead you can convert a C++ object pointer to void*, copy it in mjData.userdata (keep in mind a pointer takes 8 bytes) and then in your callback convert void* back to a C++ object pointer.
    Isaac likes this.