Ask Your Question
0

Rotors control with matlab/simulink on Gazebo

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

Gio888 gravatar image

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

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.


Update

rosinit

$ rosinit

The value of the ROS_MASTER_URI environment variable, http://127.0.1.1:11311, will be used to connect to the ROS master.
The value of the ROS_HOSTNAME environment variable, 127.0.1.1, will be used to set the advertised address for the ROS node.
Warning: The IP address 127.0.1.1 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 http://127.0.1.1:37780/

rostopic

$ rostopic list

/clock                                                                  
/command/motors                                                         
/command/rate                                                           
/diagnostics                                                            
/erlecopter/bottom/camera_info                                          
/erlecopter/bottom/image_raw                                            
/erlecopter/bottom/image_raw/compressed                                 
/erlecopter/bottom/image_raw/compressed/parameter_descriptions          
/erlecopter/bottom/image_raw/compressed/parameter_updates               
/erlecopter/bottom/image_raw/compressedDepth                            
/erlecopter/bottom/image_raw/compressedDepth/parameter_descriptions     
/erlecopter/bottom/image_raw/compressedDepth/parameter_updates          
/erlecopter/bottom/image_raw/theora                                     
/erlecopter/bottom/image_raw/theora/parameter_descriptions              
/erlecopter/bottom/image_raw/theora/parameter_updates                   
/erlecopter/bottom/parameter_descriptions                               
/erlecopter/bottom/parameter_updates                                    
/erlecopter/command/attitude                                            
/erlecopter/command/motor_speed                                         
/erlecopter/fix                                                         
/erlecopter/fix/position/parameter_descriptions                         
/erlecopter/fix/position/parameter_updates                              
/erlecopter/fix/status/parameter_descriptions                           
/erlecopter/fix/status/parameter_updates                                
/erlecopter/fix/velocity/parameter_descriptions                         
/erlecopter/fix/velocity/parameter_updates                              
/erlecopter/fix_velocity                                                
/erlecopter/front/camera_front_info                                     
/erlecopter/front/image_front_raw                                       
/erlecopter/front/image_front_raw/compressed                            
/erlecopter/front/image_front_raw/compressed/parameter_descriptions     
/erlecopter/front/image_front_raw/compressed/parameter_updates          
/erlecopter/front/image_front_raw/compressedDepth                       
/erlecopter/front/image_front_raw/compressedDepth/parameter_descriptions
/erlecopter/front/image_front_raw/compressedDepth/parameter_updates     
/erlecopter/front/image_front_raw/theora                                
/erlecopter/front/image_front_raw/theora/parameter_descriptions         
/erlecopter/front/image_front_raw/theora/parameter_updates              
/erlecopter/front/parameter_descriptions                                
/erlecopter/front/parameter_updates                                     
/erlecopter/gazebo/command/motor_speed                                  
/erlecopter/ground_truth/imu                                            
/erlecopter/ground_truth/odometry                                       
/erlecopter/ground_truth/pose                                           
/erlecopter/ground_truth/pose_with_covariance                           
/erlecopter/ground_truth/position                                       
/erlecopter/ground_truth/transform

Gio8, [6 gen 2019, 19:28:27]:
/erlecopter/imu                                                         
/erlecopter/motor_speed/0                                               
/erlecopter/motor_speed/1                                               
/erlecopter/motor_speed/2                                               
/erlecopter/motor_speed/3                                               
/erlecopter/motors                                                      
/erlecopter/waypoint                                                    
/erlecopter/wind                                                        
/gazebo/link_states                                                     
/gazebo/model_states                                                    
/gazebo/parameter_descriptions                                          
/gazebo/parameter_updates                                               
/gazebo/set_link_state                                                  
/gazebo/set_model_state                                                 
/imu                                                                    
/mavlink/from                                                           
/mavlink/to                                                             
/mavros/battery                                                         
/mavros/cam_imu_sync/cam_imu_stamp                                      
/mavros/extended_state                                                  
/mavros/global_position/compass_hdg                                     
/mavros/global_position/global                                          
/mavros/global_position/local                                           
/mavros/global_position/raw/fix                                         
/mavros/global_position/raw/gps_vel                                     
/mavros/global_position/rel_alt                                         
/mavros/imu/atm_pressure                                                
/mavros/imu/data                                                        
/mavros/imu/data_raw                                                    
/mavros/imu/mag                                                         
/mavros/imu/temperature                                                 
/mavros/local_position/odom                                             
/mavros/local_position/pose                                             
/mavros/local_position/velocity                                         
/mavros/manual_control/control                                          
/mavros/mission/waypoints                                               
/mavros/radio_status                                                    
/mavros/rc/in                                                           
/mavros/rc/out                                                          
/mavros/rc/override                                                     
/mavros/setpoint_accel/accel                                            
/mavros/setpoint_position/local                                         
/mavros/setpoint_raw/attitude                                           
/mavros/setpoint_raw/global                                             
/mavros/setpoint_raw/local                                              
/mavros/setpoint_raw/target_attitude                                    
/mavros/setpoint_raw/target_global                                      
/mavros/setpoint_raw/target_local                                       
/mavros/setpoint_velocity/cmd_vel                                       
/mavros/state                                                           
/mavros/time_reference                                                  
/mavros/vfr_hud                                                         
/mavros/wind_estimation                                                 
/rosout                                                                 
/rosout_agg                                                             
/scan                                                                   
/sonar_d                                                         
/sonar_front ...
(more)
edit retag flag offensive close merge delete

Comments

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 imagejayess ( 2019-01-06 13:15:00 -0600 )edit

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

robowarrior gravatar imagerobowarrior ( 2019-01-08 04:57:08 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

robowarrior gravatar image

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

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.)

rosinit
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.


UPDATE:

In case the ROS topic already exists, follow this:

rosinit
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

Comments

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

Wajeeh gravatar imageWajeeh ( 2019-04-09 14:27:57 -0600 )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

Stats

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

Seen: 381 times

Last updated: Apr 09 '19