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
72 stars 15 forks source link

Modified version of the CFlib backend and cmd_vel_legacy topic #9

Closed GusBon closed 6 months ago

GusBon commented 6 months ago

Hi, I am trying to control a Crazyflie by sending to it roll pitch yaw and thrust commands. I have developed a node that publish on topics of Crazyswarm2.

But after some tests, the node appears to be working but nothing happens on Crazysim, the propellers of the Crazyflie are not turning. I am publishing on the cmd_vel_legacy topic. The node is publishing correctly on the topic when I echo it and the crazyflie servers seems to receive the data also. For more details, I have already discussed about it on the Crazyswarm2 github (https://github.com/IMRCLab/crazyswarm2/discussions/499). And as a result of this discussion, it appears that the modified version of the Cflib used in Crazysim seems to be where the things are malfunctioning.

I have tested with another node to publish on the cmd_hover topic, and this time everything works fine, the drone fly to the wanted position.

llanesc commented 6 months ago

It could be a few things. I am using a slightly modified version of Crazyswarm2 which is a bit outdated. The modifications I made are to directly control attitude setpoints through its own topic instead of the cmd_vel_legacy option. Although that shouldn't stop you from using cmd_vel_legacy. Are you initially sending all zeros like I do here. I believe this a requirement from the firmware when you want to switch to the low level commander. Otherwise the firmware will reject all the inputs and the motors won't spin.

GusBon commented 6 months ago

Ok, Thank for this answer and for the precision on the attitude set points topic. So, as you said the problem was that i didn't publish all zeros at the beginning of the sim. It is now working by doing so. Thanks a lot ! : )