TinyRobotics
Loading...
Searching...
No Matches
MotionState2D.h
1#pragma once
2#include "TinyRobotics/units/Units.h"
3#include "TinyRobotics/coordinates/Coordinate.h"
4
5namespace tinyrobotics {
6
7/**
8 * @struct Delta2D
9 * @ingroup control
10 * @brief Represents a 2D incremental motion update (dx, dy, dtheta).
11 *
12 * Used for odometry, IMU, and motion estimation to describe the change in position and orientation
13 * over a time step in 2D space.
14 */
15struct Delta2D {
16 float dx;
17 float dy;
18 float dtheta;
19};
20
21/**
22 * @class MotionState2D
23 * @ingroup control
24 * @brief Interface for representing the navigation state of a robot in 2D space.
25 *
26 * Provides access to position, heading (orientation), and speed.
27 */
28/**
29 * @class IMotionState2D
30 * @ingroup control
31 * @brief Interface for representing the navigation state of a robot in 2D space.
32 *
33 * Provides access to position, heading (orientation), and speed.
34 */
35class IMotionState2D : public MessageSource {
36 public:
37 virtual Coordinate<DistanceM> getPosition() const = 0;
38 virtual Angle getHeading() const = 0;
39 virtual Speed getSpeed() const = 0;
40 virtual Transform2D getTransform() const = 0;
41 virtual bool begin(Transform2D transform) = 0;
42 virtual void end() = 0;
43};
44
45/**
46 * @brief Concrete implementation of INavigationState2D for storing and accessing 2D navigation state.
47 *
48 * Holds position, heading, and speed values for a robot in 2D space.
49 */
50class MotionState2D : public IMotionState2D {
51 public:
52 /**
53 * @brief Construct a new NavigationState2D object.
54 * @param position The 2D position (meters).
55 * @param heading The heading/orientation (radians).
56 * @param speed The speed (meters/second).
57 */
58 MotionState2D(const Coordinate<DistanceM>& position, const Angle& heading, const Speed& speed)
59 : position(position), heading(heading), speed(speed) {}
60
61 Coordinate<DistanceM> getPosition() const override { return position; }
62 Angle getHeading() const override { return heading; }
63 Speed getSpeed() const override { return speed; }
64
65 protected:
66 Coordinate<DistanceM> position;
67 Angle heading;
68 Speed speed;
69};
70
71} // namespace tinyrobotics
Represents an angle with unit conversion and wrap-around support.
Definition: Angle.h:42
A generic 3D coordinate class for robotics, navigation, and spatial calculations.
Definition: Coordinate.h:57
Interface for representing the navigation state of a robot in 2D space.
Definition: MotionState2D.h:35
Concrete implementation of INavigationState2D for storing and accessing 2D navigation state.
Definition: MotionState2D.h:50
MotionState2D(const Coordinate< DistanceM > &position, const Angle &heading, const Speed &speed)
Construct a new NavigationState2D object.
Definition: MotionState2D.h:58
Represents a speed measurement with unit conversion support.
Definition: Speed.h:40
Represents a 2D incremental motion update (dx, dy, dtheta).
Definition: MotionState2D.h:15