Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a more convenient option to create a reference frame #48

Open
calvertdw opened this issue Jul 25, 2022 · 0 comments
Open

Add a more convenient option to create a reference frame #48

calvertdw opened this issue Jul 25, 2022 · 0 comments

Comments

@calvertdw
Copy link
Member

calvertdw commented Jul 25, 2022

For when you need a lot of frames and you don't care too much what the name is and you just want to make sure each one is unique. I suggest just putting the calling classname and an index. I've been using a ThreadLocal MutableInt for this, but maybe a global AtomicInteger is better.

import org.apache.commons.lang3.mutable.MutableInt;
import us.ihmc.euclid.referenceFrame.ReferenceFrame;
import us.ihmc.euclid.referenceFrame.tools.ReferenceFrameTools;
import us.ihmc.euclid.transform.RigidBodyTransform;

public static ThreadLocal<MutableInt> INDEX = ThreadLocal.withInitial(MutableInt::new);
public static String getCallingClassName()
{
   StackTraceElement callerStackElement = new Throwable().getStackTrace()[2];
   return callerStackElement.getClassName();
}
public static ReferenceFrame constructFrameWithUnchangingTransformFromParent(ReferenceFrame parentFrame, RigidBodyTransform transformFromParent)
{
   return ReferenceFrameTools.constructFrameWithUnchangingTransformFromParent(getCallingClassName() + INDEX.get(),
                                                                              parentFrame,
                                                                              transformFromParent);
}
public static ReferenceFrame constructFrameWithUnchangingTransformToParent(ReferenceFrame parentFrame, RigidBodyTransform transformToParent)
{
   return ReferenceFrameTools.constructFrameWithUnchangingTransformToParent(getCallingClassName() + INDEX.get(),
                                                                            parentFrame,
                                                                            transformToParent);
}
public static ReferenceFrame constructFrameWithChangingTransformFromParent(ReferenceFrame parentFrame, RigidBodyTransform transformFromParent)
{
   return ReferenceFrameTools.constructFrameWithChangingTransformFromParent(getCallingClassName() + INDEX.get(),
                                                                            parentFrame,
                                                                            transformFromParent);
}
public static ReferenceFrame constructFrameWithChangingTransformToParent(ReferenceFrame parentFrame, RigidBodyTransform transformToParent)
{
   return ReferenceFrameTools.constructFrameWithChangingTransformToParent(getCallingClassName() + INDEX.get(),
                                                                          parentFrame,
                                                                          transformToParent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant