Compare commits
4 Commits
74d901cc86
...
15652f7347
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15652f7347 | ||
|
|
f456464f6c | ||
|
|
c9a08c26ea | ||
|
|
5880f967d7 |
@ -214,7 +214,7 @@ public:
|
||||
|
||||
float accelerometerRawToReading(const std::int16_t bit) const
|
||||
{
|
||||
return float(bit) * accel_fs_to_bit_constants_[std::uint32_t(scale_accel_)];
|
||||
return (float(bit) * accel_fs_to_bit_constants_[std::uint32_t(scale_accel_)]) * 9.8f;
|
||||
}
|
||||
|
||||
float gyroRawToReading(const std::int16_t bit) const
|
||||
|
||||
@ -17,6 +17,15 @@
|
||||
namespace Peripherals
|
||||
{
|
||||
|
||||
struct IrSensorsReading
|
||||
{
|
||||
/// Distance as read by the sensor.
|
||||
float distance;
|
||||
|
||||
/// @c true if the @c distance is < the wall threshold.
|
||||
bool sees_object;
|
||||
};
|
||||
|
||||
template<typename G, std::size_t N, std::size_t Average>
|
||||
class IrSensors
|
||||
{
|
||||
@ -61,16 +70,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::array<std::pair<float, bool>, N> getDistanceData()
|
||||
std::array<IrSensorsReading, N> getDistanceData()
|
||||
{
|
||||
std::array<std::pair<float, bool>, N> data;
|
||||
std::array<IrSensorsReading, N> data;
|
||||
|
||||
for (std::size_t i = 0; i < N; i++)
|
||||
{
|
||||
const float interim = averages_[i] - offsets_[i];
|
||||
|
||||
data[i].first = multipliers_[i] * std::pow(interim, exponents_[i]);
|
||||
data[i].second = data[i].first < wall_thresholds_[i];
|
||||
data[i].distance = multipliers_[i] * std::pow(interim, exponents_[i]);
|
||||
data[i].sees_object = data[i].distance < wall_thresholds_[i];
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
@ -8,7 +8,10 @@
|
||||
#ifndef SKULLC_THREADS_ACTOR_HPP_
|
||||
#define SKULLC_THREADS_ACTOR_HPP_
|
||||
|
||||
#include <cmsis_os.h>
|
||||
#include <freertos_os2.h>
|
||||
#include <queue.h>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "threads_primitivethread.hpp"
|
||||
@ -23,7 +26,7 @@ class Actor
|
||||
public:
|
||||
using value_type = T;
|
||||
|
||||
static_assert(std::is_trivially_constructible_v<value_type>, "T must be trivially constructible.");
|
||||
static_assert(std::is_default_constructible_v<value_type>, "T must be default constructible.");
|
||||
static_assert(std::is_trivially_copyable_v<value_type>, "T must be trivially copyable.");
|
||||
|
||||
Actor(const std::uint32_t queue_size, const char* name, const osPriority_t priority, const std::uint32_t stack_size)
|
||||
@ -54,7 +57,7 @@ private:
|
||||
{
|
||||
init();
|
||||
|
||||
value_type data;
|
||||
value_type data{};
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
@ -20,7 +20,8 @@ struct Signallable
|
||||
{
|
||||
using value_type = T;
|
||||
|
||||
static_assert(std::is_trivially_constructible_v<value_type>, "T must be trivially constructible.");
|
||||
static_assert(std::is_trivially_copyable_v<value_type>, "T must be trivially copyable.");
|
||||
static_assert(std::is_default_constructible_v<value_type>, "T must be default constructible.");
|
||||
|
||||
virtual bool emit(const T& t) = 0;
|
||||
virtual std::pair<bool, BaseType_t> emitFromIsr(const T& t) = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user