27 #include "auv_status.pb.h"
29 #include <boost/units/base_units/metric/bar.hpp>
30 #include <boost/units/io.hpp>
31 #include <boost/units/physical_dimensions/pressure.hpp>
32 #include <boost/units/systems/si.hpp>
33 #include <boost/units/systems/si/dimensionless.hpp>
34 #include <boost/units/systems/si/prefixes.hpp>
35 #include <boost/units/systems/si/velocity.hpp>
36 #include <boost/units/systems/temperature/celsius.hpp>
37 #include <boost/units/systems/temperature/fahrenheit.hpp>
39 #include <boost/units/base_units/metric/nautical_mile.hpp>
43 CTDTestMessage test_msg;
45 using namespace boost::units;
46 using boost::units::metric::bar_base_unit;
47 using boost::units::si::deci;
49 typedef bar_base_unit::unit_type Bar;
52 quantity<Bar> pressure(150.123456789 * si::deci * bar);
54 test_msg.set_pressure_with_units(pressure);
57 boost::units::unit<boost::units::temperature_dimension, boost::units::si::system>;
58 quantity<absolute<Kelvin>> temp(15 * absolute<celsius::temperature>());
59 std::cout << temp << std::endl;
61 double temp_d = (temp - quantity<absolute<Kelvin>>(0 * absolute<Kelvin>())) / Kelvin();
62 std::cout << temp_d << std::endl;
64 test_msg.set_temperature_with_units(15 * absolute<fahrenheit::temperature>());
65 test_msg.set_micro_temp_with_units(15 * Kelvin());
66 test_msg.set_salinity(35.2);
67 test_msg.set_sound_speed(1500);
69 quantity<si::velocity> c(1500 * si::meters_per_second);
70 test_msg.set_sound_speed_with_units(c);
71 test_msg.set_depth_with_units(100 * si::meters);
72 quantity<si::velocity> auv_spd(2.5 * si::meters_per_second);
73 test_msg.set_auv_speed_with_units(auv_spd);
74 std::cout <<
"auv_spd: " << auv_spd << std::endl;
76 test_msg.set_salinity_with_units(38.9 * si::dimensionless());
78 std::cout << test_msg.DebugString() << std::endl;
79 std::cout <<
"Temperature: " << test_msg.temperature_with_units() << std::endl;
80 std::cout <<
"Micro temperature: " << test_msg.micro_temp_with_units() << std::endl;
81 std::cout << std::setprecision(10) <<
"Pressure: " << test_msg.pressure_with_units()
83 std::cout <<
"Pressure (as bars): " << quantity<Bar>(test_msg.pressure_with_units())
85 std::cout <<
"Sound speed: " << test_msg.sound_speed_with_units() << std::endl;
86 std::cout <<
"AUV speed: " << test_msg.auv_speed_with_units() << std::endl;
87 std::cout <<
"Salinity: " << test_msg.salinity_with_units() << std::endl;
90 status.set_x_with_units(1000 * si::meters);
91 status.set_y_with_units(500 * si::meters);
92 status.set_heading_with_units(3.1415926535 / 2 * si::radians);
94 using NauticalMile = metric::nautical_mile_base_unit::unit_type;
95 quantity<NauticalMile> x_nm(status.x_with_units());
96 quantity<NauticalMile> y_nm(status.y_with_units());
98 std::cout << status.DebugString() << std::endl;
99 std::cout << x_nm << std::endl;
100 std::cout << y_nm << std::endl;
101 std::cout << status.heading_with_units() << std::endl;
104 p.set_mass_with_units(2 * si::kilograms);
105 p.set_si_mass_with_units(10 * si::kilograms);
106 p.mutable_child()->set_length_with_units(5 * si::meters);
108 assert(p.mass() == 2000);
109 assert(p.si_mass() == 10);
110 assert(p.child().length() == 500);
112 std::cout <<
"all tests passed" << std::endl;