Skip to content
Snippets Groups Projects
Commit 7618ebbe authored by bbartels's avatar bbartels
Browse files

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

resolves #6
parent 78fccd52
No related branches found
No related tags found
No related merge requests found
......@@ -11,22 +11,40 @@ require script_dir + "/testing_library"
bin_dir = script_dir + "/../../bin/"
Dir.chdir(bin_dir)
Timeout::timeout(30) {
puts("Setting up...")
puts("Setting up...")
# Start virtual quad
quad_pid = Process.spawn("./virt-quad start -q",
{ :rlimit_as => 536870912, # 512 MiB total RAM
:rlimit_stack => 1048576}) # 1 MiB stack
# Start virtual quad
quad_pid = Process.spawn("./virt-quad start -q",
{ :rlimit_as => 536870912, # 512 MiB total RAM
:rlimit_stack => 1048576}) # 1 MiB stack
sleep 0.5
sleep 0.5
# Set RC switches
set_gear GEAR_OFF
set_flap FLAP_OFF
# Set RC switches
set_gear GEAR_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_y 0`
`./virt-quad set i2c_imu_z -1`
......@@ -34,84 +52,62 @@ Timeout::timeout(30) {
`./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
#################
# Begin Tests
#################
begin
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("Increasing Thrust to half maximum...")
for i in (THROTTLE_MIN..THROTTLE_MID).step(0.01)
set_throttle(i)
sleep 0.005
end
puts("Switching to autonomous and hovering for 3 seconds")
set_flap FLAP_OFF
sleep 3
puts("Hovering for 1 seconds")
sleep 1
puts("Switch back to manual, relaxing thrust to zero")
set_flap FLAP_ON
i = THROTTLE_MID
while i > THROTTLE_MIN
i -= 0.01
set_throttle(i)
sleep 0.005
end
puts("Switching to autonomous and hovering for 1 seconds")
set_flap FLAP_OFF
sleep 1
puts("Switch back to manual, relaxing thrust to zero")
set_flap FLAP_ON
i = THROTTLE_MID
while i > THROTTLE_MIN
i -= 0.01
set_throttle(i)
sleep 0.005
end
# Get logs
# Get logs
Thread.new {
sleep 1
puts("Swiching off GEAR...")
set_gear GEAR_OFF
}
Thread.new {
sleep 1
puts("Switching off GEAR...")
set_gear GEAR_OFF
}
logs = []
puts("Preparing to receive logs. This might take a while. You can ctrl-c to quit early.")
logs = []
begin
while true
logs.push(recv_packet)
end
rescue Timeout::Error
puts "No logs left"
begin
while true
logs.push(recv_packet)
end
rescue Exception
end
if logs.length == 2
log_data = logs[1].split("\n")
for data in log_data
puts data
end
p log_data.length
end
for data in logs
puts data
end
puts "------------------------------------------"
puts "#{logs.length} total logs recieved"
ensure
puts "------------------------------------------"
Process.kill(9, quad_pid)
Process.wait(quad_pid)
ensure
end
}
Process.kill(9, quad_pid)
Process.wait(quad_pid)
end
......@@ -72,15 +72,19 @@ def send_packet(bytes)
end
def recv_packet
c = 'c'
msg = []
fifo = nil
Timeout::timeout(5) {
fifo = File.open(UART_TX)
Timeout::timeout(3) {
fifo = File.open(UART_TX, "r+")
}
# Receive the header
msg = []
for i in 1..7
c = fifo.read(1)
Timeout::timeout(3) {
c = fifo.read(1)
}
msg.push(c)
end
......@@ -89,7 +93,9 @@ def recv_packet
msg = []
for i in 1..length
c = fifo.read(1)
Timeout::timeout(3) {
c = fifo.read(1)
}
msg.push(c)
end
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