ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Controlling Gazebo Cessna Plane with ROS

asked 2019-03-16 06:52:55 -0500

thegreek gravatar image

updated 2019-03-16 22:23:35 -0500

jayess gravatar image

Hi. https://answers.ros.org/questions/sco... I am new to Gazebo and ROS and i want to control the example Cessna plane in Gazebo using ROS.

I am starting the Gazebo using following command:

gazebo --verbose worlds/cessna_demo.world

It allows me control the plane with keyboard input.

But i want to control the plane with ROS (rospy and python).

In the world file there is a plugin:

  <!-- Plugins for controlling the thrust and control surfaces -->
  <plugin name="cessna_control" filename="libCessnaPlugin.so">
   <propeller>cessna_c172::propeller_joint</propeller>
   <propeller_max_rpm>2500</propeller_max_rpm>
   <left_aileron>cessna_c172::left_aileron_joint</left_aileron>
   <left_flap>cessna_c172::left_flap_joint</left_flap>
   <right_aileron>cessna_c172::right_aileron_joint</right_aileron>
   <right_flap>cessna_c172::right_flap_joint</right_flap>
   <elevators>cessna_c172::elevators_joint</elevators>
   <rudder>cessna_c172::rudder_joint</rudder>
   <propeller_p_gain>10000</propeller_p_gain>
   <propeller_i_gain>0</propeller_i_gain>
   <propeller_d_gain>0</propeller_d_gain>
   <surfaces_p_gain>2000</surfaces_p_gain>
   <surfaces_i_gain>0</surfaces_i_gain>
   <surfaces_d_gain>0</surfaces_d_gain>
   </plugin>

How can i edit this so i can control the plane with ROS?

Thanks...

edit retag flag offensive close merge delete

Comments

Hi, if you have solved this issue could you please share your solution ? Thanks...

zuygar gravatar image zuygar  ( 2020-06-03 04:44:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-02-07 17:15:25 -0500

Hi there, I was having the same challenge and I figure a solution for this problem. I know the post is old but it may give some clues for someone having the same troubles.

So first, the C++ file where the libCessnaPlugin.so comes from does not use any instance of ROS. It does mention that publishes the Pose and subscribes the motor speed but no through a ROS network since this files doesn't call anything from there. So I found this repo (https://github.com/AurelienRoy/ardupi...), where there is a plugin called aircraft_plugin which in essence is the same as the cessna_plugin but now this one does make use of a ROS node and subscribes to a topic called motor_message. This topic used the message CommandMotorSpeed that comes from the mav_com_mav_msgs package (I got it from here https://github.com/PX4/mav_comm).

Now, I tried to catkin_make the aircraftplugin and found several error due to deprecated fucntions of Gazebo since I was using Gazebo 9, and this plugin is old, so I had to change the old functions with the replacements base on this post (https://github.com/osrf/gazebo/blob/g...) and then I has able to compile the package.

Now, in order to attach the plugin to the Cessna model I added these lines in the URDF:

  <gazebo>
     <plugin name="aircraft_plugin" filename="libaircraft_plugin.so">
        <commandSubTopic>/command/motor_speed</commandSubTopic>
        <left_aileron>left_aileron_joint</left_aileron>
        <left_flap>left_flap_joint</left_flap>
        <right_aileron>right_aileron_joint</right_aileron>
        <right_flap>right_flap_joint</right_flap>
        <elevators>elevators_joint</elevators>
        <rudder>rudder_joint</rudder>
        <propeller>propeller_joint</propeller>
        <propeller_link>propeller</propeller_link>
        <propeller_max_rpm>37500</propeller_max_rpm>
     </plugin>
  </gazebo>

Finally, it took me a while to know how to publish in the topic so I could move the aricraft control surfaces, and this format worked for me (For testing purposes)

rostopic pub -r 10 /command/motor_speed mav_msgs/CommandMotorSpeed '{motor_speed: [100, 100, 100, 100, 100]}'

I am still new on Gazebo ROS development, but at least this worked for me, so I don't know if there was an easier solution, but it worked for me.

Hope it helps.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2019-03-16 06:52:55 -0500

Seen: 471 times

Last updated: Mar 16 '19