From 44785c76f017619f32dcb8fce2ee2e0ee1095656 Mon Sep 17 00:00:00 2001 From: Tim Stadtmann <tim.stadtmann@rwth-aachen.de> Date: Tue, 4 Oct 2016 20:49:08 +0200 Subject: [PATCH] Update example-scripts --- examples/MotorBraking.m | 21 ------------------- examples/distancePlotting.m | 18 ++++++++++++++-- examples/testProfiling.m | 24 +++++++++++++++++++++ examples/testToolbox.m | 42 ------------------------------------- 4 files changed, 40 insertions(+), 65 deletions(-) delete mode 100644 examples/MotorBraking.m create mode 100644 examples/testProfiling.m delete mode 100644 examples/testToolbox.m diff --git a/examples/MotorBraking.m b/examples/MotorBraking.m deleted file mode 100644 index 47b6f2c..0000000 --- a/examples/MotorBraking.m +++ /dev/null @@ -1,21 +0,0 @@ -b = EV3('debug', 2); -b.connect('bt', 'serPort', '/dev/rfcomm0'); -m = b.motorA; -sl = b.motorB; - -m.tachoLimit = 1000; -m.brakeMode = 'Coast'; - -counts = []; -power = [60, 65, 70, 75, 80, 85, 90, 95, 100]; - -for i=1:length(power) - m.resetTachoCount; - m.reset; - m.power = power(i); - m.syncedStart(sl); - m.waitFor(); - counts = [counts, m.tachoCount]; - b.beep; - b.debug = false; -end \ No newline at end of file diff --git a/examples/distancePlotting.m b/examples/distancePlotting.m index 416e8a5..c0c2c3c 100644 --- a/examples/distancePlotting.m +++ b/examples/distancePlotting.m @@ -1,3 +1,12 @@ +% This script has two purposes: +% * Plotting distance to ultrasonic sensor (for fun and as an example) +% * Analyse runtime of sensor readings (comment out marked part of code to get useful +% results) +% Necessary: +% * USB-connection +% * UltraSonic-Sensor at Port 4 +clear all + b = EV3('debug', 0); b.connect('usb'); @@ -15,8 +24,11 @@ hold on; while toc < 20 readings = [readings, s.value]; time = [time, toc]; -% plot(time, readings) -% drawnow + + %% Plotting + % Should be commented out if you analyse latency of sensor readings + plot(time, readings) + drawnow end hold off; @@ -24,6 +36,8 @@ fprintf('\nSensor readings per sec: %f\n', length(readings)/time(length(time))); b.disconnect(); +clear all + %% Results % Bluetooth % debug=2, sensor-typ-kontrolle an: 7.5 Readings/sec % worst case diff --git a/examples/testProfiling.m b/examples/testProfiling.m new file mode 100644 index 0000000..0f80605 --- /dev/null +++ b/examples/testProfiling.m @@ -0,0 +1,24 @@ +% In order to generally examine the runtime-distribution, start this script +% with the 'Run and Time'-Button in MATLAB. +% Necessary: +% * USB-connection +% * Motor at Port A +clear all + +b = EV3(); +b.connect('usb'); +ma = b.motorA; +ma.setProperties('Power', 50, 'LimitValue', 2000); + +t = 0; +flag = 0; +tacho = 0; + +tic; +ma.start(); +while(toc < 7) + flag = [flag, ma.isRunning]; + tacho = [tacho, ma.tachoCount]; +end + +clear all \ No newline at end of file diff --git a/examples/testToolbox.m b/examples/testToolbox.m deleted file mode 100644 index a04346e..0000000 --- a/examples/testToolbox.m +++ /dev/null @@ -1,42 +0,0 @@ -b = EV3(); -b.connect('bt', 'serPort', '/dev/rfcomm0'); -b.sensor3.mode = DeviceMode.Color.Col; -b.sensor4.mode = DeviceMode.UltraSonic.DistCM; -tic; -t = 0; - -b.motorA.setProperties('power', 50, 'speedRegulation', 'on', 'smoothStart', 10, 'limitMode', ... - 'Time', 'limitValue', 3000); -b.motorA.start(); - -pause(0.5); -while b.motorA.isRunning() - b.sensor3.value - b.sensor4.value - b.motorA.tachoCount -end - -b.motorB.power = 50; -b.motorB.limitValue = 4*360; -b.motorB.start(); -b.motorB.waitFor(); -b.beep(); - -b.motorA.speedRegulation = false; -pause(1); -b.motorA.syncedStart(b.motorB, 'turnRatio', 200); -b.motorA.waitFor(); - -for i=1:10 - b.sensor3.value - b.motorA.tachoCount - b.sensor3.reset - b.motorA.tachoCount -end - -b.beep -b.beep - - -b.disconnect -b.delete \ No newline at end of file -- GitLab