Ask Your Question

Rotors control with matlab/simulink on Gazebo

asked 2019-01-03 06:24:39 -0500

Gio888 gravatar image

updated 2019-01-06 13:12:33 -0500

jayess gravatar image

Hi, I want to ask you a simple question: can I control rotors of a simulate drone on Gazebo, with matlab/simulink on ubuntu 14.04? I had installed all software components and they have a good communication (matlab-ros-gazebo). I can take some value of drone with matlab, but I don't understand how to control the velocity of drone's rotors. Thanks in advance.



$ rosinit

The value of the ROS_MASTER_URI environment variable,, will be used to connect to the ROS master.
The value of the ROS_HOSTNAME environment variable,, will be used to set the advertised address for the ROS node.
Warning: The IP address in the "NodeHost" setting is not associated with any network
interface. It is possible that MATLAB cannot be reached by other ROS nodes. 
  In robotics.ros.internal.Net.generateNodeHost (line 368)
  In robotics.ros.Node.parseArguments (line 313)
  In rosinit (line 92) 
Initializing global node /matlab_global_node_54033 with NodeURI


$ rostopic list


Gio8, [6 gen 2019, 19:28:27]:
/sonar_front ...
edit retag flag offensive close merge delete


I copied the information from your answer into your question since it's actually an update to your question and not an answer. I did my best to format your question, but please feel free to edit it as you see fit making sure to use the format (101010) button for code/output.

jayess gravatar image jayess  ( 2019-01-06 13:15:00 -0500 )edit

The problem seems to be with re-creating the topic. Check my updated answer.

robowarrior gravatar image robowarrior  ( 2019-01-08 04:57:08 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-01-04 13:02:54 -0500

robowarrior gravatar image

updated 2019-01-08 04:55:54 -0500

Usually, to control the speeds of a UAV in rotorS, you need to publish an array of speeds to a particular topic, right?

For Eg: To set all of the motor speeds of 'firefly' UAV to 100, we run the command

rostopic pub /firefly/command/motor_speed mav_msgs/Actuators '{angular_velocities: [100, 100, 100, 100, 100, 100]}'

Now, the equivalent to this command, using a MATLAB script and rospublisher, is as follows: (This publishes messages to the ROS network.)

motor_speeds = rospublisher('/firefly/command/motor_speed','mav_msgs/Actuators');
msg = rosmessage(motor_speeds);
msg.Data = '{angular_velocities: [100, 100, 100, 100, 100, 100]}';
send(motor_speeds, msg);

PS: Try this. Let me know what happens. Coz, I haven't run this. I just followed that above link. So, let me know how it goes.


In case the ROS topic already exists, follow this:

motor_speeds_topic = '/firefly/command/motor_speed';
msg = rosmessage(motor_speeds);
msg.Data = '{angular_velocities: [100, 100, 100, 100, 100, 100]}';
send(motor_speeds_topic, msg);

Change the value of motor_speeds_topic to that existing topic you want.

Peace fellazz!!

edit flag offensive delete link more


Hi! Can you please send me the link to this repository? I would also install the same simulator for my project. Thanks

Wajeeh gravatar image Wajeeh  ( 2019-04-09 14:27:57 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2019-01-03 06:24:39 -0500

Seen: 773 times

Last updated: Apr 09 '19