Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update modalai fcv2 board support for 1.14 #21653

Merged
merged 4 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions boards/modalai/fc-v2/default.px4board
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ CONFIG_COMMON_DIFFERENTIAL_PRESSURE=y
CONFIG_COMMON_DISTANCE_SENSOR=y
CONFIG_DRIVERS_DSHOT=y
CONFIG_DRIVERS_GPS=y
CONFIG_DRIVERS_IMU_BOSCH_BMI088=y
CONFIG_DRIVERS_IMU_INVENSENSE_ICM20602=y
CONFIG_DRIVERS_IMU_INVENSENSE_ICM20649=y
CONFIG_DRIVERS_IMU_INVENSENSE_ICM20948=y
# CONFIG_DRIVERS_IMU_BOSCH_BMI088=y
# CONFIG_DRIVERS_IMU_INVENSENSE_ICM20602=y
# CONFIG_DRIVERS_IMU_INVENSENSE_ICM20649=y
# CONFIG_DRIVERS_IMU_INVENSENSE_ICM20948=y
CONFIG_DRIVERS_IMU_INVENSENSE_ICM42688P=y
CONFIG_DRIVERS_IRLOCK=y
CONFIG_COMMON_LIGHT=y
Expand All @@ -29,11 +29,13 @@ CONFIG_DRIVERS_POWER_MONITOR_INA226=y
CONFIG_DRIVERS_POWER_MONITOR_VOXLPM=y
CONFIG_DRIVERS_PWM_OUT=y
CONFIG_DRIVERS_RC_INPUT=y
CONFIG_DRIVERS_RPM=y
CONFIG_COMMON_TELEMETRY=y
CONFIG_DRIVERS_UAVCAN=y
CONFIG_BOARD_UAVCAN_INTERFACES=1
CONFIG_BOARD_UAVCAN_TIMER_OVERRIDE=2
CONFIG_MODULES_AIRSPEED_SELECTOR=y
# CONFIG_MODULES_ATTITUDE_ESTIMATOR_Q=y
CONFIG_MODULES_CAMERA_FEEDBACK=y
CONFIG_MODULES_COMMANDER=y
CONFIG_MODULES_CONTROL_ALLOCATOR=y
Expand All @@ -52,6 +54,7 @@ CONFIG_MODULES_GYRO_FFT=y
CONFIG_MODULES_LAND_DETECTOR=y
CONFIG_MODULES_LANDING_TARGET_ESTIMATOR=y
CONFIG_MODULES_LOAD_MON=y
# CONFIG_MODULES_LOCAL_POSITION_ESTIMATOR=y
CONFIG_MODULES_LOGGER=y
CONFIG_MODULES_MAG_BIAS_ESTIMATOR=y
CONFIG_MODULES_MANUAL_CONTROL=y
Expand All @@ -70,6 +73,7 @@ CONFIG_MODULES_TEMPERATURE_COMPENSATION=y
CONFIG_MODULES_UXRCE_DDS_CLIENT=y
CONFIG_MODULES_VTOL_ATT_CONTROL=y
CONFIG_SYSTEMCMDS_ACTUATOR_TEST=y
CONFIG_SYSTEMCMDS_BL_UPDATE=y
CONFIG_SYSTEMCMDS_BSONDUMP=y
CONFIG_SYSTEMCMDS_DMESG=y
CONFIG_SYSTEMCMDS_GPIO=y
Expand Down
4 changes: 2 additions & 2 deletions boards/modalai/fc-v2/init/rc.board_sensors
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ icm42688p -s -b 1 -R 12 start
# Internal SPI2 ICM-42688
icm42688p -s -b 2 -R 12 start

# Internal I2C mag
bmm150 -I start
# Don't start Internal I2C mag
# bmm150 -I start
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the internal mag dropped?

If nothing else it's useful having it to properly orient the external mag. The common modules from holybro and mro both use an ist8310, but it's mounted differently and we have no way to detect, so doing it at calibration time (relative to an internal) was the least bad option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to remember that it was giving us some grief but I don't remember exactly what that was so I'll ask around and see what the specific issue was.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the flight test team just said that it was super noisy? Perhaps the idea is that you enable it but set SYS_HAS_MAG and MAG_TYPE parameters to not use it unless you have a secondary unit and then you just use the internal one for reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is internal mag used on Pixhawks in general? Just as a reference or as the actual primary source?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how having the internal one enabled helps the calibration figure out the orientation. I just tried calibrating the external compass with and without the internal one enabled and in neither case did it determine the proper rotation of the external compass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our discussion I will leave this disabled for now


# Internal I2C baro
icp201xx -I start
14 changes: 14 additions & 0 deletions boards/modalai/fc-v2/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,18 @@ else()
nuttx_drivers # sdio
px4_layer
)

set(COMMON_MODALAI_SRC_DIR ${PX4_SOURCE_DIR}/boards/modalai/src)
set(MODALAI_SYSTEMCMD_SRC_DIR ${COMMON_MODALAI_SRC_DIR}/systemcmds/modalai)

px4_add_module(
MODULE systemcmds__modalai
MAIN modalai
COMPILE_FLAGS
SRCS
${MODALAI_SYSTEMCMD_SRC_DIR}/modalai_fc-v2.c
${MODALAI_SYSTEMCMD_SRC_DIR}/modalai_fc-v1.c
${MODALAI_SYSTEMCMD_SRC_DIR}/modalai.c
DEPENDS
)
endif()
16 changes: 14 additions & 2 deletions boards/modalai/fc-v2/src/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
# define GPIO_nLED_GREEN /* PE4 */ (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN4)
# define GPIO_nLED_BLUE /* PE5 */ (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN5)

// GPIO_nLED_2_RED/ GPIO_nLED_2_GREEN /GPIO_nLED_2_BLUE are for v1 LED tests

# define GPIO_nLED_2_RED /* PI0 */ (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTI|GPIO_PIN0)
# define GPIO_nLED_2_GREEN /* PH11 */ (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTH|GPIO_PIN11)
# define GPIO_nLED_2_BLUE /* PA2 */ (GPIO_OUTPUT|GPIO_OPENDRAIN|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN2)

# define BOARD_HAS_CONTROL_STATUS_LEDS 1
# define BOARD_OVERLOAD_LED LED_RED
# define BOARD_ARMED_STATE_LED LED_BLUE
Expand Down Expand Up @@ -208,6 +214,12 @@

#define CAN1_SILENT /* PD15 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN15)

/* For primary/backup signaling with VOXL, 2 pins on J4 are exposed */
// GPIO_VOXL_STATUS_OUT/ GPIO_VOXL_STATUS_IN are for v1 Spare MSS Communications Interface and J4 tests

#define GPIO_VOXL_STATUS_OUT /* PE4 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN4)
#define GPIO_VOXL_STATUS_IN /* PE3 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTE|GPIO_PIN3)

/* Define True logic Power Control in arch agnostic form */

#define VDD_3V3_SPEKTRUM_POWER_EN(on_true) px4_arch_gpiowrite(GPIO_VDD_3V3_SPEKTRUM_POWER_EN, (on_true))
Expand Down Expand Up @@ -338,8 +350,8 @@

#define BOARD_NUM_IO_TIMERS 5

// J1 / TELEM1 / USART7
#define MODAL_IO_DEFAULT_PORT "/dev/ttyS6"
// J5 USART5 TELEM2 Port next to PWM connector
#define MODAL_IO_DEFAULT_PORT "/dev/ttyS4"

__BEGIN_DECLS

Expand Down
131 changes: 131 additions & 0 deletions boards/modalai/src/systemcmds/modalai/modalai.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#include <px4_platform_common/module.h>

#include "chip.h"
#include "stm32_gpio.h"
#include "board_config.h"

#include <nuttx/board.h>
#include <arch/board/board.h>

// v2
#ifdef CONFIG_ARCH_CHIP_STM32H753II // chip on M0087
#include "modalai_fc-v2.h"
#define MODALAI_FC_V2 1
#else
#include "modalai_fc-v1.h"
#endif

__EXPORT int modalai_main(int argc, char *argv[]);

int modalai_main(int argc, char *argv[])
{
int hw_rev = board_get_hw_revision();
int hw_ver = board_get_hw_version();

eHW_TYPE hw_type = eHwNone;

#ifdef MODALAI_FC_V2

if (hw_rev == 0 && hw_ver == 3) { // (should be hw_rev == 1 && hw_ver == 3) eventually...
hw_type = eM0087;

} else if (hw_rev == 0 && hw_ver == 3) {
hw_type = eM0079;

} else {
return -1;

}

#else

if (hw_rev == 6 && hw_ver == 0) {
hw_type = eM0018;

} else if (hw_rev == 0 && hw_ver == 1) {
hw_type = eM0019;

} else if (hw_rev == 0 && hw_ver == 2) {
hw_type = eM0051;

} else {
return -1;

}

#endif

if (argc <= 1) {
#ifdef MODALAI_FC_V2
modalai_print_usage_v2();
#else
modalai_print_usage_v1();
#endif
return 1;
}

if (!strcmp(argv[1], "led")) {
#ifdef MODALAI_FC_V2
return modalai_led_test_v2();
#else
return modalai_led_test_v1();
#endif

} else if (!strcmp(argv[1], "con")) {
if (argc <= 2) {
PRINT_MODULE_USAGE_COMMAND("con");
PRINT_MODULE_USAGE_ARG("<1,4,5,6,7,9,10,12,13>", "Connector ID", false);
PRINT_MODULE_USAGE_ARG("<uint>", "Pin Number", false);
PRINT_MODULE_USAGE_ARG("0 | 1", "<output state> (defaults to 0)", false);
return 1;
}

uint8_t con = 0;
uint8_t pin = 0;
bool state = false;

if (argc > 2) {
con = atoi(argv[2]);
}

if (argc > 3) {
pin = atoi(argv[3]);
}

if (argc > 4) {
state = atoi(argv[4]);
}

#ifdef MODALAI_FC_V2
return modalai_con_gpio_test_v2(con, pin, state);
#else
return modalai_con_gpio_test_v1(con, pin, state);
#endif

} else if (!strcmp(argv[1], "buzz")) {

#ifdef MODALAI_FC_V2
return modalai_buzz_test_v2(hw_type);
#else
return modalai_buzz_test_v1(hw_type);
#endif



} else if (!strcmp(argv[1], "detect")) {
#ifdef MODALAI_FC_V2
modalai_hw_detect_v2(hw_type);
#else
modalai_hw_detect_v1(hw_type);
#endif

return 0;
}

#ifdef MODALAI_FC_V2
modalai_print_usage_v2();
#else
modalai_print_usage_v1();
#endif
return -EINVAL;
}
Loading