@@ -498,7 +498,7 @@ void propulsion_microseconds_callback(const void * msgin)
498
498
void timer_callback (rcl_timer_t * timer, int64_t last_call_time) {
499
499
RCLC_UNUSED (last_call_time);
500
500
if (timer != NULL ) {
501
- RCSOFTCHECK (rcl_publish (&power_batteries_voltage_publisher, &power_batteries_voltage_publisher , NULL ));
501
+ RCSOFTCHECK (rcl_publish (&power_batteries_voltage_publisher, &power_batteries_voltage_msg , NULL ));
502
502
RCSOFTCHECK (rcl_publish (&power_thrusters_current_publisher, &power_thrusters_current_msg, NULL ));
503
503
RCSOFTCHECK (rcl_publish (&power_board_temperature_publisher, &power_board_temperature_msg, NULL ));
504
504
RCSOFTCHECK (rcl_publish (&power_teensy_temperature_publisher, &power_teensy_temperature_msg, NULL ));
@@ -549,7 +549,7 @@ bool create_entities()
549
549
" /power/teensy/temperature" ));
550
550
551
551
// create timer,
552
- const unsigned int timer_timeout = 100 ;
552
+ const unsigned int timer_timeout = 1000 ;
553
553
RCCHECK (rclc_timer_init_default (
554
554
&timer,
555
555
&support,
@@ -615,18 +615,47 @@ void power_setup() {
615
615
set_microros_serial_transports (Serial);
616
616
delay (2000 );
617
617
618
+ // allocates correct message sizes and initialzies to 0, required or crashes
619
+
618
620
propulsion_microseconds_msg.data .size = 8 ;
619
621
propulsion_microseconds_msg.data .capacity = 8 ;
620
622
propulsion_microseconds_msg.data .data = (int16_t *)malloc (propulsion_microseconds_msg.data .capacity * sizeof (int16_t ));
623
+ for (int i = 0 ; i < 8 ; i++) {
624
+ propulsion_microseconds_msg.data .data [i] = 0 ;
625
+ }
621
626
622
627
power_batteries_voltage_msg.data .size = 2 ;
623
628
power_batteries_voltage_msg.data .capacity = 2 ;
624
629
power_batteries_voltage_msg.data .data = (float *)malloc (power_batteries_voltage_msg.data .capacity * sizeof (float ));
630
+ for (int i = 0 ; i < 2 ; i++) {
631
+ power_batteries_voltage_msg.data .data [i] = 0.0 ;
632
+ }
633
+
634
+ power_thrusters_current_msg.data .size = 8 ;
635
+ power_thrusters_current_msg.data .capacity = 8 ;
636
+ power_thrusters_current_msg.data .data = (float *)malloc (power_thrusters_current_msg.data .capacity * sizeof (float ));
637
+ for (int i = 0 ; i < 8 ; i++) {
638
+ power_thrusters_current_msg.data .data [i] = 0.0 ;
639
+ }
625
640
626
641
power_board_temperature_msg.data = 0.0 ;
627
642
628
643
power_teensy_temperature_msg.data = 0.0 ;
629
644
645
+ // allocates thrusters to 1500 in case of reset and allocates -2.0 to sensing to go under the -1.0 of unintiailized from drivers
646
+
647
+ for (int i = 0 ; i < 8 ; i++) {
648
+ propulsion_microseconds_msg.data .data [i] = 1500 ;
649
+ }
650
+ for (int i = 0 ; i < 2 ; i++) {
651
+ power_batteries_voltage_msg.data .data [i] = -2.0 ;
652
+ }
653
+ for (int i = 0 ; i < 8 ; i++) {
654
+ power_thrusters_current_msg.data .data [i] = -2.0 ;
655
+ }
656
+ power_board_temperature_msg.data = -2.0 ;
657
+ power_teensy_temperature_msg.data = -2.0 ;
658
+
630
659
state = WAITING_AGENT;
631
660
}
632
661
0 commit comments