Initial commit

This commit is contained in:
2026-07-03 16:37:12 +07:00
commit 63b8c1ea8b
1931 changed files with 640587 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using CartographerSharp.Models.Transform;
using RobotNet10.Shared.Numbers;
namespace CartographerSharp.Sensor;
/// <summary>
/// IMU data structure.
/// </summary>
public struct ImuData(long time, Vector3 linearAcceleration, Vector3 angularVelocity)
{
public long Time { get; set; } = time;
public Vector3 LinearAcceleration { get; set; } = linearAcceleration;
public Vector3 AngularVelocity { get; set; } = angularVelocity;
}
/// <summary>
/// Operations on ImuData.
/// </summary>
public static class ImuDataOperations
{
/// <summary>
/// Converts 'imu_data' to a proto::ImuData.
/// </summary>
public static Models.Sensor.ImuData ToProto(ImuData imuData)
{
return new Models.Sensor.ImuData(
imuData.Time,
new Vector3d(imuData.LinearAcceleration.X, imuData.LinearAcceleration.Y, imuData.LinearAcceleration.Z),
new Vector3d(imuData.AngularVelocity.X, imuData.AngularVelocity.Y, imuData.AngularVelocity.Z)
);
}
/// <summary>
/// Converts 'proto' to an ImuData.
/// </summary>
public static ImuData FromProto(Models.Sensor.ImuData proto)
{
return new ImuData(
proto.Timestamp,
new Vector3(proto.LinearAcceleration.X, proto.LinearAcceleration.Y, proto.LinearAcceleration.Z),
new Vector3(proto.AngularVelocity.X, proto.AngularVelocity.Y, proto.AngularVelocity.Z)
);
}
}