Skip to content

Commit

Permalink
fix bug with feedbacks for v3 cyphal+dronecan target
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Sep 24, 2024
1 parent 81449c8 commit ae885a4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BUILD_DIR:=$(ROOT_DIR)/build
BUILD_OBJ_DIR:=$(BUILD_DIR)/obj

all: clean_releases cyphal_v2 cyphal_v3 dronecan_v2 dronecan_v3 sitl_dronecan sitl_cyphal
all: clean_releases cyphal_v2 cyphal_v3 dronecan_v2 dronecan_v3 v3 sitl_dronecan sitl_cyphal

# Cyphal
NUNAVUT_OUT_DIR:=$(BUILD_DIR)/nunavut_out
Expand Down Expand Up @@ -43,8 +43,8 @@ dronecan_v3: checks clean

# Cyphal & DroneCAN
v3: checks generate_dsdl clean
mkdir -p ${BUILD_OBJ_DIR}
cd ${BUILD_OBJ_DIR} && cmake -DCAN_PROTOCOL=both -DUSE_PLATFORM_NODE_V3=ON -G "Unix Makefiles" ../.. && make
mkdir -p ${BUILD_DIR}/both_v3/obj
cd ${BUILD_DIR}/both_v3/obj && cmake -DCAN_PROTOCOL=both -DUSE_PLATFORM_NODE_V3=ON -G "Unix Makefiles" ../../.. && make

# Common:
checks:
Expand Down
6 changes: 3 additions & 3 deletions Src/modules/cyphal/feedback/feedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "params.hpp"
#include "peripheral/pwm/pwm.hpp"

REGISTER_MODULE(FeedbackModule)
REGISTER_MODULE(CyphalFeedbackModule)

void FeedbackPublisher::publish() {
uint8_t buffer[reg_udral_service_actuator_common_Feedback_0_1_EXTENT_BYTES_];
Expand All @@ -21,12 +21,12 @@ void FeedbackPublisher::publish() {
}
}

void FeedbackModule::update_params() {
void CyphalFeedbackModule::update_params() {
auto port_id = static_cast<uint16_t>(paramsGetIntegerValue(PARAM_PUB_FEEDBACK_1_ID));
pub.setPortId(port_id);
}

void FeedbackModule::spin_once() {
void CyphalFeedbackModule::spin_once() {
pub.msg.heartbeat.health.value = uavcan_node_Health_1_0_NOMINAL;
pub.msg.heartbeat.readiness.value = reg_udral_service_common_Readiness_0_1_ENGAGED;
uint32_t pwm_ccr_reg_value = HAL::Pwm::get_duration(HAL::PwmPin::PWM_1);
Expand Down
4 changes: 2 additions & 2 deletions Src/modules/cyphal/feedback/feedback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ struct FeedbackPublisher: public cyphal::CyphalPublisher {
reg_udral_service_actuator_common_Feedback_0_1 msg;
};

class FeedbackModule : public Module {
class CyphalFeedbackModule : public Module {
public:
FeedbackModule() : Module(1, Protocol::CYPHAL) {}
CyphalFeedbackModule() : Module(1, Protocol::CYPHAL) {}

protected:
void update_params() override;
Expand Down
14 changes: 7 additions & 7 deletions Src/modules/dronecan/feedback/feedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#include "peripheral/adc/circuit_periphery.hpp"


REGISTER_MODULE(FeedbackModule)
REGISTER_MODULE(DronecanFeedbackModule)


void FeedbackModule::init() {
void DronecanFeedbackModule::init() {
mode = Module::Mode::STANDBY;
}

void FeedbackModule::update_params() {
void DronecanFeedbackModule::update_params() {
auto cmd_type_value = paramsGetIntegerValue(IntParamsIndexes::PARAM_PWM_CMD_TYPE);
cmd_type = static_cast<CommandType>(cmd_type_value);

Expand All @@ -36,7 +36,7 @@ void FeedbackModule::update_params() {
}
}

void FeedbackModule::spin_once() {
void DronecanFeedbackModule::spin_once() {
if (feedback_type == FeedbackType::DISABLED) {
return;
}
Expand All @@ -62,7 +62,7 @@ void FeedbackModule::spin_once() {
}
}

void FeedbackModule::publish_esc_status(PwmChannelInfo& pwm) {
void DronecanFeedbackModule::publish_esc_status(PwmChannelInfo& pwm) {
esc_status.msg = {
.error_count = esc_status.msg.error_count + 1,
.voltage = CircuitPeriphery::voltage_vin(),
Expand All @@ -76,7 +76,7 @@ void FeedbackModule::publish_esc_status(PwmChannelInfo& pwm) {
esc_status.publish();
}

void FeedbackModule::publish_actuator_status(PwmChannelInfo& pwm) {
void DronecanFeedbackModule::publish_actuator_status(PwmChannelInfo& pwm) {
actuator_status.msg = {
.actuator_id = static_cast<uint8_t>(pwm.channel),

Expand All @@ -93,7 +93,7 @@ void FeedbackModule::publish_actuator_status(PwmChannelInfo& pwm) {
actuator_status.publish();
}

void FeedbackModule::publish_hardpoint_status(PwmChannelInfo& pwm) {
void DronecanFeedbackModule::publish_hardpoint_status(PwmChannelInfo& pwm) {
static constexpr uint16_t CMD_RELEASE_OR_MIN = 0;
static constexpr uint16_t CMD_HOLD_OR_MAX = 1;

Expand Down
4 changes: 2 additions & 2 deletions Src/modules/dronecan/feedback/feedback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ enum class FeedbackType: uint8_t {
NUMBER_OF_FEEDBACKS,
};

class FeedbackModule : public Module {
class DronecanFeedbackModule : public Module {
public:
void init() override;

inline FeedbackModule() : Module(10, Protocol::DRONECAN) {}
inline DronecanFeedbackModule() : Module(10, Protocol::DRONECAN) {}

protected:
void spin_once() override;
Expand Down

0 comments on commit ae885a4

Please sign in to comment.