blob: 9acb49dee416aebd19b4c1deb5c0dc32d2909933 [file] [log] [blame]
Ytai Ben-Tsvi09ad8c92022-01-28 14:19:08 -08001/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include "media/Pose.h"
19
20namespace android {
21namespace media {
22
23/**
24 * Biasing for a stream of poses.
25 *
26 * This filter takes a stream of poses and at any time during the stream, can change the frame of
27 * reference for the stream to be that of the last pose received, via the recenter() operation.
28 *
29 * Typical usage:
30 * PoseBias bias;
31 *
32 * bias.setInput(...);
33 * output = bias.getOutput();
34 * bias.setInput(...);
35 * output = bias.getOutput();
36 * bias.setInput(...);
37 * output = bias.getOutput();
38 * bias.recenter(); // Reference frame is now equal to the last input.
39 * output = bias.getOutput(); // This is now the identity pose.
40 *
41 * There doesn't need to be a 1:1 correspondence between setInput() and getOutput() calls.
42 * The initial bias point is identity.
43 *
44 * This implementation is thread-compatible, but not thread-safe.
45 */
46class PoseBias {
47 public:
48 void setInput(const Pose3f& input);
49
50 void recenter();
51
52 Pose3f getOutput() const;
53
54 private:
55 Pose3f mLastWorldToInput;
56 Pose3f mBiasToWorld;
57};
58
59} // namespace media
60} // namespace android