gtfactslab / CrazySim

A Crazyflie simulator for testing CFLib Python code, ROS 2 nodes through Crazyswarm2, custom crazyflie-firmware modules, or perform a flight demo on the crazyflie-python-client.
GNU General Public License v3.0
65 stars 8 forks source link

how to add custom firmware #14

Open hyeminsong opened 1 week ago

hyeminsong commented 1 week ago

Hello!

I want to use this project for checking my firmware.

mkdir -p sitl_make/build && cd $_
cmake ..
make all

I did the build above and also checked that /sitl_make/CMakeList.txt has a list of codes that I added to /src. (${CF2_SITL_SRCS_DIR}/modules/src/controller/controller..c) I want to add my controller, is there anything else that needs to be done separately?

Additionally, I was wondering if you could know how to add multiranger deck in simulation(gazebo).

Thank you!

llanesc commented 1 week ago

Hi @hyeminsong, you can follow this blog post for steps on how to add a new controller. The steps to add to KBuild can be replaced by the CMakeLists.txt. I plan to switch over to KBuild soon to be consistent with the official firmware. Then to use your controller you need to modify the stabilizer.controller parameter through CFLib, crazyflie-client, Crazyswarm2, etc.

Right now I don't currently support the multiranger deck. I think this will require setting up 5 linear versions of the lidar sensor with different poses on the cf base_link. This can be done in the models folder by creating a new model called crazyflie_multiranger. Then, you will need a new plugin or modify the old one to subscribe to those 5 lidar messages and send it to the firmware using a custom CRTP packet like what was done for the IMU. The issue is data transmission to the firmware. The deck code is typically heavily embedded in the firmware with device comms, so it may require a custom file based on this range source code that logs to the range log group.

hyeminsong commented 1 week ago

Thank you for your kind reply. I think I didn't explain my situation properly, so I'm adding content.

I've already tested it in hardware with custom controller. I'd like to proceed with further modification on the simulation with your project. Currently, I can't receive the data of the log group I added to controller at this time(TOC Not exist error). So, I think this error came form controller not added properly. Because of that, I wonder if additional work is needed in the simulation.

llanesc commented 1 week ago

So you tested your controller on hardware and you can see the custom log group on the client/cflib, but when you moved it to the CrazySim firmware you cannot? There shouldn't be any extra steps other than adding the source files to the CMakeLists file in sitl_make and registering the controller in the controller.c and controller.h file. Can you check if the log group exists by using the custom crazyflie-client and connecting to CrazySim?