lis-epfl / swarmlab

SmarmLab: a versatile Matlab package for drone swarm simulation.
MIT License
211 stars 75 forks source link

Error in wind simulation #6

Open gabrieleincerti opened 3 years ago

gabrieleincerti commented 3 years ago

Hi I’m Gabriele, I downloaded the first release of SwarmLab library for Matlab R2021_a, the computer I use is a Macbook with M1 microprocessor. Testing the library I found some problems, using the GUI interface specially for wind command. In every type of simulation (Controller, Path Manager, Path Follower, Path Planner) flagging the function Add Wind or Add Gust the simulation stops and Matlab report an error in the get_wind file; checking this file I have found a syntax error in line 61(the function in the file is called TurbolentWindFieldGenerator but the right name is turbulent_wind_field_generator ). I modified the syntax but now there is another error, starting the simulation the report is an error in force_moment_quad file in line 80, in a atan2 function (input is not real).

dewimadden commented 3 years ago

I can vouch for this issue. The error I get is the following (shown below). Similar to OP, I get it for all simulation types.

main_GUI Type CTRL-C to exit Warning: No video frames were written to this file. The file may be invalid. Undefined function 'TurbulentWindFieldGenerator' for input arguments of type 'double'.

Error in get_wind (line 61) [WF,~,t,~,~,X,Y,~,~] = TurbulentWindFieldGenerator(U0,I0,Seed,HubHt,Nx,Ny,Lx,Ly,dt,T,xLu,xLv,xLw,Lc,a,shearExp);

Error in example_controller (line 93) wind = get_wind(time, map, p_sim.dt, p_sim.end_time, drone.pos_ned, WIND_ACTIVE, ...

Error in GUI_drone/StartsimulationSwitchValueChanged (line 92) example_controller();

Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 453) Error while evaluating Switch PrivateValueChangedFcn.'

EnricaSo commented 3 years ago

Hello @gabrieleincerti and @djmads08,

Sorry for the delay. I fixed the name of the method and now I can properly run the simulation from the GUI. @gabrieleincerti, you say you get another error now. Could you please tell me exactly the way you run the simulation and the parameters you use so that I could reproduce the error?

Best, Enrica

dewimadden commented 3 years ago

Hello @EnricaSo ,

  1. To recreate, clone the current git repository for drone swarm lab.
  2. Go to examples, run the main_GUI and start simulation.
  3. The presented error is shown:

`main_GUI Type CTRL-C to exit Warning: No video frames were written to this file. The file may be invalid. Undefined function 'pdist' for input arguments of type 'double'.

Error in Drone/update_path_length (line 405) pdist([self.prev_state(1:3)'; self.pos_ned'], 'euclidean');

Error in Drone/compute_kinematics (line 582) self.update_path_length();

Error in Drone/update_state (line 361) self.compute_kinematics(time);

Error in example_controller (line 100) drone.update_state(wind, time);

Error in GUI_drone/StartsimulationSwitchValueChanged (line 92) example_controller();

Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 453) Error while evaluating Switch PrivateValueChangedFcn.`

EnricaSo commented 3 years ago

Hello @djmads08,

You receive that error because, apparently, you don't have the pdist function installed. Please, verify that you have installed the Statistics and Machine Learning Toolbox.

gabrieleincerti commented 3 years ago

For reproduce the simulation you have to start the simulation in GUI Drone and the parameter are: Drone Parameters : Quadcopter; Simulation Parameters : Path Follower; Add Wind = 25;

This should be the error:

Error using atan2 Inputs must be real.

Error in forces_moments_quad (line 80) alpha = atan2(vaz, vax);

Error in Drone/compute_dynamics (line 546) out = forces_moments_quad(self.get_state(), self.delta, ...

Error in Drone/update_state (line 360) self.compute_dynamics(wind, time);

Error in example_path_follower (line 106) drone.update_state(wind, time);  

jorredebacker commented 2 years ago

Hi did you already find the problem because I get the same error