timestamped_transform.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2017 The Cartographer Authors
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 
18 
19 namespace cartographer {
20 namespace transform {
21 
23  const TimestampedTransform& end,
24  const common::Time time) {
25  CHECK_LE(start.time, time);
26  CHECK_GE(end.time, time);
27 
28  const double duration = common::ToSeconds(end.time - start.time);
29  const double factor = common::ToSeconds(time - start.time) / duration;
30  const Eigen::Vector3d origin =
31  start.transform.translation() +
32  (end.transform.translation() - start.transform.translation()) * factor;
33  const Eigen::Quaterniond rotation =
34  Eigen::Quaterniond(start.transform.rotation())
35  .slerp(factor, Eigen::Quaterniond(end.transform.rotation()));
36  return TimestampedTransform{time, transform::Rigid3d(origin, rotation)};
37 }
38 
39 } // namespace transform
40 } // namespace cartographer
Rigid3< double > Rigid3d
UniversalTimeScaleClock::time_point Time
Definition: time.h:44
const Quaternion & rotation() const
static time_point time
TimestampedTransform Interpolate(const TimestampedTransform &start, const TimestampedTransform &end, const common::Time time)
const Vector & translation() const
double ToSeconds(const Duration duration)
Definition: time.cc:29


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58