I’ve been trying to add code and interface level tests to ROSOSC lately, and I thought I would take some time to document my lessons learned.
rostest, and it’s sister stack rosunit, can be used to implement interface and code level tests, respectively. rosunit is useful for putting already-existing (hopefully) unit tests into the greater rosbuild framework, so that these test can be run either via the rosunit command line utility, or through the rosbuild system.
I am please to announce a new stack that I’ve been working on: ROSOSC. Code and documentation for my “beta” release are available immediately on the ROS.org wiki: http://www.ros.org/wiki/rososc
Currently, the pr2_computer_monitor stack uses the IPMI interface for monitoring hardware status. Since not everyone can get a computer with these capabilities, I decided to create a simple parser for the lm_sensors package in Linux.
lm_sensors allows the user to get basic system information such as voltages, temperatures, and fan speeds from the SMBus and I2C controllers that are built into motherboards.
Here is an example of the output of the ‘sensors’ command, once lm_sensors has been properly configured for your system.
atk0110-acpi-0 Adapter: ACPI interface Vcore Voltage: +1.14 V (min = +0.80 V, max = +1.60 V) +3.3 Voltage: +3.28 V (min = +2.97 V, max = +3.63 V) +5 Voltage: +5.09 V (min = +4.50 V, max = +5.50 V) +12 Voltage: +12.15 V (min = +10.20 V, max = +13.80 V) CPU FAN Speed: 1875 RPM (min = 600 RPM) CHASSIS FAN 1 Speed: 629 RPM (min = 600 RPM) CHASSIS2 FAN Speed: 649 RPM (min = 600 RPM) POWER FAN Speed: 0 RPM (min = 600 RPM) CPU Temperature: +41.0°C (high = +60.0°C, crit = +95.0°C) MB Temperature: +43.0°C (high = +45.0°C, crit = +95.0°C) coretemp-isa-0000 Adapter: ISA adapter Core 0: +51.0°C (high = +80.0°C, crit = +100.0°C) coretemp-isa-0001 Adapter: ISA adapter Core 1: +50.0°C (high = +80.0°C, crit = +100.0°C) coretemp-isa-0002 Adapter: ISA adapter Core 2: +41.0°C (high = +80.0°C, crit = +100.0°C) coretemp-isa-0003 Adapter: ISA adapter Core 3: +59.0°C (high = +80.0°C, crit = +100.0°C)
And here is a screenshot of the sensors in Runtime Monitor on ROS.
My code is available in my personal ROS stack on GitHub. Feel free to check it out.
MATLAB is installed on all Auburn College of Engineering computers. Student licenses can also be purchased from the bookstore for home use. It is supported on Windows, Linux and Macintosh computers.
MATLAB can be used in two main ways, interactively and scripted. Interactive mode is much like using a graphing calculator where the user inputs commands and MATLAB runs the commands instantly. Scripted mode is used by going to “File > New > Script” and entering commands there.
Here is an example of how to do problem 1:
pr1_1_i_d.m
Here is an example function:
function u_t = unitstep( t, tau ) %UNITSTEP Creates a unit step output given a range input % Multiply by a double so that the answer will be a double. u_t = 1.0 * (t >= tau); end |
At the beginning of your files, you may find it helpful to use the following commands to clean up your workspace.
close all; % Close all figure windows clear; % Clears all variables in the workspace clc; % Clears the console |
Using MATLAB’s built in Cell Mode (YouTube Tutorial) can make documentation and debugging much easier.
An example of using cells can be found here:
pr1_1_i_d.m
Cells are marked with the double-percent sign (%%). Each cell will execute independently when Ctrl+Enter is pressed.
figure(); % Creates a new figure plot(x,y); % Creates a plot of x vs y stem(x,y); % Creates a stem-plot of x vs y xlabel('t (s)'); % Label the x-axis ylabel('x(t)'); % Label the y-axis title('1.1.ii.c'); % Set the Title of your plot title(sprintf('deltaT = %8.3f',deltaT)) % Title with string substitution grid on; % Turn on a background grid axis equal; % Sets tick marks to be even on x and y axis axis square; % Makes the current axis box square (cannot be used with axis equal.) |
A commonly-overlooked feature of MATLAB is the publishing feature. This allows you to publish any m-file in cell mode to a pdf, latex, or word document easily.
The settings can be accessed in the editor window by going to File > Publish Configuration, and then publish the file by going to File > Publish.
Here is an example of a published file (PDF): pr1_1_i_d.pdf
And another example of my custom LaTeX export: pr1_1_i_d
The “help” command at the command window interface to MATLAB will return basic text-only help documentation for the function in question.
>> help eye EYE Identity matrix. EYE(N) is the N-by-N identity matrix. EYE(M,N) or EYE([M,N]) is an M-by-N matrix with 1's on the diagonal and zeros elsewhere. EYE(SIZE(A)) is the same size as A. EYE with no arguments is the scalar 1. EYE(M,N,CLASSNAME) or EYE([M,N],CLASSNAME) is an M-by-N matrix with 1's of class CLASSNAME on the diagonal and zeros elsewhere. Note: The size inputs M and N should be nonnegative integers. Negative integers are treated as 0. Example: x = eye(2,3,'int8'); See also speye, ones, zeros, rand, randn. Overloaded methods: distributed/eye codistributor2dbc/eye codistributor1d/eye codistributed/eye Reference page in Help browser doc eye |
The “doc” command at the command window interface will return the MATLAB rich-text documentation for the function in question.
“doc eye” returns Mathworks Documentation
The “lookfor” command at the command window interface will search for functions matching a string.
>> lookfor identity eye - Identity matrix. speye - Sparse identity matrix. |