Skip to content
Snippets Groups Projects
Commit 3094a215 authored by bbartels's avatar bbartels
Browse files

quad: Remove test_logger in favor of a virt-quad test

resolves #6
parent af2fe94d
No related branches found
No related tags found
No related merge requests found
...@@ -11,22 +11,40 @@ require script_dir + "/testing_library" ...@@ -11,22 +11,40 @@ require script_dir + "/testing_library"
bin_dir = script_dir + "/../../bin/" bin_dir = script_dir + "/../../bin/"
Dir.chdir(bin_dir) Dir.chdir(bin_dir)
Timeout::timeout(30) {
puts("Setting up...") puts("Setting up...")
# Start virtual quad # Start virtual quad
quad_pid = Process.spawn("./virt-quad start -q", quad_pid = Process.spawn("./virt-quad start -q",
{ :rlimit_as => 536870912, # 512 MiB total RAM { :rlimit_as => 536870912, # 512 MiB total RAM
:rlimit_stack => 1048576}) # 1 MiB stack :rlimit_stack => 1048576}) # 1 MiB stack
sleep 0.5 sleep 0.5
# Set RC switches # Set RC switches
set_gear GEAR_OFF set_gear GEAR_OFF
set_flap FLAP_OFF set_flap FLAP_OFF
# Set initial quad orientation (flat on the ground, facing forward)
`./virt-quad set i2c_imu_x 0`
`./virt-quad set i2c_imu_y 0`
`./virt-quad set i2c_imu_z -1`
`./virt-quad set rc_roll 0.498`
`./virt-quad set rc_pitch 0.497`
`./virt-quad set rc_yaw 0.498`
#################
# Begin Tests
#################
begin
puts "------------------------------------------"
puts "-- Beginning logging test..."
puts "------------------------------------------"
# Set initial quad orientation (flat on the ground, facing forward) # Set initial quad orientation (flat on ground, facing forward)
`./virt-quad set i2c_imu_x 0` `./virt-quad set i2c_imu_x 0`
`./virt-quad set i2c_imu_y 0` `./virt-quad set i2c_imu_y 0`
`./virt-quad set i2c_imu_z -1` `./virt-quad set i2c_imu_z -1`
...@@ -34,84 +52,62 @@ Timeout::timeout(30) { ...@@ -34,84 +52,62 @@ Timeout::timeout(30) {
`./virt-quad set rc_pitch 0.497` `./virt-quad set rc_pitch 0.497`
`./virt-quad set rc_yaw 0.498` `./virt-quad set rc_yaw 0.498`
puts("Turning on GEAR...")
set_gear GEAR_ON
set_flap FLAP_ON
sleep 0.015
################# puts("Increasing Thrust to half maximum...")
# Begin Tests for i in (THROTTLE_MIN..THROTTLE_MID).step(0.01)
################# set_throttle(i)
sleep 0.005
begin end
puts "------------------------------------------"
puts "-- Beginning logging test..."
puts "------------------------------------------"
# Set initial quad orientation (flat on ground, facing forward)
`./virt-quad set i2c_imu_x 0`
`./virt-quad set i2c_imu_y 0`
`./virt-quad set i2c_imu_z -1`
`./virt-quad set rc_roll 0.498`
`./virt-quad set rc_pitch 0.497`
`./virt-quad set rc_yaw 0.498`
puts("Turning on GEAR...")
set_gear GEAR_ON
set_flap FLAP_ON
sleep 0.015
puts("Increasing Thrust to half maximum...")
for i in (THROTTLE_MIN..THROTTLE_MID).step(0.01)
set_throttle(i)
sleep 0.005
end
puts("Hovering for 3 seconds")
sleep 3
puts("Switching to autonomous and hovering for 3 seconds") puts("Hovering for 1 seconds")
set_flap FLAP_OFF sleep 1
sleep 3
puts("Switch back to manual, relaxing thrust to zero") puts("Switching to autonomous and hovering for 1 seconds")
set_flap FLAP_ON set_flap FLAP_OFF
i = THROTTLE_MID sleep 1
while i > THROTTLE_MIN
i -= 0.01 puts("Switch back to manual, relaxing thrust to zero")
set_throttle(i) set_flap FLAP_ON
sleep 0.005 i = THROTTLE_MID
end while i > THROTTLE_MIN
i -= 0.01
set_throttle(i)
sleep 0.005
end
# Get logs # Get logs
Thread.new { Thread.new {
sleep 1 sleep 1
puts("Swiching off GEAR...") puts("Switching off GEAR...")
set_gear GEAR_OFF set_gear GEAR_OFF
} }
logs = [] puts("Preparing to receive logs. This might take a while. You can ctrl-c to quit early.")
logs = []
begin begin
while true while true
logs.push(recv_packet) logs.push(recv_packet)
end
rescue Timeout::Error
puts "No logs left"
end end
rescue Exception
end
if logs.length == 2 for data in logs
log_data = logs[1].split("\n") puts data
for data in log_data end
puts data
end
p log_data.length
end
puts "------------------------------------------" puts "#{logs.length} total logs recieved"
ensure puts "------------------------------------------"
Process.kill(9, quad_pid) ensure
Process.wait(quad_pid)
end Process.kill(9, quad_pid)
} Process.wait(quad_pid)
end
...@@ -72,15 +72,19 @@ def send_packet(bytes) ...@@ -72,15 +72,19 @@ def send_packet(bytes)
end end
def recv_packet def recv_packet
c = 'c'
msg = []
fifo = nil fifo = nil
Timeout::timeout(5) { Timeout::timeout(3) {
fifo = File.open(UART_TX) fifo = File.open(UART_TX, "r+")
} }
# Receive the header # Receive the header
msg = [] msg = []
for i in 1..7 for i in 1..7
c = fifo.read(1) Timeout::timeout(3) {
c = fifo.read(1)
}
msg.push(c) msg.push(c)
end end
...@@ -89,7 +93,9 @@ def recv_packet ...@@ -89,7 +93,9 @@ def recv_packet
msg = [] msg = []
for i in 1..length for i in 1..length
c = fifo.read(1) Timeout::timeout(3) {
c = fifo.read(1)
}
msg.push(c) msg.push(c)
end end
fifo.close fifo.close
......
CC=gcc
test: test.c
$(CC) -o test_log -I. -I../src/quad_app -I../src/computation_graph test.c ../src/quad_app/*.c ../src/computation_graph/*.c -lm
# MicroCART On-board Quad Log
# Sample size: 3
time accel_x accel_y accel_z gyro_x gyro_y gyro_z Altitude PID_Correction X pos PID_Correction Y pos PID_Correction Pitch PID_Correction Roll PID_Correction Yaw PID_Correction Pitch Rate PID_Correction Roll Rate PID_Correction Yaw Rate PID_Correction Pitch_Constant Roll_Constant Yaw_Constant VRPN X_Constant VRPN Y_Constant VRPN Alt_Constant VRPN Pitch_Constant VRPN Roll_Constant X Setpoint_Constant Y Setpoint_Constant Alt Setpoint_Constant Yaw Setpoint_Constant Signal Mixer_PWM 0 Signal Mixer_PWM 1 Signal Mixer_PWM 2 Signal Mixer_PWM 3
s G G G rad/s rad/s rad/s 10ns_dutycycle rad rad rad/s rad/s rad/s 10ns_dutycycle 10ns_dutycycle 10ns_dutycycle rad rad rad m m m rad rad m m m rad 10ns_dutycycle 10ns_dutycycle 10ns_dutycycle 10ns_dutycycle
0.000000 0.000000 0.000000 0.000000 0.000000 4722366482869645213696.000000 -nan 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 4722366482869645213696.000000 -nan 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 4722366482869645213696.000000 -nan 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
#include <stddef.h>
#include "type_def.h"
#include "log_data.h"
#include "control_algorithm.h"
int zybo_uart_write(struct UARTDriver *self, unsigned char c) {
printf("%c", c);
return 0;
}
int main() {
modular_structs_t structs;
structs.hardware_struct.uart.write = zybo_uart_write;
control_algorithm_init(&(structs.parameter_struct));
initialize_logging(&structs.log_struct, &structs.parameter_struct);
log_data(&(structs.log_struct), &(structs.parameter_struct));
log_data(&(structs.log_struct), &(structs.parameter_struct));
log_data(&(structs.log_struct), &(structs.parameter_struct));
printLogging(&structs.hardware_struct, &(structs.log_struct), &(structs.parameter_struct));
return 0;
}
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment