index.js 1016 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // import { YUpLStrategy } from "./strategy-manager/y-up-l-strategy.js";
  2. import { YUpRStrategy } from "./strategy-manager/y-up-r-strategy.js";
  3. const strategies = {
  4. // "y-up-l": YUpLStrategy,
  5. "y-up-r": YUpRStrategy,
  6. };
  7. export class UWB {
  8. constructor({ upAxis, LR, worldPose }) {
  9. this.setStrategy(upAxis + '-'+LR, worldPose);
  10. }
  11. setStrategy(strategyKey, worldPose) {
  12. if (!strategies[strategyKey]) {
  13. throw new Error(`${strategyKey} 策略不存在`);
  14. }
  15. this.currentStrategy = new strategies[strategyKey]();
  16. this.setLocalOriginPose(worldPose);
  17. }
  18. unifiedCoordinateSystem(model) {
  19. if (this.currentStrategy) {
  20. return this.currentStrategy.unifiedCoordinateSystem(model);
  21. }
  22. }
  23. setLocalOriginPose(worldPose) {
  24. if (this.currentStrategy) {
  25. this.currentStrategy.setLocalOriginPose(worldPose);
  26. }
  27. }
  28. convertLocalToWorld(localPosition) {
  29. if (this.currentStrategy) {
  30. return this.currentStrategy.convertLocalToWorld( localPosition);
  31. }
  32. }
  33. }