Skip to content

Commit 6e8d77c

Browse files
jgoppertbperseghetti
authored andcommitted
Switch to UDP for ROS comms.
Signed-off-by: James Goppert <james.goppert@gmail.com>
1 parent 692b03e commit 6e8d77c

26 files changed

+1057
-18
lines changed

app/b3rb/CMakeLists.txt

+50-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
1515

1616
project(b3rb LANGUAGES C)
1717

18-
target_compile_options(app PRIVATE -Wall -Wextra -Werror)
19-
20-
set_source_files_properties(src/casadi/gen/b3rb.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
21-
2218
set(SOURCE_FILES src/main.c)
2319

2420
if (CONFIG_CEREBRI_B3RB_FSM)
@@ -56,4 +52,54 @@ if (CONFIG_CEREBRI_B3RB_CASADI)
5652
src/casadi/gen/b3rb.c)
5753
endif()
5854

55+
set(flags
56+
-std=c11
57+
-Wall
58+
-Wextra
59+
-Werror
60+
-Wstrict-prototypes
61+
-Waggregate-return
62+
-Wbad-function-cast
63+
-Wcast-align
64+
-Wcast-qual
65+
-Wfloat-equal
66+
-Wformat-security
67+
-Wlogical-op
68+
-Wmissing-declarations
69+
# ubxlib includes geographiclib which dir doesn't exist
70+
#-Wmissing-include-dirs
71+
-Wmissing-prototypes
72+
-Wnested-externs
73+
-Wpointer-arith
74+
-Wredundant-decls
75+
-Wsequence-point
76+
-Wshadow
77+
-Wstrict-prototypes
78+
-Wswitch
79+
-Wundef
80+
-Wunreachable-code
81+
-Wunused-but-set-parameter
82+
-Wwrite-strings
83+
)
84+
string(JOIN " " flags ${flags})
85+
86+
set_source_files_properties(
87+
${SOURCE_FILES}
88+
PROPERTIES COMPILE_FLAGS
89+
"${flags}"
90+
)
91+
92+
set_source_files_properties(
93+
src/casadi/gen/b3rb.c
94+
PROPERTIES COMPILE_FLAGS
95+
"${flags}\
96+
-Wno-unused-parameter\
97+
-Wno-missing-prototypes\
98+
-Wno-missing-declarations\
99+
-Wno-float-equal")
100+
59101
target_sources(app PRIVATE ${SOURCE_FILES})
102+
103+
target_include_directories(app SYSTEM BEFORE PRIVATE ${ZEPHYR_BASE}/include)
104+
105+
# vi: ts=2 sw=2 et

app/b3rb/boards/mr_canhubk3.conf

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ CONFIG_CEREBRI_ACTUATE_PWM_NUMBER=2
55
CONFIG_LED_STRIP=y
66
CONFIG_APA102_STRIP=y
77

8+
CONFIG_ETH_NXP_S32_RX_RING_LEN=16
9+
810
# steering
911
CONFIG_CEREBRI_ACTUATE_PWM_USE_POS_0=y
1012
CONFIG_CEREBRI_ACTUATE_PWM_INDEX_0=0

app/b3rb/boards/native_sim.conf

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ CONFIG_ASAN=n
1515
CONFIG_UBSAN=n
1616

1717
CONFIG_CEREBRI_ACTUATE_LED_ARRAY=n
18+
CONFIG_CEREBRI_ACTUATE_SOUND=n
19+
CONFIG_CEREBRI_ACTUATE_PWM=n
1820
CONFIG_CEREBRI_SENSE_POWER=n
1921
CONFIG_CEREBRI_SENSE_IMU=n
2022
CONFIG_CEREBRI_SENSE_BARO=n

app/b3rb/prj.conf

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ CONFIG_CEREBRI_ACTUATE_SOUND=y
2020

2121
CONFIG_NET_BUF_RX_COUNT=24
2222
CONFIG_NET_PKT_RX_COUNT=24
23-
CONFIG_ETH_NXP_S32_RX_RING_LEN=16
2423

2524
CONFIG_CEREBRI_SENSE_POWER=y
2625
CONFIG_CEREBRI_SENSE_SAFETY=y
@@ -29,7 +28,9 @@ CONFIG_CEREBRI_SENSE_MAG=y
2928
CONFIG_CEREBRI_SENSE_WHEEL_ODOMETRY=y
3029
CONFIG_CEREBRI_SENSE_UBX_GNSS=y
3130

32-
CONFIG_CEREBRI_SYNAPSE_ETHERNET=y
31+
CONFIG_CEREBRI_SYNAPSE_ETH_RX=y
32+
CONFIG_CEREBRI_SYNAPSE_ETH_TX=y
33+
CONFIG_CEREBRI_SYNAPSE_ETHERNET=n
3334

3435
CONFIG_CEREBRI_SYNAPSE_TOPIC=y
3536
CONFIG_CEREBRI_CORE_COMMON=y

app/b3rb/src/fsm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
LOG_MODULE_REGISTER(b3rb_fsm, CONFIG_CEREBRI_B3RB_LOG_LEVEL);
2424

25-
void transition(
25+
static void transition(
2626
void* state,
2727
bool request,
2828
const char* request_name,

app/b3rb/src/lighting.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void lighting_work_handler(struct k_work* work)
8888
zros_sub_update(&ctx->sub_safety);
8989
zros_sub_update(&ctx->sub_battery_state);
9090

91-
double t = (double)k_uptime_ticks() / CONFIG_SYS_CLOCK_TICKS_PER_SEC;
91+
double t = k_uptime_ticks() / ((double)CONFIG_SYS_CLOCK_TICKS_PER_SEC);
9292
const double led_pulse_freq = 0.25;
9393
const double brightness_min = 4;
9494
const double brightness_max = 30;

app/b3rb/src/mixing.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
#include <synapse_topic_list.h>
6+
#include "mixing.h"
77

88
void b3rb_set_actuators(synapse_msgs_Actuators* msg, double turn_angle, double omega_fwd)
99
{

app/b3rb/src/velocity.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void init_b3rb_vel(context* ctx)
6262
}
6363

6464
// computes rc_input from V, omega
65-
void update_cmd_vel(context* ctx)
65+
static void update_cmd_vel(context* ctx)
6666
{
6767
double turn_angle = 0;
6868
double omega_fwd = 0;

lib/dream/sil/zephyr_main.c

+16-6
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ LOG_MODULE_REGISTER(dream_sil, CONFIG_CEREBRI_DREAM_SIL_LOG_LEVEL);
2929

3030
extern sil_context_t g_ctx;
3131
extern struct ring_buf g_msg_updates;
32+
static K_THREAD_STACK_DEFINE(my_stack_area, MY_STACK_SIZE);
33+
static struct k_thread my_thread_data;
3234

3335
static void zephyr_sim_entry_point(void* p0, void* p1, void* p2)
3436
{
3537
struct zros_node node;
3638
struct zros_sub sub_actuators;
3739
synapse_msgs_Actuators actuators;
3840

39-
zros_node_init(&node, "sil");
41+
zros_node_init(&node, "dream_sil");
4042
zros_sub_init(&sub_actuators, &node, &topic_actuators, &actuators, 10);
4143

4244
sil_context_t* ctx = p0;
@@ -130,10 +132,18 @@ static void zephyr_sim_entry_point(void* p0, void* p1, void* p2)
130132
printf("zephyr main loop finished\n");
131133
}
132134

133-
// zephyr threads
134-
K_THREAD_DEFINE(zephyr_sim, MY_STACK_SIZE,
135-
zephyr_sim_entry_point,
136-
&g_ctx, NULL, NULL,
137-
MY_PRIORITY, 0, 0);
135+
static int start()
136+
{
137+
k_tid_t tid = k_thread_create(&my_thread_data, my_stack_area,
138+
K_THREAD_STACK_SIZEOF(my_stack_area),
139+
zephyr_sim_entry_point,
140+
&g_ctx, NULL, NULL,
141+
MY_PRIORITY, 0, K_FOREVER);
142+
k_thread_name_set(tid, "dream_sil");
143+
k_thread_start(tid);
144+
return 0;
145+
}
146+
147+
SYS_INIT(start, POST_KERNEL, 0);
138148

139149
// vi: ts=4 sw=4 et

lib/synapse/CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
add_subdirectory_ifdef(CONFIG_CEREBRI_SYNAPSE_ZROS zros)
4-
add_subdirectory_ifdef(CONFIG_CEREBRI_SYNAPSE_ETHERNET ethernet)
3+
add_subdirectory_ifdef(CONFIG_CEREBRI_SYNAPSE_ETH_TX eth_tx)
4+
add_subdirectory_ifdef(CONFIG_CEREBRI_SYNAPSE_ETH_RX eth_rx)
55
add_subdirectory_ifdef(CONFIG_CEREBRI_SYNAPSE_TOPIC topic)
6+
add_subdirectory_ifdef(CONFIG_CEREBRI_SYNAPSE_UDP udp)
67
add_subdirectory_ifdef(CONFIG_CEREBRI_SYNAPSE_VESC_CAN vesc_can)
8+
add_subdirectory_ifdef(CONFIG_CEREBRI_SYNAPSE_ZROS zros)

lib/synapse/Kconfig

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
menu "Synapse"
55

66
rsource "zros/Kconfig"
7+
rsource "eth_tx/Kconfig"
8+
rsource "eth_rx/Kconfig"
79
rsource "ethernet/Kconfig"
810
rsource "topic/Kconfig"
911
rsource "vesc_can/Kconfig"

lib/synapse/eth_rx/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2024, CogniPilot Foundation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
zephyr_library_named(cerebri_synapse_eth_rx)
5+
6+
# we need to be able to include generated header files
7+
zephyr_include_directories()
8+
9+
zephyr_library_sources(
10+
src/main.c
11+
src/proto/udp_rx.c
12+
)

lib/synapse/eth_rx/Kconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2024, CogniPilot Foundation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config CEREBRI_SYNAPSE_ETH_RX
5+
bool "ethernet receive"
6+
default y
7+
depends on CEREBRI_SYNAPSE_ZROS
8+
help
9+
This option enables the synapse udp interface
10+
11+
if CEREBRI_SYNAPSE_ETH_RX
12+
13+
module = CEREBRI_SYNAPSE_ETH_RX
14+
module-str = synapse_eth_rx
15+
source "subsys/logging/Kconfig.template.log_config"
16+
17+
endif # CEREBRI_SYNAPSE_ETH_RX

0 commit comments

Comments
 (0)