hku-mars/IKFoM

add interface to supprt get sub state's index

youzhenxing opened this issue · 2 comments

is there possible to support get sub state's index in states vector, here is examples that commly use:
define states vector x = [vec3(p),so3(q),vec3(vel),vec(extrisic_p), so3(extrinsic_q)]

if I want to operate substates vel, the code fowlling is bound to the absolute position of sub states in states vector
x[6] = *;x[7]=*,x[8]=
but, if there is an interface to get sub state index, the code above do not have any changes when I change the states ordering,like:
x[x.vel.start_index()] = *;x[x.vel.start_index() + 1]=*,x[x.vel.start_index() + 2]=
as getting sub state is a very common operation, when I change the states ordering, too much code related to states index have to be changed and very easy got into trouble.

I found the solution that already support: x.vel.IDX

Dear @youzhenxing

I hope this message finds you well. I've been working on a piece of code where I have defined a state, say x, which is composed of a number of components such as SO3, vect, and S2. I'm attempting to access the state using an index. However, when I try to do so, I'm encountering an error that I can't seem to resolve.

The error is: no match for operator[](operand types are state_ikfom and int). I'm fairly certain that the index I'm using doesn't exceed the size of the state. From what I understand, it seems like the state_ikfom object doesn't support index-based access.

Seeing as you seem to have had success with accessing the state using an index, I was wondering if you might be able to shed some light on this issue. Specifically, how were you able to implement index-based access for your state? Also, if you have any suggestions on how I might resolve this error, I would greatly appreciate your input.

Thank you for your time, and I look forward to hearing from you.

Best Regards,