Matlab controllers and Crazyflie ROS package

Firmware/software/electronics
Post Reply
flavia1394
Beginner
Posts: 23
Joined: Fri Mar 30, 2018 5:10 pm

Matlab controllers and Crazyflie ROS package

Post by flavia1394 » Thu Jul 05, 2018 9:04 pm

HI,
I would like to use the Matlab controller that I created in these month to let fly the crazyflie. The first step was putting all the sensor value with the ROS package in Matlab, now I would like simply to send a trajectory from MATLAB to the drone and then using the controllers that I created.

Can you help me? I will be more specific:
1) where should I send the trajectory with ROS? Is the topic /crazyflie/goal useful for this?
2) I created the publishers and subscribers in a Simulink file and everything works fine because in the graphs I can see the sine wave and the other command. The image below shows the model in Simulink. My question is: how can I let the crazyflie fly? Because even though I publish the topic and it appears in the list, nothing happen to the drone. What am I missing?

Should I rewrite the controller class in the crazyflie ros package?
Schermata 2018-07-05 alle 4.57.19 PM.png
Attachments
Schermata 2018-07-05 alle 4.56.43 PM.png
Last edited by flavia1394 on Fri Jul 06, 2018 4:11 pm, edited 1 time in total.

flavia1394
Beginner
Posts: 23
Joined: Fri Mar 30, 2018 5:10 pm

Re: Drone fly with Matlab controller

Post by flavia1394 » Fri Jul 06, 2018 4:01 pm

Should I rewrite the controller class into the Ros crazyflie package?

whoenig
Expert
Posts: 283
Joined: Mon Oct 27, 2014 2:55 am

Re: Matlab controllers and Crazyflie ROS package

Post by whoenig » Sat Jul 07, 2018 12:56 am

If your controller is a position controller (and you want to use the on-board attitude controller), you can publish your target values to the cmd_vel topic. One example of such approach is the crazyflie_controller package in the crazyflie_ros stack.
If you want to replace the complete controller, the latency will be too high to run it off-board and achieve satisfactory performance. In this case, you should re-write your controller in C and include it in the firmware. One example of such approach is controller_mellinger.c in the firmware.

flavia1394
Beginner
Posts: 23
Joined: Fri Mar 30, 2018 5:10 pm

Re: Matlab controllers and Crazyflie ROS package

Post by flavia1394 » Tue Jul 10, 2018 1:47 pm

whoenig wrote:
Sat Jul 07, 2018 12:56 am
If your controller is a position controller (and you want to use the on-board attitude controller), you can publish your target values to the cmd_vel topic. One example of such approach is the crazyflie_controller package in the crazyflie_ros stack.
If you want to replace the complete controller, the latency will be too high to run it off-board and achieve satisfactory performance. In this case, you should re-write your controller in C and include it in the firmware. One example of such approach is controller_mellinger.c in the firmware.

Thank you so much for your answer, this things help me for the thesis. My controllers in MATLAB are PID, LQG and LQT.

I saw that the cmd_vel is a topic that have roll pitch and yaw rate that are angles, and only the thrust is a PWM. In my LQG and LQT controllers I have the PWM values to sent to the motors. So do you suggest to rewrite the controller class in the ros package with a new topic that receive the PWM instead of roll pitch and yaw rate??

whoenig
Expert
Posts: 283
Joined: Mon Oct 27, 2014 2:55 am

Re: Matlab controllers and Crazyflie ROS package

Post by whoenig » Tue Jul 10, 2018 7:57 pm

For controllers that output PWM directly, I suggest to implement your code in C, directly in the firmware. The latency is too high and bandwidth too low to achieve good control results if the controller is running off-board.

flavia1394
Beginner
Posts: 23
Joined: Fri Mar 30, 2018 5:10 pm

Re: Matlab controllers and Crazyflie ROS package

Post by flavia1394 » Fri Jul 13, 2018 3:29 am

whoenig wrote:
Tue Jul 10, 2018 7:57 pm
For controllers that output PWM directly, I suggest to implement your code in C, directly in the firmware. The latency is too high and bandwidth too low to achieve good control results if the controller is running off-board.
Thank you for your answer.

Post Reply