mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Update to 2018_v4 image and new build system. (#598)
* Revert "Force OpenCV to 3.1.0 (#602)"
This reverts commit 50ed55e8e2.
* Removes Simulation
* Removes old build system
* Removes old gtest
* Adds new gmock and gtest
* Updates to new ni-libraries
* removes MyRobot (to be replaced)
* moves files to new location
* Adds new sim backend and new test executables
* updates .styleguide and .gitignore
* Changes cpp WPILibVersion to a function
MSVC throws an AV with the old version.
* Disables USBCamera on all systems except for linux
* 2018 NI Libraries
* New build system
This commit is contained in:
committed by
Peter Johnson
parent
50ed55e8e2
commit
e1195e8b9d
@@ -0,0 +1,30 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2012-2017. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* The interface for sendable objects that gives the sendable a default name in
|
||||
* the Smart Dashboard
|
||||
*
|
||||
*/
|
||||
class NamedSendable : public Sendable {
|
||||
public:
|
||||
/**
|
||||
* @return the name of the subtable of SmartDashboard that the Sendable object
|
||||
* will use
|
||||
*/
|
||||
virtual std::string GetName() const = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
37
wpilibc/src/main/native/include/SmartDashboard/Sendable.h
Normal file
37
wpilibc/src/main/native/include/SmartDashboard/Sendable.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2011-2017. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "tables/ITable.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class Sendable {
|
||||
public:
|
||||
/**
|
||||
* Initializes a table for this sendable object.
|
||||
* @param subtable The table to put the values in.
|
||||
*/
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable) = 0;
|
||||
|
||||
/**
|
||||
* @return the table that is currently associated with the sendable
|
||||
*/
|
||||
virtual std::shared_ptr<ITable> GetTable() const = 0;
|
||||
|
||||
/**
|
||||
* @return the string representation of the named data type that will be used
|
||||
* by the smart dashboard for this sendable
|
||||
*/
|
||||
virtual std::string GetSmartDashboardType() const = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
@@ -0,0 +1,60 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2011-2017. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "SmartDashboard/SendableChooserBase.h"
|
||||
#include "llvm/StringMap.h"
|
||||
#include "llvm/StringRef.h"
|
||||
#include "tables/ITable.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* The {@link SendableChooser} class is a useful tool for presenting a selection
|
||||
* of options to the {@link SmartDashboard}.
|
||||
*
|
||||
* <p>For instance, you may wish to be able to select between multiple
|
||||
* autonomous modes. You can do this by putting every possible {@link Command}
|
||||
* you want to run as an autonomous into a {@link SendableChooser} and then put
|
||||
* it into the {@link SmartDashboard} to have a list of options appear on the
|
||||
* laptop. Once autonomous starts, simply ask the {@link SendableChooser} what
|
||||
* the selected value is.</p>
|
||||
*
|
||||
* @tparam T The type of values to be stored
|
||||
* @see SmartDashboard
|
||||
*/
|
||||
template <class T>
|
||||
class SendableChooser : public SendableChooserBase {
|
||||
llvm::StringMap<T> m_choices;
|
||||
|
||||
template <class U>
|
||||
static U _unwrap_smart_ptr(const U& value);
|
||||
|
||||
template <class U>
|
||||
static U* _unwrap_smart_ptr(const std::unique_ptr<U>& value);
|
||||
|
||||
template <class U>
|
||||
static std::weak_ptr<U> _unwrap_smart_ptr(const std::shared_ptr<U>& value);
|
||||
|
||||
public:
|
||||
virtual ~SendableChooser() = default;
|
||||
|
||||
void AddObject(llvm::StringRef name, T object);
|
||||
void AddDefault(llvm::StringRef name, T object);
|
||||
|
||||
auto GetSelected() -> decltype(_unwrap_smart_ptr(m_choices[""]));
|
||||
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
#include "SendableChooser.inc"
|
||||
@@ -0,0 +1,106 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2011-2017. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Adds the given object to the list of options.
|
||||
*
|
||||
* On the {@link SmartDashboard} on the desktop, the object will appear as the
|
||||
* given name.
|
||||
*
|
||||
* @param name the name of the option
|
||||
* @param object the option
|
||||
*/
|
||||
template <class T>
|
||||
void SendableChooser<T>::AddObject(llvm::StringRef name, T object) {
|
||||
m_choices[name] = std::move(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given object to the list of options and marks it as the default.
|
||||
*
|
||||
* Functionally, this is very close to {@link SendableChooser#AddObject(const
|
||||
* char *name, void *object) AddObject(...)} except that it will use this as
|
||||
* the default option if none other is explicitly selected.
|
||||
*
|
||||
* @param name the name of the option
|
||||
* @param object the option
|
||||
*/
|
||||
template <class T>
|
||||
void SendableChooser<T>::AddDefault(llvm::StringRef name, T object) {
|
||||
m_defaultChoice = name;
|
||||
AddObject(name, std::move(object));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the selected option (a raw pointer U* if T =
|
||||
* std::unique_ptr<U> or a std::weak_ptr<U> if T = std::shared_ptr<U>).
|
||||
*
|
||||
* If there is none selected, it will return the default. If there is none
|
||||
* selected and no default, then it will return a value-initialized instance.
|
||||
* For integer types, this is 0. For container types like std::string, this is
|
||||
* an empty string.
|
||||
*
|
||||
* @return the option selected
|
||||
*/
|
||||
template <class T>
|
||||
auto SendableChooser<T>::GetSelected()
|
||||
-> decltype(_unwrap_smart_ptr(m_choices[""])) {
|
||||
std::string selected = m_table->GetString(kSelected, m_defaultChoice);
|
||||
if (selected == "") {
|
||||
return decltype(_unwrap_smart_ptr(m_choices[""])){};
|
||||
} else {
|
||||
return _unwrap_smart_ptr(m_choices[selected]);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void SendableChooser<T>::InitTable(std::shared_ptr<ITable> subtable) {
|
||||
std::vector<std::string> keys;
|
||||
m_table = subtable;
|
||||
if (m_table != nullptr) {
|
||||
for (const auto& choice : m_choices) {
|
||||
keys.push_back(choice.first());
|
||||
}
|
||||
|
||||
// Unlike std::map, llvm::StringMap elements are not sorted
|
||||
std::sort(keys.begin(), keys.end());
|
||||
|
||||
m_table->PutValue(kOptions, nt::Value::MakeStringArray(std::move(keys)));
|
||||
m_table->PutString(kDefault, m_defaultChoice);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class U>
|
||||
U SendableChooser<T>::_unwrap_smart_ptr(const U& value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class U>
|
||||
U* SendableChooser<T>::_unwrap_smart_ptr(const std::unique_ptr<U>& value) {
|
||||
return value.get();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class U>
|
||||
std::weak_ptr<U> SendableChooser<T>::_unwrap_smart_ptr(
|
||||
const std::shared_ptr<U>& value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
} // namespace frc
|
||||
@@ -0,0 +1,40 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2017. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "tables/ITable.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* This class is a non-template base class for {@link SendableChooser}.
|
||||
*
|
||||
* It contains static, non-templated variables to avoid their duplication in the
|
||||
* template class.
|
||||
*/
|
||||
class SendableChooserBase : public Sendable {
|
||||
public:
|
||||
virtual ~SendableChooserBase() = default;
|
||||
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
protected:
|
||||
static const char* kDefault;
|
||||
static const char* kOptions;
|
||||
static const char* kSelected;
|
||||
|
||||
std::string m_defaultChoice;
|
||||
std::shared_ptr<ITable> m_table;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
100
wpilibc/src/main/native/include/SmartDashboard/SmartDashboard.h
Normal file
100
wpilibc/src/main/native/include/SmartDashboard/SmartDashboard.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2011-2017. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "tables/ITable.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SmartDashboard : public SensorBase {
|
||||
public:
|
||||
static void init();
|
||||
|
||||
static bool ContainsKey(llvm::StringRef key);
|
||||
|
||||
static std::vector<std::string> GetKeys(int types = 0);
|
||||
|
||||
static void SetPersistent(llvm::StringRef key);
|
||||
static void ClearPersistent(llvm::StringRef key);
|
||||
static bool IsPersistent(llvm::StringRef key);
|
||||
|
||||
static void SetFlags(llvm::StringRef key, unsigned int flags);
|
||||
static void ClearFlags(llvm::StringRef key, unsigned int flags);
|
||||
static unsigned int GetFlags(llvm::StringRef key);
|
||||
|
||||
static void Delete(llvm::StringRef key);
|
||||
|
||||
static void PutData(llvm::StringRef key, Sendable* data);
|
||||
static void PutData(NamedSendable* value);
|
||||
static Sendable* GetData(llvm::StringRef keyName);
|
||||
|
||||
static bool PutBoolean(llvm::StringRef keyName, bool value);
|
||||
static bool SetDefaultBoolean(llvm::StringRef key, bool defaultValue);
|
||||
static bool GetBoolean(llvm::StringRef keyName, bool defaultValue);
|
||||
|
||||
static bool PutNumber(llvm::StringRef keyName, double value);
|
||||
static bool SetDefaultNumber(llvm::StringRef key, double defaultValue);
|
||||
static double GetNumber(llvm::StringRef keyName, double defaultValue);
|
||||
|
||||
static bool PutString(llvm::StringRef keyName, llvm::StringRef value);
|
||||
static bool SetDefaultString(llvm::StringRef key,
|
||||
llvm::StringRef defaultValue);
|
||||
static std::string GetString(llvm::StringRef keyName,
|
||||
llvm::StringRef defaultValue);
|
||||
|
||||
static bool PutBooleanArray(llvm::StringRef key, llvm::ArrayRef<int> value);
|
||||
static bool SetDefaultBooleanArray(llvm::StringRef key,
|
||||
llvm::ArrayRef<int> defaultValue);
|
||||
static std::vector<int> GetBooleanArray(llvm::StringRef key,
|
||||
llvm::ArrayRef<int> defaultValue);
|
||||
|
||||
static bool PutNumberArray(llvm::StringRef key, llvm::ArrayRef<double> value);
|
||||
static bool SetDefaultNumberArray(llvm::StringRef key,
|
||||
llvm::ArrayRef<double> defaultValue);
|
||||
static std::vector<double> GetNumberArray(
|
||||
llvm::StringRef key, llvm::ArrayRef<double> defaultValue);
|
||||
|
||||
static bool PutStringArray(llvm::StringRef key,
|
||||
llvm::ArrayRef<std::string> value);
|
||||
static bool SetDefaultStringArray(llvm::StringRef key,
|
||||
llvm::ArrayRef<std::string> defaultValue);
|
||||
static std::vector<std::string> GetStringArray(
|
||||
llvm::StringRef key, llvm::ArrayRef<std::string> defaultValue);
|
||||
|
||||
static bool PutRaw(llvm::StringRef key, llvm::StringRef value);
|
||||
static bool SetDefaultRaw(llvm::StringRef key, llvm::StringRef defaultValue);
|
||||
static std::string GetRaw(llvm::StringRef key, llvm::StringRef defaultValue);
|
||||
|
||||
static bool PutValue(llvm::StringRef keyName,
|
||||
std::shared_ptr<nt::Value> value);
|
||||
static bool SetDefaultValue(llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> defaultValue);
|
||||
static std::shared_ptr<nt::Value> GetValue(llvm::StringRef keyName);
|
||||
|
||||
private:
|
||||
virtual ~SmartDashboard() = default;
|
||||
|
||||
/** The {@link NetworkTable} used by {@link SmartDashboard} */
|
||||
static std::shared_ptr<ITable> m_table;
|
||||
|
||||
/**
|
||||
* A map linking tables in the SmartDashboard to the
|
||||
* {@link SmartDashboardData} objects they came from.
|
||||
*/
|
||||
static std::map<std::shared_ptr<ITable>, Sendable*> m_tablesToData;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
Reference in New Issue
Block a user