Rosflight_simulation

Hello,

We are trying to make the rosflight gazebo simulation work. We are not capable to do so with the instructions provided by the webpage. My question to the developers is, does the simulation work?
(We have tested in both melodic and kinetic with the same results.)

Thanks in advance.
Mikel

1 Like

Hey,

we have a gazebo simulation running in our project. It’s not my part as im working on the hardware, but nevertheless maybe I can provide some help?
What did you tried so far?

Regards Rafael

Hello,

We have tried to launch the simulation in ROS melodic and Kinetic, but when the simulation launches, the drone appears without any texture and with half the drone under the ground (see the image attached). There is no tf related to the simulation (that we think that should be there).

photo_2019-11-30_20-27-14
photo_2019-11-30_20-27-21

If you have any other instructions different to the ones from the web, we’d be thankful if you share it with us.

Regards,
Mikel

Hi @LarreaMikel,

The behavior you’ve described so far matches the expected behavior. The Gazebo simulation is pretty minimal; it runs the flight controller firmware as software-in-the-loop (SIL) and simulates the basic sensors (IMU, barometer, etc.), but that’s about it. It’s intended to help test your basic configuration, and as a starting point for application-specific simulation setups. The graphics are not fancy, and the drone appearing to be halfway underground is not pretty, but is just the way it’s set up.

To test if it’s working, the first thing I’d do would be to start rosflight_io in UDP mode (so it communicates with the SIL firmware over UDP as opposed to over a serial connection with hardware):

rosrun rosflight rosflight_io _udp:=true

With that running, you should be able to do something like rostopic hz /imu/data and see that simulated IMU data is being published. The next step after that is to run through the basic flight controller setup steps as if it were real hardware, then connect a simulated RC transmitter (instructions on this page) and see if you can get it flying!

As far as there being tf published, that’s something I guess we just never implemented since we don’t use it that much ourselves. If that’s a feature that’s useful to you, consider opening an issue or pull request on GitHub.

Does that help?

hello there i am stuck here, running through the basic flight controller setup steps are not clear can you please elaborate https://docs.rosflight.org/user-guide/getting-started/#general-setup

It will be easiest if you create a new topic for us to discuss this on. Could you also explain what you don’t understand from the documentation?

i think it is just a continuation/follow up on what has already been discussed. I launched the simulation on gazebo now i want to fly the drone what is the next step after running rosrun rosflight rosflight_io _udp:=true on a separate terminal. but also running that command seems to be throwing errors

Those errors are exactly what you would have with a new drone that isn’t set up. In order to fly, you’ll need to:

  1. Configure Parameters
  2. Connect a simulated RC controller (perhaps with rosflight_joy)
  3. Optionally run /param_write to save the parameters so you don’t have to do this again.
  4. Calibrate stuff. Run the rosservices calibrate_imu and calibrate_baro

The situation is exactly the same with a real aircraft, except you would have a real RC connection.

@BillThePlatypus, I am also having difficulties in simulation, especially rosflight_joy. Do I clone rosflight_joy into rosflight_ws/src? I have pygame installed as per instructions but when I run, rosrun rosflight_joy rc_keyboard RC:=/fixedwing/RC, I get pygame not found.
Basically, gazebo and rosflight_io are running but I have no way to “launch” the aircraft.

Perhaps try sudo apt install python-pygame.

You can find out what signals are getting through from the controller using:

rostopic echo /fixedwing/RC

I found also that the setting in rosflight_keyboard_base.py of (1,1) for the size of the window to capture the keystrokes was unhelpful. If you change it to:

    screen = pygame.display.set_mode((400, 400))

it’s much easier to find and put on the top.

(Note to authors, not everyone has a joystick to hand when they’re trying to get this thing to work from scratch from no knowledge. If I get it to work, then I might go and try to source a joystick, because only then might it be worth it!)

Other grave difficulties encountered along the way:

The /param_get service created by the rosflight_io node should probably be in a namespace, such as “/rosflight_io/param_get”

This had me confused with the “rosparam” function, which is a completely different set of parameters.

The remap line at the bottom of https://docs.rosflight.org/user-guide/gazebo_simulation/ is missing a “/” at the start of the “to” parameter:

I’m doing the fixedwing type. Then, after a lot more hassle with unfamiliar stuff (I do not have an RC kit, I’m just trying to make a simulation), I uncovered the following four commands you need to run to make it even possible (running from the keyboard).

rosservice call /calibrate_imu
rosservice call /param_set FIXED_WING 1.0
rosservice call /param_set ARM_CHANNEL 4
rosservice call /param_set MIXER 10

At this point it’s useful to have a window showing you

rostopic echo /rc_raw

You can now click ‘o’ (which is bound to channel 4, and the arms the motors) and it will give errors that it cannot when the RC throttle is high.

Hold down ‘s’ to lower this throttle from its default middle value. Now you can hold down ‘w’ to set the throttle up, and it will finally take off. Phew!

Should I put comments into some github issues so they are more likely to get fixed?

1 Like

Hi Julian!

Thanks for the detailed report! This is great stuff.

I would really appreciate an Issue (or even better, a pull request!). It would be great to fold these improvements into our roadmap.

I have a problem with my ROSflight maybe there are some issues that I don’t understand I have hard-coded

all actuators to 0 and then I give the drone a throttle it keeps on orbiting along the y-axis I don’t know what might be the problem because I thought when it is given only a forward movement it has to go on a straight line not orbit as if it has a loop somewhere.

Thank you so much for this much needed information.
Excuse me for the noob question but I’m working on my bachelor thesis and I am lost.

What do i need to change in order to make it work for a multir-rotor and not a fixed wing?
I tried

rosservice call /param_set MULTIROTOR 1.0
and
rosservice call /param_set MULTI_ROTOR 1.0

None of them work. Also how do i know what the key for arming is? I tried everything to arm the drone and its not working and sometimes pygame crashes.