Skip to content

Commit

Permalink
improve udral actuators
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Oct 9, 2023
1 parent f29e407 commit ac4ff30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions Udral/actuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SetpointSubscriber::SetpointSubscriber(Cyphal* driver_) :
int8_t SetpointSubscriber::init() {
port_id = paramsGetIntegerValue(IntParamsIndexes::SETPOINT_ID);
if (driver->subscribe(this,
reg_udral_service_actuator_common_sp_Vector4_0_1_EXTENT_BYTES_,
reg_udral_service_actuator_common_sp_Vector31_0_1_EXTENT_BYTES_,
CanardTransferKindMessage) < 0) {
return -1;
}
Expand All @@ -24,11 +24,12 @@ int8_t SetpointSubscriber::init() {
void SetpointSubscriber::callback(const CanardRxTransfer& transfer) {
const uint8_t* payload = static_cast<const uint8_t*>(transfer.payload);
size_t payload_len = transfer.payload_size;
reg_udral_service_actuator_common_sp_Vector4_0_1_deserialize_(&msg, payload, &payload_len);
reg_udral_service_actuator_common_sp_Vector31_0_1_deserialize_(&msg, payload, &payload_len);
_setpoint_size = payload_len / 2;
_recv_counter++;
}

const reg_udral_service_actuator_common_sp_Vector4_0_1& SetpointSubscriber::get_setpoint() const {
const reg_udral_service_actuator_common_sp_Vector31_0_1& SetpointSubscriber::get_setpoint() const {
return msg;
}

Expand Down
8 changes: 5 additions & 3 deletions Udral/actuator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@

#include "cyphal.hpp"
#include "reg/udral/service/actuator/common/sp/Scalar_0_1.h"
#include "reg/udral/service/actuator/common/sp/Vector4_0_1.h"
#include "reg/udral/service/actuator/common/sp/Vector31_0_1.h"
#include "reg/udral/service/common/Readiness_0_1.h"


struct SetpointSubscriber: public CyphalSubscriber {
SetpointSubscriber(Cyphal* driver);
int8_t init();
void callback(const CanardRxTransfer& transfer) override;
const reg_udral_service_actuator_common_sp_Vector4_0_1& get_setpoint() const;
const reg_udral_service_actuator_common_sp_Vector31_0_1& get_setpoint() const;
uint8_t get_setpoint_size() const {return _setpoint_size;};
uint32_t get_recv_counter() const;
void clear_recv_counter();
private:
reg_udral_service_actuator_common_sp_Vector4_0_1 msg = {};
reg_udral_service_actuator_common_sp_Vector31_0_1 msg = {};
uint32_t _recv_counter{0};
uint8_t _setpoint_size{0};
};


Expand Down

0 comments on commit ac4ff30

Please sign in to comment.