2023-Robot
Robot code for 2023 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
config_types.h
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <string_view>
8
9namespace argos_lib {
13 enum struct RobotInstance {
16 };
17
24
25 struct CANAddress {
27 std::string_view busName;
28
29 CANAddress() = delete;
30 constexpr CANAddress(int address, const std::string_view& busName = "rio") : address(address), busName(busName) {}
31 };
32
38 static inline int GetCANAddr(const argos_lib::CANAddress& compAddress,
39 const argos_lib::CANAddress& practiceAddress,
40 argos_lib::RobotInstance instance) {
41 return instance == argos_lib::RobotInstance::Competition ? compAddress.address : practiceAddress.address;
42 }
43
49 static inline std::string_view GetCANBus(const argos_lib::CANAddress& compAddress,
50 const argos_lib::CANAddress& practiceAddress,
51 argos_lib::RobotInstance instance) {
52 return instance == argos_lib::RobotInstance::Competition ? compAddress.busName : practiceAddress.busName;
53 }
54
55} // namespace argos_lib
Definition addresses.h:11
Definition swap_controllers_command.h:12
static int GetCANAddr(const argos_lib::CANAddress &compAddress, const argos_lib::CANAddress &practiceAddress, argos_lib::RobotInstance instance)
Gets integer address from CANAddress objects based on robot instance.
Definition config_types.h:38
RobotInstance
Differentiates between practice robot and competition robot.
Definition config_types.h:13
@ Competition
Competition robot.
@ Practice
Practice robot.
RobotInstance GetRobotInstance()
Detect robot instance.
Definition robot_instance.cpp:11
static std::string_view GetCANBus(const argos_lib::CANAddress &compAddress, const argos_lib::CANAddress &practiceAddress, argos_lib::RobotInstance instance)
Gets std::string_view bus name from CANAddress objects based on robot instance.
Definition config_types.h:49
Definition config_types.h:25
int address
Definition config_types.h:26
constexpr CANAddress(int address, const std::string_view &busName="rio")
Definition config_types.h:30
std::string_view busName
Definition config_types.h:27