2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2016-01-02 03:02:34 -08:00
|
|
|
/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "Ultrasonic.h"
|
|
|
|
|
|
|
|
|
|
#include "Counter.h"
|
|
|
|
|
#include "DigitalInput.h"
|
|
|
|
|
#include "DigitalOutput.h"
|
2016-11-01 20:12:08 -07:00
|
|
|
#include "HAL/HAL.h"
|
2016-05-20 17:30:37 -07:00
|
|
|
#include "LiveWindow/LiveWindow.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
#include "Timer.h"
|
|
|
|
|
#include "Utility.h"
|
|
|
|
|
#include "WPIErrors.h"
|
|
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2015-10-30 01:07:14 -07:00
|
|
|
// Time (sec) for the ping trigger pulse.
|
|
|
|
|
constexpr double Ultrasonic::kPingTime;
|
|
|
|
|
// Priority that the ultrasonic round robin task runs.
|
2016-09-06 00:01:45 -07:00
|
|
|
const int Ultrasonic::kPriority;
|
2015-10-30 01:07:14 -07:00
|
|
|
// Max time (ms) between readings.
|
|
|
|
|
constexpr double Ultrasonic::kMaxUltrasonicTime;
|
2013-12-15 18:30:16 -05:00
|
|
|
constexpr double Ultrasonic::kSpeedOfSoundInchesPerSec;
|
2015-10-30 01:07:14 -07:00
|
|
|
// automatic round robin mode
|
|
|
|
|
std::atomic<bool> Ultrasonic::m_automaticEnabled{false};
|
2016-01-12 16:27:34 -05:00
|
|
|
std::set<Ultrasonic*> Ultrasonic::m_sensors;
|
2013-12-15 18:30:16 -05:00
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Background task that goes through the list of ultrasonic sensors and pings
|
2016-05-20 17:30:37 -07:00
|
|
|
* each one in turn. The counter is configured to read the timing of the
|
|
|
|
|
* returned echo pulse.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* DANGER WILL ROBINSON, DANGER WILL ROBINSON:
|
2015-10-30 01:07:14 -07:00
|
|
|
* This code runs as a task and assumes that none of the ultrasonic sensors
|
|
|
|
|
* will change while it's running. Make sure to disable automatic mode before
|
|
|
|
|
* touching the list.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void Ultrasonic::UltrasonicChecker() {
|
|
|
|
|
while (m_automaticEnabled) {
|
2015-10-30 01:07:14 -07:00
|
|
|
for (auto& sensor : m_sensors) {
|
|
|
|
|
if (!m_automaticEnabled) break;
|
|
|
|
|
|
|
|
|
|
if (sensor->IsEnabled()) {
|
2016-05-20 17:30:37 -07:00
|
|
|
sensor->m_pingChannel->Pulse(kPingTime); // do the ping
|
2015-10-30 01:07:14 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
Wait(0.1); // wait for ping to return
|
2015-10-30 01:07:14 -07:00
|
|
|
}
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initialize the Ultrasonic Sensor.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* This is the common code that initializes the ultrasonic sensor given that
|
2016-05-20 17:30:37 -07:00
|
|
|
* there are two digital I/O channels allocated. If the system was running in
|
|
|
|
|
* automatic mode (round robin) when the new sensor is added, it is stopped,
|
|
|
|
|
* the sensor is added, then automatic mode is restored.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void Ultrasonic::Initialize() {
|
|
|
|
|
bool originalMode = m_automaticEnabled;
|
2016-05-20 17:30:37 -07:00
|
|
|
SetAutomaticMode(false); // kill task when adding a new sensor
|
2015-06-25 01:54:20 -07:00
|
|
|
// link this instance on the list
|
2015-10-30 01:07:14 -07:00
|
|
|
m_sensors.insert(this);
|
2013-12-15 18:30:16 -05:00
|
|
|
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
m_counter.SetMaxPeriod(1.0);
|
|
|
|
|
m_counter.SetSemiPeriodMode(true);
|
|
|
|
|
m_counter.Reset();
|
2015-06-25 15:07:55 -04:00
|
|
|
m_enabled = true; // make it available for round robin scheduling
|
|
|
|
|
SetAutomaticMode(originalMode);
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
static int instances = 0;
|
|
|
|
|
instances++;
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_Report(HALUsageReporting::kResourceType_Ultrasonic, instances);
|
Revert changes preventing old user code from compiling.
I'm not 100% sure whether we want these, but they are a quick
find and replace to do.
Basically, there are two primary things that we have done
this summer that break existing user code:
-Changing GetInstance() calls to return references instead
of pointers. This forces users to change from doing something
like LiveWindow::GetInstance()->AddSensor() to LiveWindow::GetInstance().AddSensor().
-Making PIDGet() and related calls const, forcing users to change
the function signatures wherever they override them.
The GetInstance() calls don't really matter to me either way,
especially since there are no real ownership issues going on there,
unlike the rest of the smart pointer-related changes.
For the const stuff, it is certainly more correct to mandate that
user PIDGet() functions be const and the such, but at the same time,
I'm not sure that there is any strong need for it, and the errors
generated are not the most helpful. While this wouldn't necessarily
be an issue for more experienced teams or completely new teams (who
don't have any old code to be reusing), it may cause issues for more
average teams who aren't familiar with the intricacies of C++ anything.
Change-Id: I6e7007982069292ea70e6d0fc8ca40203340df1b
2015-07-24 19:19:40 -04:00
|
|
|
LiveWindow::GetInstance()->AddSensor("Ultrasonic",
|
2015-06-25 15:07:55 -04:00
|
|
|
m_echoChannel->GetChannel(), this);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-05-20 17:30:37 -07:00
|
|
|
* Create an instance of the Ultrasonic Sensor.
|
|
|
|
|
*
|
|
|
|
|
* This is designed to support the Daventech SRF04 and Vex ultrasonic
|
2015-06-25 15:07:55 -04:00
|
|
|
* sensors.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* @param pingChannel The digital output channel that sends the pulse to
|
2016-05-20 17:30:37 -07:00
|
|
|
* initiate the sensor sending the ping.
|
2015-06-25 15:07:55 -04:00
|
|
|
* @param echoChannel The digital input channel that receives the echo. The
|
2016-05-20 17:30:37 -07:00
|
|
|
* length of time that the echo is high represents the
|
|
|
|
|
* round trip time of the ping, and the distance.
|
|
|
|
|
* @param units The units returned in either kInches or kMilliMeters
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
Ultrasonic::Ultrasonic(int pingChannel, int echoChannel, DistanceUnit units)
|
2015-07-29 16:48:04 -04:00
|
|
|
: m_pingChannel(std::make_shared<DigitalOutput>(pingChannel)),
|
|
|
|
|
m_echoChannel(std::make_shared<DigitalInput>(echoChannel)),
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
m_counter(m_echoChannel) {
|
2015-06-25 15:07:55 -04:00
|
|
|
m_units = units;
|
|
|
|
|
Initialize();
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Create an instance of an Ultrasonic Sensor from a DigitalInput for the echo
|
2016-05-20 17:30:37 -07:00
|
|
|
* channel and a DigitalOutput for the ping channel.
|
|
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* @param pingChannel The digital output object that starts the sensor doing a
|
2016-05-20 17:30:37 -07:00
|
|
|
* ping. Requires a 10uS pulse to start.
|
2015-06-25 15:07:55 -04:00
|
|
|
* @param echoChannel The digital input object that times the return pulse to
|
2016-05-20 17:30:37 -07:00
|
|
|
* determine the range.
|
|
|
|
|
* @param units The units returned in either kInches or kMilliMeters
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
Ultrasonic::Ultrasonic(DigitalOutput* pingChannel, DigitalInput* echoChannel,
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
DistanceUnit units)
|
|
|
|
|
: m_pingChannel(pingChannel, NullDeleter<DigitalOutput>()),
|
|
|
|
|
m_echoChannel(echoChannel, NullDeleter<DigitalInput>()),
|
|
|
|
|
m_counter(m_echoChannel) {
|
2015-06-23 04:49:51 -07:00
|
|
|
if (pingChannel == nullptr || echoChannel == nullptr) {
|
2015-06-25 15:07:55 -04:00
|
|
|
wpi_setWPIError(NullParameter);
|
2015-11-15 14:49:50 -08:00
|
|
|
m_units = units;
|
2015-06-25 15:07:55 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
m_units = units;
|
|
|
|
|
Initialize();
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Create an instance of an Ultrasonic Sensor from a DigitalInput for the echo
|
2016-05-20 17:30:37 -07:00
|
|
|
* channel and a DigitalOutput for the ping channel.
|
|
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* @param pingChannel The digital output object that starts the sensor doing a
|
2016-05-20 17:30:37 -07:00
|
|
|
* ping. Requires a 10uS pulse to start.
|
2015-06-25 15:07:55 -04:00
|
|
|
* @param echoChannel The digital input object that times the return pulse to
|
2016-05-20 17:30:37 -07:00
|
|
|
* determine the range.
|
|
|
|
|
* @param units The units returned in either kInches or kMilliMeters
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
Ultrasonic::Ultrasonic(DigitalOutput& pingChannel, DigitalInput& echoChannel,
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
DistanceUnit units)
|
|
|
|
|
: m_pingChannel(&pingChannel, NullDeleter<DigitalOutput>()),
|
|
|
|
|
m_echoChannel(&echoChannel, NullDeleter<DigitalInput>()),
|
|
|
|
|
m_counter(m_echoChannel) {
|
|
|
|
|
m_units = units;
|
|
|
|
|
Initialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create an instance of an Ultrasonic Sensor from a DigitalInput for the echo
|
2016-05-20 17:30:37 -07:00
|
|
|
* channel and a DigitalOutput for the ping channel.
|
|
|
|
|
*
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
* @param pingChannel The digital output object that starts the sensor doing a
|
2016-05-20 17:30:37 -07:00
|
|
|
* ping. Requires a 10uS pulse to start.
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
* @param echoChannel The digital input object that times the return pulse to
|
2016-05-20 17:30:37 -07:00
|
|
|
* determine the range.
|
|
|
|
|
* @param units The units returned in either kInches or kMilliMeters
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
*/
|
2015-07-29 16:48:04 -04:00
|
|
|
Ultrasonic::Ultrasonic(std::shared_ptr<DigitalOutput> pingChannel,
|
|
|
|
|
std::shared_ptr<DigitalInput> echoChannel,
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
DistanceUnit units)
|
|
|
|
|
: m_pingChannel(pingChannel),
|
|
|
|
|
m_echoChannel(echoChannel),
|
|
|
|
|
m_counter(m_echoChannel) {
|
2015-06-25 15:07:55 -04:00
|
|
|
m_units = units;
|
|
|
|
|
Initialize();
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor for the ultrasonic sensor.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* Delete the instance of the ultrasonic sensor by freeing the allocated digital
|
2016-05-20 17:30:37 -07:00
|
|
|
* channels. If the system was in automatic mode (round robin), then it is
|
|
|
|
|
* stopped, then started again after this sensor is removed (provided this
|
|
|
|
|
* wasn't the last sensor).
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
Ultrasonic::~Ultrasonic() {
|
|
|
|
|
bool wasAutomaticMode = m_automaticEnabled;
|
|
|
|
|
SetAutomaticMode(false);
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-10-30 01:07:14 -07:00
|
|
|
// No synchronization needed because the background task is stopped.
|
|
|
|
|
m_sensors.erase(this);
|
|
|
|
|
|
|
|
|
|
if (!m_sensors.empty() && wasAutomaticMode) {
|
|
|
|
|
SetAutomaticMode(true);
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Turn Automatic mode on/off.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* When in Automatic mode, all sensors will fire in round robin, waiting a set
|
|
|
|
|
* time between each sensor.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* @param enabling Set to true if round robin scheduling should start for all
|
2016-05-20 17:30:37 -07:00
|
|
|
* the ultrasonic sensors. This scheduling method assures that
|
|
|
|
|
* the sensors are non-interfering because no two sensors fire
|
|
|
|
|
* at the same time. If another scheduling algorithm is
|
|
|
|
|
* prefered, it can be implemented by pinging the sensors
|
|
|
|
|
* manually and waiting for the results to come back.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void Ultrasonic::SetAutomaticMode(bool enabling) {
|
|
|
|
|
if (enabling == m_automaticEnabled) return; // ignore the case of no change
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
m_automaticEnabled = enabling;
|
2015-10-30 01:07:14 -07:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
if (enabling) {
|
2015-10-30 01:07:14 -07:00
|
|
|
/* Clear all the counters so no data is valid. No synchronization is needed
|
|
|
|
|
* because the background task is stopped.
|
|
|
|
|
*/
|
|
|
|
|
for (auto& sensor : m_sensors) {
|
|
|
|
|
sensor->m_counter.Reset();
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
2015-10-30 01:07:14 -07:00
|
|
|
|
2016-11-01 20:12:08 -07:00
|
|
|
m_thread = std::thread(&Ultrasonic::UltrasonicChecker);
|
2014-08-14 00:07:02 -07:00
|
|
|
|
|
|
|
|
// TODO: Currently, lvuser does not have permissions to set task priorities.
|
|
|
|
|
// Until that is the case, uncommenting this will break user code that calls
|
|
|
|
|
// Ultrasonic::SetAutomicMode().
|
2016-05-20 17:30:37 -07:00
|
|
|
// m_task.SetPriority(kPriority);
|
2015-06-25 15:07:55 -04:00
|
|
|
} else {
|
2015-10-30 01:07:14 -07:00
|
|
|
// Wait for background task to stop running
|
2016-11-01 20:12:08 -07:00
|
|
|
m_thread.join();
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-10-30 01:07:14 -07:00
|
|
|
/* Clear all the counters (data now invalid) since automatic mode is
|
|
|
|
|
* disabled. No synchronization is needed because the background task is
|
|
|
|
|
* stopped.
|
|
|
|
|
*/
|
|
|
|
|
for (auto& sensor : m_sensors) {
|
|
|
|
|
sensor->m_counter.Reset();
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Single ping to ultrasonic sensor.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* Send out a single ping to the ultrasonic sensor. This only works if automatic
|
2015-10-30 01:07:14 -07:00
|
|
|
* (round robin) mode is disabled. A single ping is sent out, and the counter
|
|
|
|
|
* should count the semi-period when it comes in. The counter is reset to make
|
|
|
|
|
* the current value invalid.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void Ultrasonic::Ping() {
|
|
|
|
|
wpi_assert(!m_automaticEnabled);
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
m_counter.Reset(); // reset the counter to zero (invalid data now)
|
2015-06-25 15:07:55 -04:00
|
|
|
m_pingChannel->Pulse(
|
|
|
|
|
kPingTime); // do the ping to start getting a single range
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if there is a valid range measurement.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* The ranges are accumulated in a counter that will increment on each edge of
|
2016-05-20 17:30:37 -07:00
|
|
|
* the echo (return) signal. If the count is not at least 2, then the range has
|
|
|
|
|
* not yet been measured, and is invalid.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
bool Ultrasonic::IsRangeValid() const { return m_counter.Get() > 1; }
|
2013-12-15 18:30:16 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the range in inches from the ultrasonic sensor.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* @return double Range in inches of the target returned from the ultrasonic
|
2016-05-20 17:30:37 -07:00
|
|
|
* sensor. If there is no valid value yet, i.e. at least one
|
|
|
|
|
* measurement hasn't completed, then return 0.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
double Ultrasonic::GetRangeInches() const {
|
|
|
|
|
if (IsRangeValid())
|
artf4154: Get rid of raw pointers in C++.
This deals with the majority of the user-facing code
in wpilibC++Devices and a substantial portion of it in
wpilibC++. wpilibC++Sim and wpilibC++IntegrationTests
are untouched except where it is necessary to make them
work with the rest of the libraries.
There is still a lot to do in the following areas:
-The HAL (which we may not want to touch at all).
-The I2C, Serial, and SPI interfaces in wpilibC++Devices,
which I haven't gotten around to doing yet.
-Most wpilibC++Devices classes have void* pointers
for interacting with the HAL.
-InterruptableSensorBase passes a void *params for
the interrupt handler.
-I haven't converted all the const char* to std::strings.
-There are plenty of other cases of raw pointers still
existing.
-This doesn't fall directly under raw pointer stuff,
but move syntax and rvalue references could be introduced
in many places.
-I haven't touched vision code.
-The Resource classes conflict (one is in the hal, the other
in wpilibC++). Someone should figure out a more
permanent fix (eg, just renaming them), then doing
what I did (making a new namespace for one of them,
essentially the same as renaming it).
A few other things:
-I created a NullDeleter class which is marked as deprecated.
What this does is it can be passed as the deleter to a
std::shared_ptr so that when you are converting raw pointers
to shared_ptrs the shared_ptr doesn't do any deletion if
someone else owns the raw pointer. This should only be
used in making old raw pointer UIs.
-I had to alter the build.gradle so that it did not
emit errors when deprecated functions called deprecated
functions. Unfortunately, gradle doesn't appear to be
actually printing out gcc warnigns for some reason.
The best way I have found to fix this is to patch
the toolchains (https://bitbucket.org/byteit101/toolchain-builder/pull-request/5/make-gcc-not-throw-warnings-for-nested/diff)
so that a deprecated function calling a deprecated
function is fine but a non-deprecated function calling
a deprecated function will throw a warning (which we
then elevate with -Werror). I believe that clang
deals with this properly, although I have not
tried it myself.
Change-Id: Ib8090c66893576fe73654f4e9d268f9d37be06a2
2015-06-30 15:01:20 -04:00
|
|
|
return m_counter.GetPeriod() * kSpeedOfSoundInchesPerSec / 2.0;
|
2015-06-25 15:07:55 -04:00
|
|
|
else
|
|
|
|
|
return 0;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the range in millimeters from the ultrasonic sensor.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* @return double Range in millimeters of the target returned by the ultrasonic
|
2016-05-20 17:30:37 -07:00
|
|
|
* sensor. If there is no valid value yet, i.e. at least one
|
|
|
|
|
* measurement hasn't completed, then return 0.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
double Ultrasonic::GetRangeMM() const { return GetRangeInches() * 25.4; }
|
2013-12-15 18:30:16 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the range in the current DistanceUnit for the PIDSource base object.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @return The range in DistanceUnit
|
|
|
|
|
*/
|
Revert changes preventing old user code from compiling.
I'm not 100% sure whether we want these, but they are a quick
find and replace to do.
Basically, there are two primary things that we have done
this summer that break existing user code:
-Changing GetInstance() calls to return references instead
of pointers. This forces users to change from doing something
like LiveWindow::GetInstance()->AddSensor() to LiveWindow::GetInstance().AddSensor().
-Making PIDGet() and related calls const, forcing users to change
the function signatures wherever they override them.
The GetInstance() calls don't really matter to me either way,
especially since there are no real ownership issues going on there,
unlike the rest of the smart pointer-related changes.
For the const stuff, it is certainly more correct to mandate that
user PIDGet() functions be const and the such, but at the same time,
I'm not sure that there is any strong need for it, and the errors
generated are not the most helpful. While this wouldn't necessarily
be an issue for more experienced teams or completely new teams (who
don't have any old code to be reusing), it may cause issues for more
average teams who aren't familiar with the intricacies of C++ anything.
Change-Id: I6e7007982069292ea70e6d0fc8ca40203340df1b
2015-07-24 19:19:40 -04:00
|
|
|
double Ultrasonic::PIDGet() {
|
2015-06-25 15:07:55 -04:00
|
|
|
switch (m_units) {
|
|
|
|
|
case Ultrasonic::kInches:
|
|
|
|
|
return GetRangeInches();
|
|
|
|
|
case Ultrasonic::kMilliMeters:
|
|
|
|
|
return GetRangeMM();
|
|
|
|
|
default:
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-07-14 20:37:52 -07:00
|
|
|
void Ultrasonic::SetPIDSourceType(PIDSourceType pidSource) {
|
|
|
|
|
if (wpi_assert(pidSource == PIDSourceType::kDisplacement)) {
|
|
|
|
|
m_pidSource = pidSource;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Set the current DistanceUnit that should be used for the PIDSource base
|
|
|
|
|
* object.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param units The DistanceUnit that should be used.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void Ultrasonic::SetDistanceUnits(DistanceUnit units) { m_units = units; }
|
2013-12-15 18:30:16 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the current DistanceUnit that is used for the PIDSource base object.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @return The type of DistanceUnit that is being used.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
Ultrasonic::DistanceUnit Ultrasonic::GetDistanceUnits() const {
|
|
|
|
|
return m_units;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Ultrasonic::UpdateTable() {
|
2015-06-23 04:49:51 -07:00
|
|
|
if (m_table != nullptr) {
|
2015-06-25 15:07:55 -04:00
|
|
|
m_table->PutNumber("Value", GetRangeInches());
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
void Ultrasonic::StartLiveWindowMode() {}
|
2014-06-13 17:45:10 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
void Ultrasonic::StopLiveWindowMode() {}
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
std::string Ultrasonic::GetSmartDashboardType() const { return "Ultrasonic"; }
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-07-29 16:48:04 -04:00
|
|
|
void Ultrasonic::InitTable(std::shared_ptr<ITable> subTable) {
|
2015-06-25 15:07:55 -04:00
|
|
|
m_table = subTable;
|
|
|
|
|
UpdateTable();
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-07-29 16:48:04 -04:00
|
|
|
std::shared_ptr<ITable> Ultrasonic::GetTable() const { return m_table; }
|