PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
7.83k stars 13.22k forks source link

[Bug] `dyn` dynamically loads the PX4 module routine #22027

Open Byzeal opened 10 months ago

Byzeal commented 10 months ago

Describe the bug

Hello, I am learning the PX4 software system, and recently I am learning the example in /src/example, where the dyn_hello example has been unable to achieve the experimental effect. I have already opened dyn_hello in example through the 'make px4_sitl_default boardconfig' command, and then I conducted the 'make px4_sitl_default' command, also recompiled and in the path: \build\px4_sitl_default\src\examples\dyn_hello generates the examplesdyn_hello.px4mod file, and then, I compile with the 'make px4_sitl_default jmavsim_shell' command, and enter the command dyn./examplesdyn_hello.px4mod in the pxh window, but it shows: ERROR [dyn] ./examples__dyn_hello.px4mod: cannot open shared object file: No such file or directory Command 'dyn' failed, returned 1.

To Reproduce

root@R:/mnt/c/PX4PSP/Firmware# make px4_fmu-v6c_default boardconfig [1/1] cd /mnt/c/PX4PSP/Firmware && /usr/bin/cmake -E env P...P/Firmware/build/px4_fmu-v6c_default/NuttX/apps_copy.stamp Loaded configuration '/mnt/c/PX4PSP/Firmware/build/px4_fmu-v6c_default/boardconfig' Configuration saved to '/mnt/c/PX4PSP/Firmware/build/px4_fmu-v6c_default/boardconfig' Loaded configuration '/mnt/c/PX4PSP/Firmware/build/px4_fmu-v6c_default/boardconfig' Minimal configuration saved to 'defconfig' root@R:/mnt/c/PX4PSP/Firmware# make px4_fmu-v6c_default [1/1] Re-running CMake... -- PX4 version: v1.13.3 -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.9", minimum required is "3") -- PX4 config file: /mnt/c/PX4PSP/Firmware/boards/px4/fmu-v6c/default.px4board -- PLATFORM nuttx -- TOOLCHAIN arm-none-eabi -- ARCHITECTURE cortex-m7 -- ROMFSROOT px4fmu_common -- IO px4_io-v2_default -- SERIAL_GPS1 /dev/ttyS0 -- SERIAL_GPS2 /dev/ttyS6 -- SERIAL_TEL1 /dev/ttyS5 -- SERIAL_TEL2 /dev/ttyS3 -- SERIAL_TEL3 /dev/ttyS1 -- UAVCAN_INTERFACES 2 -- UAVCAN_TIMER_OVERRIDE 2 -- PX4 config: px4_fmu-v6c_default -- PX4 platform: nuttx -- cmake build type: MinSizeRel -- Enabling double FP precision hardware instructions -- drivers/px4io: ROMFS including px4_io-v2_default -- Found PythonInterp: /usr/bin/python3 (found version "3.6.9") -- Using C++11 -- Release build type: MinSizeRel -- ROMFS: ROMFS/px4fmu_common -- ROMFS: Adding platforms/nuttx/init/stm32h7/rc.board_arch_defaults -> /etc/init.d/rc.board_arch_defaults -- ROMFS: Adding boards/px4/fmu-v6c/init/rc.board_defaults -> /etc/init.d/rc.board_defaults -- ROMFS: Adding boards/px4/fmu-v6c/init/rc.board_sensors -> /etc/init.d/rc.board_sensors -- ROMFS: Adding boards/px4/fmu-v6c/extras/px4_fmu-v6c_bootloader.bin -> /etc/extras/px4_fmu-v6c_bootloader.bin -- ROMFS: Adding boards/px4/fmu-v6c/extras/px4_io-v2_default.bin -> /etc/extras/px4_io-v2_default.bin -- Configuring done -- Generating done -- Build files have been written to: /mnt/c/PX4PSP/Firmware/build/px4_fmu-v6c_default [1049/1051] Linking CXX executable px4_fmu-v6c_default.elf Memory region Used Size Region Size %age Used ITCM_RAM: 0 GB 64 KB 0.00% FLASH: 1898540 B 1920 KB 96.56% DTCM1_RAM: 0 GB 64 KB 0.00% DTCM2_RAM: 0 GB 64 KB 0.00% AXI_SRAM: 61168 B 512 KB 11.67% SRAM1: 0 GB 128 KB 0.00% SRAM2: 0 GB 128 KB 0.00% SRAM3: 0 GB 32 KB 0.00% SRAM4: 0 GB 64 KB 0.00% BKPRAM: 0 GB 4 KB 0.00% [1051/1051] Creating /mnt/c/PX4PSP/Firmware/build/px4_fmu-v6c_default/px4_fmu-v6c_default.px4 root@R:/mnt/c/PX4PSP/Firmware# make px4_sitl_default jmavsim_shell [2/3] git submodule Tools/jMAVSim [3/3] cd /mnt/c/PX4PSP/Firmware/build/px4_sitl_default/tmp...PSP/Firmware /mnt/c/PX4PSP/Firmware/build/px4_sitl_default SITL ARGS sitl_bin: /mnt/c/PX4PSP/Firmware/build/px4_sitl_default/bin/px4 debugger: none program: jmavsim model: shell world: none src_path: /mnt/c/PX4PSP/Firmware build_path: /mnt/c/PX4PSP/Firmware/build/px4_sitl_default SITL COMMAND: "/mnt/c/PX4PSP/Firmware/build/px4_sitl_default/bin/px4" "/mnt/c/PX4PSP/Firmware/build/px4_sitl_default"/etc -s etc/init.d-posix/rcS -t "/mnt/c/PX4PSP/Firmware"/test_data Creating symlink /mnt/c/PX4PSP/Firmware/build/px4_sitl_default/etc -> /mnt/c/PX4PSP/Firmware/build/px4_sitl_default/tmp


| \ \ \ / / / | | |/ / \ V / / /| | | / / \ / /_| | | | / /^\ \ __ | _| \/ \/ |/

px4 starting.

INFO [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0 /mnt/c/PX4PSP/Firmware/Tools/jmavsimrun.sh: line 65: ant: command not found INFO [param] selected parameter default file eeprom/parameters [param] parameter file not found, creating eeprom/parameters_ INFO [px4] Startup script returned successfully pxh> help Builtin Commands: actuator_test airship_att_control airspeed_selector attitude_estimator_q battery_simulator camera_feedback camera_trigger cdev_test commander commander_tests control_allocator controllib_test dataman dyn ekf2 ex_fixedwing_control failure fake_gps fake_imu fake_magnetometer flight_mode_manager fw_att_control fw_autotune_attitude_control fw_pos_control_l1 gimbal gps gyro_calibration gyro_fft hello hrt_test land_detector landing_target_estimator led_control list_files list_tasks listener load_mon local_position_estimator logger mag_bias_estimator manual_control mavlink mavlink_tests mc_att_control mc_autotune_attitude_control mc_hover_thrust_estimator mc_pos_control mc_rate_control mixer motor_test navigator param perf pwm pwm_out_sim px4_mavlink_debug px4_simple_app rc_tests rc_update replay rover_pos_control rover_steering_control rpm_simulator sd_bench send_event sensor_baro_sim sensor_gps_sim sensor_mag_sim sensors shutdown simulator sleep system_time temperature_compensation tests tone_alarm tune_control uorb uorb_tests uuv_att_control uuv_example_app uuv_pos_control ver vtol_att_control work_item_example work_queue wqueue_test pxh> dyn

Description

Load and run a dynamic PX4 module, which was not compiled into the PX4 binary.

Example

$ dyn ./he Usage: dyn [arguments...]

File containing the module [arguments...] Arguments to the module Command 'dyn' failed, returned 1. pxh> dyn ./examples__dyn_hello.px4mod ERROR [dyn] ./examples__dyn_hello.px4mod: cannot open shared object file: No such file or directory Command 'dyn' failed, returned 1. pxh> dyn ./examples__dyn_hello.px4mod ERROR [dyn] ./examples__dyn_hello.px4mod: cannot open shared object file: No such file or directory Command 'dyn' failed, returned 1. pxh> ### Expected behavior 1, I want to know how to implement the effect of this routine? 2. Do not understand how Posix and Nuttx systems operate when SITL and HITL are implemented? ### Screenshot / Media _No response_ ### Flight Log None ### Software Version 1.13.3 ### Flight controller Multicopter ### Vehicle type Multicopter ### How are the different components wired up (including port information) _No response_ ### Additional context _No response_
dagar commented 9 months ago

It's likely a path issue. These dynamic modules were a drive by contribution that we don't really use for anything and as a result haven't maintained.

Would you be interested in getting this working again and putting proper testing in place?

Byzeal commented 9 months ago

Thank you very much for your reply. For now, I am only using this feature for learning and use. I am wondering if I can use it to dynamically replace the PX4 controller during the simulation process.

Meanwhile, since the PX4 software system comes with this routine, should it be possible to maintain the integrity of the routine, which is also more user-friendly for beginners.