Skip to content

Temperature Rewrite#150

Open
kshxtij wants to merge 1 commit into
masterfrom
sns-temp
Open

Temperature Rewrite#150
kshxtij wants to merge 1 commit into
masterfrom
sns-temp

Conversation

@kshxtij

@kshxtij kshxtij commented May 5, 2022

Copy link
Copy Markdown
Contributor

#143 rewrite

Adds brakes and suspension temperatures

@kshxtij kshxtij requested a review from mifrandir as a code owner May 5, 2022 11:26
@kshxtij kshxtij requested a review from ishmis May 5, 2022 11:26
@kshxtij kshxtij added the sensors label May 5, 2022
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #150 (90046b0) into master (516a539) will increase coverage by 0.06%.
The diff coverage is 27.27%.

@@            Coverage Diff             @@
##           master     #150      +/-   ##
==========================================
+ Coverage   38.20%   38.27%   +0.06%     
==========================================
  Files          69       69              
  Lines        3942     3977      +35     
==========================================
+ Hits         1506     1522      +16     
- Misses       2436     2455      +19     
Impacted Files Coverage Δ
src/data/data.hpp 100.00% <ø> (ø)
src/sensors/temperature.hpp 100.00% <ø> (ø)
src/sensors/temperature.cpp 8.33% <7.69%> (-8.34%) ⬇️
src/sensors/main.cpp 35.92% <31.70%> (+2.70%) ⬆️
src/debugging/observer.cpp 32.22% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 516a539...90046b0. Read the comment docs.

@mifrandir mifrandir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of things to start with.

// convert to degrees C
double temp = static_cast<double>(raw_value) / 4095;
temp = (temp * 175) - 50;
return static_cast<int8_t>(temp);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a convoluted way of doing this. Is there a datasheet somewhere?
Why not the following?

return std::round(static_cast<double>(raw_value) / 23.4  - 50);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may have to recast the result to make the compiler happy. Actually, we may want to assert that the result is in bounds, e.g. by checking std::numeric_limits<int8_t>::max() or INT8_MAX.

* @param raw_value input voltage
* @return int representation of temperature
*/
static int8_t scaleData(uint8_t raw_value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

data::TemperatureData temperature_data_;
};

class BrakesAndSuspensionTemperature : public ITemperature {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should go into a separate file.


void BrakesAndSuspensionTemperature::run()
{
uint16_t raw_value = pin_.read();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

void Temperature::run()
void AmbientTemperature::run()
{
uint16_t raw_value = pin_.read();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const


using AmbientTemperaturePins = std::array<uint8_t, data::Sensors::kNumAmbientTemp>;
using BrakeTemperaturePins = std::array<uint8_t, data::Sensors::kNumBrakeTemp>;
using BrakeTemperaturePins = std::array<uint8_t, data::Sensors::kNumBrakeSuspensionTemp>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BrakeAndSuspension

Comment thread src/data/data.hpp
static constexpr size_t kNumImus = 4;
static constexpr size_t kNumEncoders = 4;
static constexpr size_t kNumBrakePressure = 2;
static constexpr size_t kNumBrakeSuspensionTemp = 4;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kNumBrakeAndSuspensionTemperature

Comment thread src/data/data.hpp
static constexpr size_t kNumEncoders = 4;
static constexpr size_t kNumBrakePressure = 2;
static constexpr size_t kNumBrakeSuspensionTemp = 4;
static constexpr size_t kNumAmbientTemp = 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kNumAmbientTemperature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants