Skip to content

Commit

Permalink
move compact feedback to zubax dir
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Aug 25, 2024
1 parent 8e62079 commit 937de75
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sonar.sources=Cyphal,Udral,ds015,examples
sonar.sources=Cyphal,Udral,ds015,zubax,examples
4 changes: 0 additions & 4 deletions Udral/actuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,4 @@ void ReadinessSubscriber::callback(const CanardRxTransfer& transfer) {
_last_recv_time_ms = HAL_GetTick();
}

void ZubaxCompactFeedbackPublisher::publish(const ZubaxCompactFeedback& msg) {
push(zubax_telega_CompactFeedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES, (const uint8_t*)&msg);
}

} // namespace cyphal
20 changes: 0 additions & 20 deletions Udral/actuator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,6 @@ struct ReadinessSubscriber: public CyphalSubscriber {
uint32_t _last_recv_time_ms{0};
};


// https://telega.zubax.com/interfaces/cyphal.html#compact
#pragma pack(push, 1)
struct ZubaxCompactFeedback {
uint32_t dc_voltage : 11;
int32_t dc_current : 12;
int32_t phase_current_amplitude : 12;
int32_t velocity : 13;
int8_t demand_factor_pct : 8;
};
#pragma pack(pop)

struct ZubaxCompactFeedbackPublisher: public CyphalPublisher {
ZubaxCompactFeedbackPublisher(Cyphal* driver_, CanardPortID port_id) : CyphalPublisher(driver_, port_id) {};
void publish(const ZubaxCompactFeedback& msg);
static constexpr float RPM_TO_RAD_PER_SEC = 0.1047198;
private:
static constexpr size_t zubax_telega_CompactFeedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES = 7;
};

} // namespace cyphal

#endif // UDRAL_ACTUATOR_HPP_
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.projectKey=RaccoonlabDev_cyphal_application
sonar.organization=raccoonlabdev
sonar.sources=Cyphal,Udral,ds015,examples
sonar.sources=Cyphal,Udral,ds015,zubax,examples
sonar.cfamily.build-wrapper-output=bw-output
sonar.host.url=https://sonarcloud.io
sonar.cfamily.gcov.reportsPath=build
15 changes: 15 additions & 0 deletions zubax/compact_feedback.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// This software is distributed under the terms of the MIT License.
/// Copyright (c) 2024 Dmitry Ponomarev.
/// Author: Dmitry Ponomarev <[email protected]>

#include "compact_feedback.hpp"
#include "main.h"
#include "params.hpp"

namespace zubax::telega {

void CompactFeedbackPublisher::publish(const CompactFeedback& msg) {
push(zubax_telega_CompactFeedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES, (const uint8_t*)&msg);
}

} // namespace zubax::telega
34 changes: 34 additions & 0 deletions zubax/compact_feedback.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/// This software is distributed under the terms of the MIT License.
/// Copyright (c) 2023 Dmitry Ponomarev.
/// Author: Dmitry Ponomarev <[email protected]>

#ifndef ZUBAX_COMPACT_FEEDBACK_HPP_
#define ZUBAX_COMPACT_FEEDBACK_HPP_

#include "cyphal.hpp"
#include "cyphal_publishers.hpp"

namespace zubax::telega {

// https://telega.zubax.com/interfaces/cyphal.html#compact
#pragma pack(push, 1)
struct CompactFeedback {
uint32_t dc_voltage : 11;
int32_t dc_current : 12;
int32_t phase_current_amplitude : 12;
int32_t velocity : 13;
int8_t demand_factor_pct : 8;
};
#pragma pack(pop)

struct CompactFeedbackPublisher: public cyphal::CyphalPublisher {
CompactFeedbackPublisher() : cyphal::CyphalPublisher(cyphal::Cyphal::get_instance(), 65535) { }
void publish(const CompactFeedback& msg);
static constexpr float RPM_TO_RAD_PER_SEC = 0.1047198;
private:
static constexpr size_t zubax_telega_CompactFeedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES = 7;
};

} // namespace zubax::telega

#endif // ZUBAX_COMPACT_FEEDBACK_HPP_

0 comments on commit 937de75

Please sign in to comment.