YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
Sensor.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Yet Another Software Suite
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#pragma once
5
6#include <wpi/hal/Value.h>
7
8#include <functional>
9#include <optional>
10#include <string>
11#include <unordered_map>
12#include <vector>
13#include <wpi/hal/SimDevice.hpp>
14
16
18class SimSensorConfig;
19}
20
22
68class Sensor {
69 public:
76 Sensor(std::string sensorName, std::vector<SensorData> fields);
77
80
81 // ---- Field access -----------------------------------------------------------
82
84 SensorData& GetField(const std::string& name);
85 const SensorData& GetField(const std::string& name) const;
86
87 double GetAsDouble(const std::string& name) const;
88 int GetAsInt(const std::string& name) const;
89 bool GetAsBoolean(const std::string& name) const;
90 int64_t GetAsLong(const std::string& name) const;
91
93 HAL_SimDeviceHandle GetDevice() const;
94
95 // ---- Trigger injection ------------------------------------------------------
96
98 void AddSimTrigger(const std::string& field, HAL_Value value, std::function<bool()> trigger);
99
100 private:
101 std::string m_sensorName;
102 std::optional<HAL_SimDeviceHandle> m_simDevice;
103 std::unordered_map<std::string, SensorData> m_simData;
104};
105
106} // namespace yams::motorcontrollers::simulation
Definition SimSensorConfig.hpp:29
HAL_SimDeviceHandle GetDevice() const
SensorData & GetField(const std::string &name)
void AddSimTrigger(const std::string &field, HAL_Value value, std::function< bool()> trigger)
int GetAsInt(const std::string &name) const
const SensorData & GetField(const std::string &name) const
Sensor(std::string sensorName, std::vector< SensorData > fields)
double GetAsDouble(const std::string &name) const
int64_t GetAsLong(const std::string &name) const
bool GetAsBoolean(const std::string &name) const
Sensor(const yams::mechanisms::config::SimSensorConfig &cfg)
Definition ArmConfig.hpp:17
Definition SimSensorConfig.hpp:15