-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8a64c5
commit 94fd6e4
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// This software is distributed under the terms of the MIT License. | ||
/// Copyright (c) 2023 Dmitry Ponomarev. | ||
/// Author: Dmitry Ponomarev <[email protected]> | ||
|
||
#include "rangefinder.hpp" | ||
#include "main.h" | ||
|
||
void RangefinderRangePublisher::publish(float range) { | ||
if (!isEnabled()) { | ||
return; | ||
} | ||
|
||
uavcan_si_sample_length_Scalar_1_0 msg; | ||
msg.meter = range; | ||
|
||
static uint8_t buffer[uavcan_si_sample_length_Scalar_1_0_EXTENT_BYTES_]; | ||
size_t buffer_size = uavcan_si_sample_length_Scalar_1_0_EXTENT_BYTES_; | ||
int32_t result = uavcan_si_sample_length_Scalar_1_0_serialize_(&msg, buffer, &buffer_size); | ||
if (NUNAVUT_SUCCESS == result) { | ||
push(buffer_size, buffer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// This software is distributed under the terms of the MIT License. | ||
/// Copyright (c) 2023 Dmitry Ponomarev. | ||
/// Author: Dmitry Ponomarev <[email protected]> | ||
|
||
#ifndef UDRAL_RANGEFINDER_HPP_ | ||
#define UDRAL_RANGEFINDER_HPP_ | ||
|
||
#include "cyphal.hpp" | ||
#include "uavcan/si/sample/length/Scalar_1_0.h" | ||
|
||
|
||
struct RangefinderRangePublisher: public CyphalPublisher { | ||
RangefinderRangePublisher(Cyphal* driver_, CanardPortID port_id) : CyphalPublisher(driver_, port_id) {}; | ||
void publish(float range); | ||
}; | ||
|
||
|
||
#endif // UDRAL_RANGEFINDER_HPP_ |