Interfacing ROS with Simulink and Crazyflie

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

Interfacing ROS with Simulink and Crazyflie

Post by flavia1394 »

Hi everyone,

I'm doing my thesis project about the formation of three Crazyflie drones. I have the loco positioning system.
For now I made the model in Simulink, with three different controllers: LQGI, LQT and PID and I wrote an algorithm that allows three drones to fly with the same trajectory without any clash. Now I would like to do the same things, but in the practice. I would like to combine the environment of Simulink with ROS, but I really don't know where I should start.

1) First of all I would like to know if ROS can allow me to comunicate with Crazyflie from Simulink and if yes, which are the steps to install it? Should I install ROS in both environments?

2) Is there a way to put the controllers that I made on Simulink in the Crazyflie without C++ code?

3) If not, what is the best way to control the Crazyflie with PID or with LQT controller and make a swarm algorithm?

4) Also I tried the command "rosinit" in MATLAB, but it gives me the following error. Must I use a bridged network to use ROS?

Code: Select all

'Cannot connect to ROS master at http://172.30.152.10:11311. Check the specified address or hostname.'


Thank you for the patience :)
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: Interfacing ROS with Simulink and Crazyflie

Post by whoenig »

1) On the matlab side you would need to install the robotics toolbox (https://www.mathworks.com/hardware-supp ... ystem.html). On a machine with Ubuntu (can be the same one or a different one), you need to install ROS.

2) Probably not, because of bandwidth/latency issues. You would basically need to log the current state and send direct motor commands from simulink. The later is not yet supported in the firmware (but easy to add). The issue is that you will only be able to run your algorithm at 100 Hz (because of limitations of the current logging system), with additional radio latency. On-board controllers run at 500 Hz.

3) Convert your simulink model to C code and integrate it into the firmware.

4) The machine running ROS must run a rosmaster (e.g., by executing roscore). The ROS machine and matlab machine must be connected over the network.
flavia1394
Beginner
Posts: 23
Joined: Fri Mar 30, 2018 5:10 pm

Re: Interfacing ROS with Simulink and Crazyflie

Post by flavia1394 »

Thank you for these informations! :) You have been very helpful!
flavia1394
Beginner
Posts: 23
Joined: Fri Mar 30, 2018 5:10 pm

Re: Interfacing ROS with Simulink and Crazyflie

Post by flavia1394 »

whoenig wrote: Thu May 31, 2018 2:26 am 1) On the matlab side you would need to install the robotics toolbox (https://www.mathworks.com/hardware-supp ... ystem.html). On a machine with Ubuntu (can be the same one or a different one), you need to install ROS.

2) Probably not, because of bandwidth/latency issues. You would basically need to log the current state and send direct motor commands from simulink. The later is not yet supported in the firmware (but easy to add). The issue is that you will only be able to run your algorithm at 100 Hz (because of limitations of the current logging system), with additional radio latency. On-board controllers run at 500 Hz.

3) Convert your simulink model to C code and integrate it into the firmware.

4) The machine running ROS must run a rosmaster (e.g., by executing roscore). The ROS machine and matlab machine must be connected over the network.

Sorry if I bother you again, can you please explain the steps to set the comunication between ROS and Crazyflie?
I installed the ROS package(https://github.com/whoenig/crazyflie_ros), and after I type

Code: Select all

roscore 
, everything seems fine and the

Code: Select all

rosrun crazyflie_tools scan
gave me the crazyflie uri, but when I write:

Code: Select all

rostopic list 
the only two topics that I see are:
/rosout
/rosout_agg
What am I missing? I would like to display the imu values and publish them and then find a way to have them in Matlab.

Thank you
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: Interfacing ROS with Simulink and Crazyflie

Post by whoenig »

You'll need to run the crazyflie_server with the crazyflie you found using `scan`. There are some example launch files in the crazyflie_demo package.
Post Reply