Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican committed Jun 16, 2016
1 parent 61ebc0f commit 5ecf8aa
Show file tree
Hide file tree
Showing 37 changed files with 2,566 additions and 1,543 deletions.
38 changes: 29 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ sudo: required
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- ubuntu-toolchain-r-test
packages:
- autoconf
- automake
- m4
- gcc-4.9
- g++-4.9
- autoconf
- automake
- m4
- gcc-4.9
- g++-4.9

before_install:
- git submodule update --init --recursive > /dev/null
Expand All @@ -20,8 +20,29 @@ before_install:
install:
- "bash -ex ./install-wiringpi.sh"

before_script:
- "bash -ex ./prepare.sh"
- export TZ=UTC

script:
- "bash -ex ./build.sh"
- make utesting && ./utesting
- make clean && ./configure CPPFLAGS="-DDEBUG" && make utesting && ./utesting
- make clean && ./configure CPPFLAGS="-DNO_SMS" && make utesting && ./utesting
- make clean && ./configure CPPFLAGS="-DDEBUG -DNO_SMS" && make utesting && ./utesting
- make clean && make
- make clean && ./configure CPPFLAGS="-DNO_POWER_OFF" && make
- make clean && ./configure CPPFLAGS="-DDEBUG" && make
- make clean && ./configure CPPFLAGS="-DNO_POWER_OFF -DDEBUG" && make
- make clean && ./configure CPPFLAGS="-DNO_SMS" && make
- make clean && ./configure CPPFLAGS="-DDEBUG -DNO_SMS" && make
- make clean && ./configure CPPFLAGS="-DSIM" && make
- make clean && ./configure CPPFLAGS="-DDEBUG -DSIM" && make
- make clean && ./configure CPPFLAGS="-DREAL_SIM" && make
- make clean && ./configure CPPFLAGS="-DDEBUG -DREAL_SIM" && make
- make clean && ./configure CPPFLAGS="-DNO_SMS -DREAL_SIM" && make
- make clean && ./configure CPPFLAGS="-DDEBUG -DNO_SMS -DREAL_SIM" && make
- make clean && ./configure CPPFLAGS="-DNO_SMS -D_SIM" && make
- make clean && ./configure CPPFLAGS="-DDEBUG -DNO_SMS -D_SIM" && make

branches:
only:
Expand All @@ -34,8 +55,7 @@ branches:
notifications:
email:
recipients:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
on_success: change
on_failure: always
6 changes: 3 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bin_PROGRAMS = openstratos
openstratos_SOURCES = openstratos.cc utils.cc threads.cc camera/Camera.cc gps/GPS.cc serial/Serial.cc logger/Logger.cc gsm/GSM.cc
openstratos_CPPFLAGS = -std=c++14
openstratos_SOURCES = openstratos.cc logic/main_while.cc logic/shut_down.cc utils.cc threads.cc camera/Camera.cc gps/GPS.cc serial/Serial.cc logger/Logger.cc gsm/GSM.cc
openstratos_CPPFLAGS = -Wall -Wextra -Werror -pedantic-errors -std=c++14

EXTRA_PROGRAMS = utesting
utesting_SOURCES = testing/testing.cc camera/Camera.cc gps/GPS.cc serial/Serial.cc logger/Logger.cc
utesting_CPPFLAGS = -std=c++14 -Itesting/bandit -Wno-unused-result -DOS_TESTING
utesting_CPPFLAGS = -Wall -Wextra -Werror -pedantic-errors -std=c++14 -Itesting/bandit -Wno-unused-parameter -DOS_TESTING
37 changes: 19 additions & 18 deletions README
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# OpenStratos Server #
# OpenStratos #

[![Build Status](https://travis-ci.org/OpenStratos/server.svg?branch=develop)](https://travis-ci.org/OpenStratos/server)
[![Build Status](https://travis-ci.org/OpenStratos/server.svg?branch=master)](https://travis-ci.org/OpenStratos/server)

Server implemented in C++14. It will be in charge of the management of the balloon. It will
communicate via SMS to the provided phone. It will initialize all needed components, track and log
position and software messages, detect launch, burst and landing and send the landing position via
SMS.
Balloon control software implemented in C++14. It will be in charge of the management of the
balloon and will communicate via SMS to the provided phone. It will initialize all needed
components, track and log position and software messages, detect launch, burst and landing and send
the landing position via SMS.

## Requirements ##

The software needs a working instalation of WiringPi and a RaspiCam for the tests. It will perform
The software needs a working installation of WiringPi and a RaspiCam for the tests. It will perform
some basic tests if no Raspberry Pi is being used. It works with Adafruit Fona module, even though
it should work with other GSM modules. It also uses the Adafruit Ultimate GPS module. The following
software is needed to compile OpenStratos (apart from the WiringPi library):
Expand All @@ -23,23 +23,23 @@ software is needed to compile OpenStratos (apart from the WiringPi library):
## Compiling ##

For compilation, a *build.sh* script is provided, that should be run as is. It will compile the
tests of OpenStratos and run them. After that, the main program can be compiled using ```make```.
tests of OpenStratos and run them. After that, the main program can be compiled using `make`.
Optional configuration arguments can be passed. The first optional configuration argument is the
*NO_SMS* flag. This prevents actual SMSs being sent, even if they are simulated. This way no charges
will be applied. For using this argument the directory should be cleaned with ```make clean``` and
will be applied. For using this argument the directory should be cleaned with `make clean` and
then pass the *NO_SMS* flag to the configure script:

```
./configure CPPFLAGS="-DNO_SMS"
```

After that the usual ```make``` will compile the software. Note that the test do not send SMSs. The software itself comes with two built-in simulation modes:
After that the usual `make` will compile the software. Note that the test do not send SMSs. The software itself comes with two built-in simulation modes:

### Normal Simulation ###

In this mode, a simple simulation is made, with a length of about 45 minutes. It will run through
all the main stages of the program. For using this mode the directory should be cleaned with
```make clean``` and then pass the *SIM* flag to the configure script:
`make clean` and then pass the *SIM* flag to the configure script:

```
./configure CPPFLAGS="-DSIM"
Expand All @@ -51,14 +51,14 @@ It can be combined with the *NO_SMS* flag:
./configure CPPFLAGS="-DSIM -DNO_SMS"
```

After that, the software can be compiled using ```make```.
After that, the software can be compiled using `make`.

### Realistic Simulation ###

In this mode, a complete realistic simulation is made, that will last for about 5 hours. It will
realistically simulate the times in a 35 km height balloon. It will be similar to the normal
simulation, the only change will be in the timing. For using this mode the directory should be
cleaned with ```make clean``` and then pass the *REAL_SIM* flag to the configure script:
cleaned with `make clean` and then pass the *REAL_SIM* flag to the configure script:

```
./configure CPPFLAGS="-DREAL_SIM"
Expand All @@ -70,15 +70,15 @@ It can be combined with the *NO_SMS* flag:
./configure CPPFLAGS="-DREAL_SIM -DNO_SMS"
```

After that, the software can be compiled using ```make```. The result of combining the two
simulation flags is undetermined. They should not be combined.
After that, the software can be compiled using `make`. The result of combining the two simulation
flags will be an error when building the main program. For testing it will have no effect.

### Debug Mode ###

The software has a small debug mode, that prints from *stdio* some logs that occur before the log
file is created. It also enables serial logging, that will log everything that happens in the
serial. This has a moderate overhead and should not be used in production. GSM and GPS loggers log everythong they send and receive. This is only needed to debug if something goes wrong with the
serial. For using this mode the directory should be cleaned with ```make clean``` and then pass the
serial. This has a moderate overhead and should not be used in production. GSM and GPS loggers log everything they send and receive. This is only needed to debug if something goes wrong with the
serial. For using this mode the directory should be cleaned with `make clean` and then pass the
*DEBUG* flag to the configure script:

```
Expand All @@ -97,7 +97,7 @@ It can be combined with the *NO_SMS* flag or/and one of the simulation flags:

For some testing there is no need to reboot or shut down the system in failures. For this, the
software provides the no power off mode, that will prevent the software from shutting the
Raspberry Pi down. For using this mode the directory should be cleaned with ```make clean``` and
Raspberry Pi down. For using this mode the directory should be cleaned with `make clean` and
then pass the *NO_POWER_OFF* flag to the configure script:

```
Expand All @@ -110,6 +110,7 @@ It can be combined with the *NO_SMS* flag, the *DEBUG* flag or/and one of the si
./configure CPPFLAGS="-DREAL_SIM -DNO_SMS -DDEBUG -DNO_POWER_OFF"
./configure CPPFLAGS="-DSIM -DDEBUG -DNO_POWER_OFF"
./configure CPPFLAGS="-DNO_SMS -DDEBUG -DNO_POWER_OFF"
```

## License ##

Expand Down
102 changes: 73 additions & 29 deletions camera/Camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ Camera::~Camera()
{
this->logger->log("Stopping video recording...");
if ( ! this->stop())
this->logger->log("Error soping video recording.");
{
this->logger->log("Error stoping video recording.");
}
else
{
this->logger->log("Video recording stopped.");
}
}
this->logger->log("Shut down finished");
delete this->logger;
Expand All @@ -59,7 +63,10 @@ void Camera::record_thread(int time)

bool Camera::record(int time)
{
if (time != 0) this->logger->log("Recording for "+to_string(time/1000)+" seconds...");
if (time != 0)
{
this->logger->log("Recording for "+to_string(time/1000)+" seconds...");
}
if ( ! this->recording)
{
this->logger->log("Not already recording, creating command...");
Expand Down Expand Up @@ -91,11 +98,18 @@ bool Camera::record(int time)
t.detach();
}

if (result) this->logger->log("Video recording correctly started.");
else this->logger->log("Error starting video recording.");
if (result)
{
this->logger->log("Video recording correctly started.");
}
else
{
this->logger->log("Error starting video recording.");
}

return result;
}
return false;
}

bool Camera::record()
Expand All @@ -107,21 +121,25 @@ bool Camera::record()
bool Camera::take_picture(const string& exif)
{
bool was_recording = this->recording;
if (was_recording) this->logger->log("Recording video, stopping...");
if (was_recording && ! this->stop()) return false;
this->logger->log("Video recording stopped.");
this->logger->log("Taking picture...");
if (was_recording)
{
this->logger->log("The video is recording.");
}
if (was_recording && ! this->stop())
{
return false;
}

string filename = "data/img/img-"+ to_string(get_file_count("data/img/")) +".jpg";
#ifdef OS_TESTING
filename = "data/img/test.jpg";
#endif

string exif_command = exif != "" ? " -x "+ exif : "";

string command = "raspistill -n -o "+ filename +" " + (PHOTO_RAW ? "-r" : "") + " -w "+ to_string(PHOTO_WIDTH)
string command = "raspistill -n -t 1 -o "+ filename +" " + (PHOTO_RAW ? "-r" : "") + " -w "+ to_string(PHOTO_WIDTH)
+" -h "+ to_string(PHOTO_HEIGHT) +" -q "+ to_string(PHOTO_QUALITY)
+" -co "+ to_string(PHOTO_CONTRAST) +" -br "+ to_string(PHOTO_BRIGHTNESS)
+" -ex "+ PHOTO_EXPOSURE + exif_command;
+" -ex "+ PHOTO_EXPOSURE + exif;

this->logger->log("Picture command: '"+command+"'");

Expand All @@ -133,10 +151,19 @@ bool Camera::take_picture(const string& exif)
int st = system(command.c_str());
bool result = st == 0;

if (result) this->logger->log("Picture taken correctly.");
else this->logger->log("Error taking picture.");
if (result)
{
this->logger->log("Picture taken correctly.");
}
else
{
this->logger->log("Error taking picture.");
}

if (was_recording) this->logger->log("Video recording was active before taking picture. Resuming...");
if (was_recording)
{
this->logger->log("Video recording was active before taking picture. Resuming...");
}
if (was_recording && ! this->record())
{
this->logger->log("Error resuming video recording.");
Expand All @@ -159,20 +186,22 @@ bool Camera::stop()
if (system("pkill raspivid") == 0)
{
this->logger->log("Video recording stopped correctly.");
this_thread::sleep_for(50ms);
this->recording = false;
return true;
}
this->logger->log("Error stopping video recording.");

if ( ! this->is_really_recording())
{
this->logger->log("Warning: video was already stopped.");
this->logger->log("Warning: video had already stopped.");
this->recording = false;
return true;
}
return false;
#else
this->logger->log("Test mode. Video recording stop simulated.");
this_thread::sleep_for(50ms);
this->recording = false;
return true;
#endif
Expand All @@ -190,17 +219,24 @@ int os::get_file_count(const string& path)
struct dirent *ep;
dp = opendir(path.c_str());

while (ep = readdir(dp)) i++;
(void) closedir(dp);
while ((ep = readdir(dp)) != NULL)
{
++i;
}
closedir(dp);

return i-2;
}

const string os::generate_exif_data()
{
string exif;
while (GPS::get_instance().get_PDOP() > 5)
this_thread::sleep_for(1s);
for (int i = 0;
i < 10 && ( ! GPS::get_instance().is_fixed() || GPS::get_instance().get_PDOP() > MAX_DOP);
++i)
{
this_thread::sleep_for(500ms);
}

double gps_lat = GPS::get_instance().get_latitude();
double gps_lon = GPS::get_instance().get_longitude();
Expand All @@ -209,14 +245,22 @@ const string os::generate_exif_data()
float gps_pdop = GPS::get_instance().get_PDOP();
euc_vec gps_velocity = GPS::get_instance().get_velocity();

exif += "GPSLatitudeRef="+to_string(gps_lat > 0 ? 'N' : 'S');
exif += " GPSLatitude="+to_string(abs((int) gps_lat*1000000))+"/1000000,0/1,0/1";
exif += " GPSLongitudeRef="+to_string(gps_lon > 0 ? 'E' : 'W');
exif += " GPSLongitude="+to_string(abs((int) gps_lon*1000000))+"/1000000,0/1,0/1";
exif += " GPSAltitudeRef=0 GPSAltitude="+to_string(gps_alt);
exif += " GPSSatellites="+to_string(gps_sat);
exif += " GPSDOP="+to_string(gps_pdop);
exif += " GPSSpeedRef=K GPSSpeed="+to_string(gps_velocity.speed*3.6);
exif += " GPSTrackRef=T GPSTrack="+to_string(gps_velocity.course);
exif += " GPSDifferential=0";
exif += " -x GPS.GPSLatitudeRef="+string(gps_lat > 0 ? "N" : "S");
exif += " -x GPS.GPSLatitude="+to_string(
abs((int) (gps_lat*1000000))
)+"/1000000";
exif += " -x GPS.GPSLongitudeRef="+string(gps_lat > 0 ? "E" : "W");
exif += " -x GPS.GPSLongitude="+to_string(
abs((int) (gps_lon*1000000))
)+"/1000000";
exif += " -x GPS.GPSAltitudeRef=0 -x GPS.GPSAltitude="+to_string((int) (gps_alt*100))+"/100";
exif += " -x GPS.GPSSatellites="+to_string(gps_sat);
exif += " -x GPS.GPSDOP="+to_string((int) (gps_pdop*1000))+"/1000";
exif += " -x GPS.GPSSpeedRef=K -x GPS.GPSSpeed="+
to_string((int) (gps_velocity.speed*3.6*1000))+"/1000";
exif += " -x GPS.GPSTrackRef=T -x GPS.GPSTrack="+
to_string((int) (gps_velocity.course*1000))+"/1000";
exif += " -x GPS.GPSDifferential=0";

return exif;
}
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.68])
AC_INIT(OpenStratos, 1.0, https://github.com/OpenStratos/server/issues)
AC_INIT(OpenStratos, 1.1.0, https://github.com/OpenStratos/server/issues)
AC_CONFIG_SRCDIR([openstratos.cc])
AM_INIT_AUTOMAKE([subdir-objects])
AC_CONFIG_HEADERS([config.h])
Expand Down
Loading

0 comments on commit 5ecf8aa

Please sign in to comment.