Interfacing ROS and Simulink - Problem with Publishing Input Commands

Discussions about autonomous flight in general, regardless of positioning method
Post Reply
rajavardhanr6
Beginner
Posts: 5
Joined: Tue Dec 12, 2017 11:35 am

Interfacing ROS and Simulink - Problem with Publishing Input Commands

Post by rajavardhanr6 »

Hi everyone,

I'm trying to design and implement a linear Hinfinity controller on crazyflie 2.0. I'm using a cascade controller where there will be a inner attitude controller and outer position controller. I had designed and implemented controller in Simulink. I'm thinking to use robotics system toolbox from Mathworks to interface Simulink and ROS. I want to subscribe position and velocity from ROS master and to publish thrust&torque/angular velocities of propellers. I don't have any problem with subscribing position and velocity, but the problem is I don't know how to publish thrust&torques/angular velocities. When I saw all the topics inside ROS master using rostopic list command, I didn't find any topics related to motors.The only topic I found something related to the input is crazyflie/joy.

If anyone had encountered this problem, I would like to hear from them and also any new suggestions/ideas are welcome .

Thanks in advance.

Rajavardhan, K.
Porto
Beginner
Posts: 2
Joined: Mon Jan 22, 2018 8:21 pm

Re: Interfacing ROS and Simulink - Problem with Publishing Input Commands

Post by Porto »

Hi,

What is the ROS library that you are using to get the cf messages?
In any case, you'll probably need to use the crazyflie/joy topic to send desired roll, pitch, yaw, and thrust commands (as if you were using the default pid controller), and then modify the crtp_commander_rpyt.c file so your commands correspond to the thrust&torque/angular velocities of propellers.

I've also implemented an Hinf controller on the cf2, but I do all the computations onboard and I only have one controller that does both position and attitude stabilization.

Best,
Joao
rajavardhanr6
Beginner
Posts: 5
Joined: Tue Dec 12, 2017 11:35 am

Re: Interfacing ROS and Simulink - Problem with Publishing Input Commands

Post by rajavardhanr6 »

Hi Porto,

Thanks for your reply.

I'm new to ROS. I think I'm using roscpp library. As you mentioned I didn't find any crtp_commander_rpyt.c in ROS workspace, but I have that my file in firmware. My basic idea is to use robotics system toolbox and interface Simulink and ROS. I want to generate ROS standalone node which I can run in the terminal.

https://www.youtube.com/watch?v=BwNw_-KXjbM (Interfacing Simulink and ROS)

I would like to know whether is it possible for you to share some of your previous work like any documentation stuff or files related to how you modified crtp_commander_rpyt.c .It would be helpful for my project work.

Thanks in advance.

Rajavardhan, K.
Porto
Beginner
Posts: 2
Joined: Mon Jan 22, 2018 8:21 pm

Re: Interfacing ROS and Simulink - Problem with Publishing Input Commands

Post by Porto »

Hi,

Sorry for the delayed reply, I don't check this forum often.

I don't have any documentation on how to modify the crtp file, and my code would probably confuse you more since I removed a bunch of things from the original code.
The main thing you have to modify is the function crtpCommanderRpytDecodeSetpoint inside the crtp_commander_rpyt.c file.
You'll need to add a mode that receives your desired angles or motor inputs and feeds that into the controller.
I can't really help you with the Simulink side of things since I don't have the robotics system toolbox, but I have been using the crazyflie_ros library to send desired setpoints to the cf.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Interfacing ROS and Simulink - Problem with Publishing Input Commands

Post by arnaud »

About the commander, depending of what you are trying to do it would be much easier to add a decoder function in the generic commander: https://github.com/bitcraze/crazyflie-f ... eric.c#L39. This way you do not have to remove anything, you can just add whatever you need. Your added decoder should generate a setpoint structure so if you need controls that are not currently implemented (like direct motor control), you can add them to the setpoint structure and then add support for it in the stablizer loop (https://github.com/bitcraze/crazyflie-f ... zer.c#L124)
Post Reply