TraveSim Adapters  0.1
Protobuf adapters for TraveSim project
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
robot_state.cpp
Go to the documentation of this file.
1 /**
2  * @file robot_state.cpp
3  *
4  * @brief Robot state data structure
5  *
6  * @author Lucas Haug <lucas.haug@thunderatz.org>
7  *
8  * @date 04/2021
9  */
10 
11 #include <iomanip>
14 
15 namespace travesim {
16 /*****************************************
17  * RobotState Related
18  *****************************************/
19 
21 }
22 
23 RobotState::RobotState(Vector2D position, double angular_position, Vector2D velocity, double angular_velocity,
24  bool is_yellow, int id) :
25  EntityState(position, angular_position, velocity, angular_velocity) {
26  this->is_yellow = is_yellow;
27  this->id = id;
28 }
29 
30 RobotState::RobotState(EntityState* entity_state, bool is_yellow, int id) :
31  EntityState(entity_state->position,
32  entity_state->angular_position,
33  entity_state->velocity,
34  entity_state->angular_velocity) {
35  this->is_yellow = is_yellow;
36  this->id = id;
37 }
38 
39 std::ostream& operator <<(std::ostream& output, const RobotState& robot_state) {
40  output << std::fixed << std::setprecision(PRINTING_DECIMAL_PRECISION);
41 
42  output << "TEAM YELLOW: " << robot_state.is_yellow << std::endl;
43  output << "ROBOT ID: " << robot_state.id << std::endl;
44 
45  output << "POSITION: ";
46  output << robot_state.position << " | ";
47  output << "THETA: "<< std::setw(PRINTING_MIN_WIDTH) << robot_state.angular_position << std::endl;
48 
49  output << "VELOCITY: ";
50  output << robot_state.velocity << " | ";
51  output << "THETA: "<< std::setw(PRINTING_MIN_WIDTH) << robot_state.angular_velocity << std::endl;
52 
53  return output;
54 }
55 }
RobotState()
Construct a new Robot State object.
Definition: robot_state.cpp:20
double angular_velocity
Angular velocity in rad/s.
Vector2D velocity
Velocity in m/s.
Common constants and types for the data structures.
Data structure to hold a two dimensional vector.
Robot state data structure.
Data structure to hold the state of a robot in the simulation.
Definition: robot_state.hpp:23
double angular_position
Angular position in radinans.
Vector2D position
Position in meters.
#define PRINTING_DECIMAL_PRECISION
Definition: data_common.hpp:22
std::ostream & operator<<(std::ostream &output, const ReplacerConfigurer &repl_conf)
bool is_yellow
Public attributes.
Definition: robot_state.hpp:64
Data structure to hold the state of a entity in the simulation.
#define PRINTING_MIN_WIDTH
Printing output configuration constants.
Definition: data_common.hpp:21