Skip to content

Commit

Permalink
Enable CI for "differential" & "servo" demos (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
serges147 authored Nov 13, 2024
1 parent 365dbc7 commit 2a70a93
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 39 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: get nunavut
run: >
pip install nunavut
pip install git+https://github.com/OpenCyphal/nunavut[email protected]
- name: Configure CMake
run: cmake -B ${{github.workspace}}/libudpard_demo/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{github.workspace}}/libudpard_demo
Expand All @@ -57,7 +57,6 @@ jobs:
run: cmake --build ${{github.workspace}}/libudpard_demo/build --config ${{env.BUILD_TYPE}}

build_differential_pressure_sensor:
if: false
name: Build Differential Pressure Sensor demo
runs-on: ubuntu-latest

Expand All @@ -68,7 +67,7 @@ jobs:

- name: get nunavut
run: >
pip install nunavut
pip install git+https://github.com/OpenCyphal/nunavut[email protected]
- name: Configure CMake
run: cmake -B ${{github.workspace}}/differential_pressure_sensor/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{github.workspace}}/differential_pressure_sensor
Expand All @@ -78,7 +77,6 @@ jobs:


build_udral_servo:
if: false
name: Build UDRAL Servo demo
runs-on: ubuntu-latest

Expand All @@ -89,7 +87,7 @@ jobs:

- name: get nunavut
run: >
pip install nunavut
pip install git+https://github.com/OpenCyphal/nunavut[email protected]
- name: Configure CMake
run: cmake -B ${{github.workspace}}/udral_servo/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{github.workspace}}/udral_servo
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
[submodule "submodules/libcyphal"]
path = submodules/libcyphal
url = https://github.com/OpenCyphal-Garage/libcyphal.git
branch = sshirokov/type_name
branch = sshirokov/async_destroy
22 changes: 11 additions & 11 deletions differential_pressure_sensor/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static void handleFastLoop(State* const state, const CanardMicrosecond monotonic
uavcan_si_unit_pressure_Scalar_1_0 msg = {0};
msg._pascal = (float) rand() * 0.1F; // TODO: sample data from the real sensor.
// Serialize and publish the message:
uint8_t serialized[uavcan_si_unit_pressure_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_si_unit_pressure_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t err = uavcan_si_unit_pressure_Scalar_1_0_serialize_(&msg, &serialized[0], &serialized_size);
assert(err >= 0);
Expand Down Expand Up @@ -226,8 +226,8 @@ static void handle1HzLoop(State* const state, const CanardMicrosecond monotonic_
heartbeat.health.value = uavcan_node_Health_1_0_NOMINAL;
}

uint8_t serialized[uavcan_node_Heartbeat_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
size_t serialized_size = sizeof(serialized);
uint8_t serialized[uavcan_node_Heartbeat_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t err = uavcan_node_Heartbeat_1_0_serialize_(&heartbeat, &serialized[0], &serialized_size);
assert(err >= 0);
if (err >= 0)
Expand Down Expand Up @@ -259,7 +259,7 @@ static void handle1HzLoop(State* const state, const CanardMicrosecond monotonic_
uavcan_pnp_NodeIDAllocationData_2_0 msg = {0};
msg.node_id.value = UINT16_MAX;
getUniqueID(msg.unique_id);
uint8_t serialized[uavcan_pnp_NodeIDAllocationData_2_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_pnp_NodeIDAllocationData_2_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t err = uavcan_pnp_NodeIDAllocationData_2_0_serialize_(&msg, &serialized[0], &serialized_size);
assert(err >= 0);
Expand Down Expand Up @@ -287,7 +287,7 @@ static void handle1HzLoop(State* const state, const CanardMicrosecond monotonic_
uavcan_si_unit_temperature_Scalar_1_0 msg = {0};
msg.kelvin = (float) rand() * 0.01F; // TODO: sample data from the real sensor.
// Serialize and publish the message:
uint8_t serialized[uavcan_si_unit_temperature_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_si_unit_temperature_Scalar_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t err = uavcan_si_unit_temperature_Scalar_1_0_serialize_(&msg, &serialized[0], &serialized_size);
assert(err >= 0);
Expand Down Expand Up @@ -365,8 +365,8 @@ static void handle01HzLoop(State* const state, const CanardMicrosecond monotonic
fillServers(state->canard.rx_subscriptions[CanardTransferKindRequest], &m.servers);
fillServers(state->canard.rx_subscriptions[CanardTransferKindResponse], &m.clients); // For regularity.

// Serialize and publish the message. Use a small buffer because we know that our message is always small.
uint8_t serialized[512] = {0}; // https://github.com/OpenCyphal/nunavut/issues/191
// Serialize and publish the message. Use a smaller buffer if you know that message is always small.
uint8_t serialized[uavcan_node_port_List_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = uavcan_node_port_List_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_;
if (uavcan_node_port_List_0_1_serialize_(&m, &serialized[0], &serialized_size) >= 0)
{
Expand Down Expand Up @@ -544,7 +544,7 @@ static void processReceivedTransfer(State* const state, const CanardRxTransfer*
{
// The request object is empty so we don't bother deserializing it. Just send the response.
const uavcan_node_GetInfo_Response_1_0 resp = processRequestNodeGetInfo();
uint8_t serialized[uavcan_node_GetInfo_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_node_GetInfo_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t res = uavcan_node_GetInfo_Response_1_0_serialize_(&resp, &serialized[0], &serialized_size);
if (res >= 0)
Expand All @@ -567,7 +567,7 @@ static void processReceivedTransfer(State* const state, const CanardRxTransfer*
if (uavcan_register_Access_Request_1_0_deserialize_(&req, transfer->payload, &size) >= 0)
{
const uavcan_register_Access_Response_1_0 resp = processRequestRegisterAccess(&req);
uint8_t serialized[uavcan_register_Access_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_register_Access_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
if (uavcan_register_Access_Response_1_0_serialize_(&resp, &serialized[0], &serialized_size) >= 0)
{
Expand All @@ -586,7 +586,7 @@ static void processReceivedTransfer(State* const state, const CanardRxTransfer*
if (uavcan_register_List_Request_1_0_deserialize_(&req, transfer->payload, &size) >= 0)
{
const uavcan_register_List_Response_1_0 resp = {.name = registerGetNameByIndex(req.index)};
uint8_t serialized[uavcan_register_List_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_register_List_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
if (uavcan_register_List_Response_1_0_serialize_(&resp, &serialized[0], &serialized_size) >= 0)
{
Expand All @@ -605,7 +605,7 @@ static void processReceivedTransfer(State* const state, const CanardRxTransfer*
if (uavcan_node_ExecuteCommand_Request_1_1_deserialize_(&req, transfer->payload, &size) >= 0)
{
const uavcan_node_ExecuteCommand_Response_1_1 resp = processRequestExecuteCommand(&req);
uint8_t serialized[uavcan_node_ExecuteCommand_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_node_ExecuteCommand_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
if (uavcan_node_ExecuteCommand_Response_1_1_serialize_(&resp, &serialized[0], &serialized_size) >= 0)
{
Expand Down
4 changes: 2 additions & 2 deletions libudpard_demo/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ static void cbOnNodeIDAllocationData(struct Subscriber* const self, struct Udpar
(void) fprintf(stderr, "RPC dispatcher start failed: %i\n", rpc_start_res);
}
} // Otherwise, it's a response destined to another node, or it's a malformed message.
} // Otherwise, the message is malformed.
} // Otherwise, it's a request from another allocation client node, or we already have a node-ID.
} // Otherwise, the message is malformed.
} // Otherwise, it's a request from another allocation client node, or we already have a node-ID.
}

static void cbOnMyData(struct Subscriber* const self, struct UdpardRxTransfer* const transfer)
Expand Down
8 changes: 4 additions & 4 deletions shared/register/register.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void registerRead(const char* const register_name, uavcan_register_Value_1_0* co
FILE* const fp = registerOpen(&register_name[0], false);
if (fp != NULL)
{
uint8_t serialized[uavcan_register_Value_1_0_EXTENT_BYTES_] = {0};
uint8_t serialized[uavcan_register_Value_1_0_EXTENT_BYTES_];
size_t sr_size = fread(&serialized[0], 1U, uavcan_register_Value_1_0_EXTENT_BYTES_, fp);
(void) fclose(fp);
uavcan_register_Value_1_0 out = {0};
Expand All @@ -54,9 +54,9 @@ void registerRead(const char* const register_name, uavcan_register_Value_1_0* co

void registerWrite(const char* const register_name, const uavcan_register_Value_1_0* const value)
{
uint8_t serialized[uavcan_register_Value_1_0_EXTENT_BYTES_] = {0};
size_t sr_size = uavcan_register_Value_1_0_EXTENT_BYTES_;
const int8_t err = uavcan_register_Value_1_0_serialize_(value, serialized, &sr_size);
uint8_t serialized[uavcan_register_Value_1_0_EXTENT_BYTES_];
size_t sr_size = uavcan_register_Value_1_0_EXTENT_BYTES_;
const int8_t err = uavcan_register_Value_1_0_serialize_(value, serialized, &sr_size);
if (err >= 0)
{
FILE* const fp = registerOpen(&register_name[0], true);
Expand Down
30 changes: 15 additions & 15 deletions udral_servo/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static void handleFastLoop(State* const state, const CanardMicrosecond monotonic
// If there are any hardware or configuration issues, report them here:
msg.heartbeat.health.value = uavcan_node_Health_1_0_NOMINAL;
// Serialize and publish the message:
uint8_t serialized[reg_udral_service_actuator_common_Feedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[reg_udral_service_actuator_common_Feedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t err =
reg_udral_service_actuator_common_Feedback_0_1_serialize_(&msg, &serialized[0], &serialized_size);
Expand Down Expand Up @@ -275,8 +275,8 @@ static void handleFastLoop(State* const state, const CanardMicrosecond monotonic
msg.value.kinematics.acceleration.meter_per_second_per_second = state->servo.acceleration;
msg.value.force.newton = state->servo.force;
// Serialize and publish the message:
uint8_t serialized[reg_udral_physics_dynamics_translation_LinearTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
size_t serialized_size = sizeof(serialized);
uint8_t serialized[reg_udral_physics_dynamics_translation_LinearTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t err =
reg_udral_physics_dynamics_translation_LinearTs_0_1_serialize_(&msg, &serialized[0], &serialized_size);
assert(err >= 0);
Expand All @@ -303,8 +303,8 @@ static void handleFastLoop(State* const state, const CanardMicrosecond monotonic
msg.value.current.ampere = 20.315F;
msg.value.voltage.volt = 51.3F;
// Serialize and publish the message:
uint8_t serialized[reg_udral_physics_dynamics_translation_LinearTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
size_t serialized_size = sizeof(serialized);
uint8_t serialized[reg_udral_physics_dynamics_translation_LinearTs_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t err = reg_udral_physics_electricity_PowerTs_0_1_serialize_(&msg, &serialized[0], &serialized_size);
assert(err >= 0);
if (err >= 0)
Expand Down Expand Up @@ -341,8 +341,8 @@ static void handle1HzLoop(State* const state, const CanardMicrosecond monotonic_
heartbeat.health.value = uavcan_node_Health_1_0_NOMINAL;
}

uint8_t serialized[uavcan_node_Heartbeat_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
size_t serialized_size = sizeof(serialized);
uint8_t serialized[uavcan_node_Heartbeat_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t err = uavcan_node_Heartbeat_1_0_serialize_(&heartbeat, &serialized[0], &serialized_size);
assert(err >= 0);
if (err >= 0)
Expand Down Expand Up @@ -374,7 +374,7 @@ static void handle1HzLoop(State* const state, const CanardMicrosecond monotonic_
uavcan_pnp_NodeIDAllocationData_2_0 msg = {0};
msg.node_id.value = UINT16_MAX;
getUniqueID(msg.unique_id);
uint8_t serialized[uavcan_pnp_NodeIDAllocationData_2_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_pnp_NodeIDAllocationData_2_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t err = uavcan_pnp_NodeIDAllocationData_2_0_serialize_(&msg, &serialized[0], &serialized_size);
assert(err >= 0);
Expand Down Expand Up @@ -403,7 +403,7 @@ static void handle1HzLoop(State* const state, const CanardMicrosecond monotonic_
// Publish the servo status -- this is a low-rate message with low-severity diagnostics.
reg_udral_service_actuator_common_Status_0_1 msg = {0};
// TODO: POPULATE THE MESSAGE: temperature, errors, etc.
uint8_t serialized[reg_udral_service_actuator_common_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[reg_udral_service_actuator_common_Status_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t err =
reg_udral_service_actuator_common_Status_0_1_serialize_(&msg, &serialized[0], &serialized_size);
Expand Down Expand Up @@ -500,8 +500,8 @@ static void handle01HzLoop(State* const state, const CanardMicrosecond monotonic
fillServers(state->canard.rx_subscriptions[CanardTransferKindRequest], &m.servers);
fillServers(state->canard.rx_subscriptions[CanardTransferKindResponse], &m.clients); // For regularity.

// Serialize and publish the message. Use a small buffer because we know that our message is always small.
uint8_t serialized[512] = {0}; // https://github.com/OpenCyphal/nunavut/issues/191
// Serialize and publish the message. Use a smaller buffer if you know that message is always small.
uint8_t serialized[uavcan_node_port_List_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = uavcan_node_port_List_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_;
if (uavcan_node_port_List_0_1_serialize_(&m, &serialized[0], &serialized_size) >= 0)
{
Expand Down Expand Up @@ -721,7 +721,7 @@ static void processReceivedTransfer(State* const state, const CanardRxTransfer*
{
// The request object is empty so we don't bother deserializing it. Just send the response.
const uavcan_node_GetInfo_Response_1_0 resp = processRequestNodeGetInfo();
uint8_t serialized[uavcan_node_GetInfo_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_node_GetInfo_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
const int8_t res = uavcan_node_GetInfo_Response_1_0_serialize_(&resp, &serialized[0], &serialized_size);
if (res >= 0)
Expand All @@ -740,7 +740,7 @@ static void processReceivedTransfer(State* const state, const CanardRxTransfer*
if (uavcan_register_Access_Request_1_0_deserialize_(&req, transfer->payload, &size) >= 0)
{
const uavcan_register_Access_Response_1_0 resp = processRequestRegisterAccess(&req);
uint8_t serialized[uavcan_register_Access_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_register_Access_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
if (uavcan_register_Access_Response_1_0_serialize_(&resp, &serialized[0], &serialized_size) >= 0)
{
Expand All @@ -755,7 +755,7 @@ static void processReceivedTransfer(State* const state, const CanardRxTransfer*
if (uavcan_register_List_Request_1_0_deserialize_(&req, transfer->payload, &size) >= 0)
{
const uavcan_register_List_Response_1_0 resp = {.name = registerGetNameByIndex(req.index)};
uint8_t serialized[uavcan_register_List_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_register_List_Response_1_0_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
if (uavcan_register_List_Response_1_0_serialize_(&resp, &serialized[0], &serialized_size) >= 0)
{
Expand All @@ -770,7 +770,7 @@ static void processReceivedTransfer(State* const state, const CanardRxTransfer*
if (uavcan_node_ExecuteCommand_Request_1_1_deserialize_(&req, transfer->payload, &size) >= 0)
{
const uavcan_node_ExecuteCommand_Response_1_1 resp = processRequestExecuteCommand(&req);
uint8_t serialized[uavcan_node_ExecuteCommand_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_] = {0};
uint8_t serialized[uavcan_node_ExecuteCommand_Response_1_1_SERIALIZATION_BUFFER_SIZE_BYTES_];
size_t serialized_size = sizeof(serialized);
if (uavcan_node_ExecuteCommand_Response_1_1_serialize_(&resp, &serialized[0], &serialized_size) >= 0)
{
Expand Down

0 comments on commit 2a70a93

Please sign in to comment.