-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathprimitive_executor.h
More file actions
75 lines (66 loc) · 2.58 KB
/
primitive_executor.h
File metadata and controls
75 lines (66 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
#include "proto/primitive.pb.h"
#include "proto/robot_status_msg.pb.h"
#include "proto/tbots_software_msgs.pb.h"
#include "software/ai/navigator/trajectory/bang_bang_trajectory_1d_angular.h"
#include "software/ai/navigator/trajectory/trajectory_path.h"
#include "software/geom/vector.h"
#include "software/time/duration.h"
#include "software/world/robot_state.h"
#include "software/world/team_types.h"
class PrimitiveExecutor
{
public:
/**
* Constructor
* @param robot_constants The robot constants for the robot which uses this primitive
* executor
*/
explicit PrimitiveExecutor(const robot_constants::RobotConstants& robot_constants);
/**
* Update primitive executor with a new Primitive
* @param primitive_msg The primitive to start
*/
void updatePrimitive(const TbotsProto::Primitive& primitive_msg);
/**
* Update primitive executor with the state of the robot
*
* @param state The current robot state
*/
void updateState(const RobotState& state);
/**
* Steps the current primitive and returns a direct control primitive with the
* target wheel velocities
*
* @param status The status of the primitive executor, set to false if current
* primitive is a Stop primitive
* @param delta_time The elapsed time since the last primitive step
*
* @returns DirectControlPrimitive The direct control primitive msg
*/
std::unique_ptr<TbotsProto::DirectControlPrimitive> stepPrimitive(
TbotsProto::PrimitiveExecutorStatus& status, Duration delta_time);
private:
/*
* Compute the next target linear _local_ velocity the robot should be at.
* @returns Vector The target linear _local_ velocity
*/
Vector getTargetLinearVelocity();
/*
* Returns the next target angular velocity the robot
*
* @returns AngularVelocity The target angular velocity
*/
AngularVelocity getTargetAngularVelocity();
RobotState state_;
TbotsProto::Primitive current_primitive_;
Duration time_since_trajectory_creation_;
robot_constants::RobotConstants robot_constants_;
std::optional<TrajectoryPath> trajectory_path_;
std::optional<BangBangTrajectory1DAngular> angular_trajectory_;
// Estimated delay between a vision frame to AI processing to robot executing
static constexpr double VISION_TO_ROBOT_DELAY_S = 0.03;
// The distance away from the destination at which we start dampening the velocity
// to avoid jittering around the destination.
static constexpr double MAX_DAMPENING_VELOCITY_DISTANCE_M = 0.05;
};