From 255dd925236e3a486f872c5d4cf0af302ff9f8b7 Mon Sep 17 00:00:00 2001 From: David Marson Date: Tue, 29 Nov 2022 16:33:25 +0100 Subject: [PATCH 1/2] Fix to add saving velocity data to method Drone.compute_kinematics and prevent error when swarm.get_vel_xyz_history() is called in example scripts --- @Drone/Drone.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/@Drone/Drone.m b/@Drone/Drone.m index 4a7268c..72015e1 100644 --- a/@Drone/Drone.m +++ b/@Drone/Drone.m @@ -570,12 +570,17 @@ function compute_kinematics(self, time) x_new = x_ode(end, :); self.pos_ned = x_new(1:3)'; - if self.pos_ned_history == [NaN, NaN, NaN] + if isequal(self.pos_ned_history, [NaN, NaN, NaN]) self.pos_ned_history = self.pos_ned; else self.pos_ned_history = [self.pos_ned_history; self.pos_ned']; end self.vel_xyz = x_new(4:6)'; + if isempty(self.vel_xyz_history) || isequal(self.vel_xyz_history, [NaN, NaN, NaN]) + self.vel_xyz_history = self.vel_xyz'; % rows = time steps, columns = states + else + self.vel_xyz_history = [self.vel_xyz_history; self.vel_xyz']; + end self.attitude = x_new(7:9)'; self.rates = x_new(10:12)'; From 40258a2dded8dd83415a467a83ed872e7469f952 Mon Sep 17 00:00:00 2001 From: David Marson Date: Tue, 29 Nov 2022 16:49:27 +0100 Subject: [PATCH 2/2] Adding an if statement to automatically set parameter based on drone type. --- parameters/param_swarm/param_swarm.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/parameters/param_swarm/param_swarm.m b/parameters/param_swarm/param_swarm.m index 152d0aa..3364f1c 100644 --- a/parameters/param_swarm/param_swarm.m +++ b/parameters/param_swarm/param_swarm.m @@ -112,8 +112,11 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -p_swarm.max_a = 10; -% p_swarm.max_a = []; % leave empty if you use a real drone model +if DRONE_TYPE == "fixed_wing" || DRONE_TYPE == "quadcopter" + p_swarm.max_a = []; % leave empty if you use a real drone model +elseif DRONE_TYPE == "point_mass" + p_swarm.max_a = 10; +end p_swarm.max_v = 7; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%