Add a more convenient option to create a reference frame
calvertdw opened this issue · comments
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);
}