mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
merged from frcsim branch
verified to work on real robots adds sim eclipse plugins, fixed JavaGazebo, made wpilibC++Sim build on windows - Java and C++ simulation robot programs run on windows - simulation eclipse plugin delivers models and gazebo plugins - Java Gazebo now respects GAZEBO_IP variables and can work across networks - hal and network tables win32 hacked to work on windows - smart dashboard broken on windows due to network tables hacks - wpilibC++Sim, gz_msgs, and frcsim_gazebo_plugins build with CMake - removed constexpr for cross platform compatibility - msgs generated using .protos as a part of build process - some spare and unused cmake/pom files deleted - simulation ubuntu debians removed entirely - refactored CMake project flags and macros - updated to match non-sim C++ API - fixed and updated documentation - servo added to simulation Change-Id: Ia702ff0f1fee10d77f543810ad88f56696443b05
This commit is contained in:
10
networktables/cpp/include/NTBase.h
Normal file
10
networktables/cpp/include/NTBase.h
Normal file
@@ -0,0 +1,10 @@
|
||||
//this file is used for hacking
|
||||
|
||||
#ifndef NT_BASE_H_
|
||||
#define NT_BASE_H_
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define noexcept throw()
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -8,23 +8,22 @@
|
||||
#define _ERROR_BASE_H
|
||||
|
||||
#if defined WIN32
|
||||
#include <semLib.h>
|
||||
|
||||
#define wpi_setErrnoErrorWithContext(context)
|
||||
#define wpi_setErrnoError()
|
||||
#define wpi_setImaqErrorWithContext(code, context)
|
||||
#define wpi_setErrorWithContext(code, context)
|
||||
#define wpi_setError(code)
|
||||
#define wpi_setStaticErrorWithContext(object, code, context)
|
||||
#define wpi_setErrnoErrorWithContext(context)
|
||||
#define wpi_setErrnoError()
|
||||
#define wpi_setImaqErrorWithContext(code, context)
|
||||
#define wpi_setErrorWithContext(code, context)
|
||||
#define wpi_setError(code)
|
||||
#define wpi_setStaticErrorWithContext(object, code, context)
|
||||
#define wpi_setStaticError(object, code)
|
||||
#define wpi_setGlobalErrorWithContext(code, context)
|
||||
#define wpi_setGlobalError(code)
|
||||
#define wpi_setGlobalErrorWithContext(code, context)
|
||||
#define wpi_setGlobalError(code)
|
||||
#define wpi_setWPIErrorWithContext(error, context)
|
||||
#define wpi_setWPIError(error)
|
||||
#define wpi_setStaticWPIErrorWithContext(object, error, context)
|
||||
#define wpi_setStaticWPIError(object, error)
|
||||
#define wpi_setGlobalWPIErrorWithContext(error, context)
|
||||
#define wpi_setGlobalWPIError(error)
|
||||
#define wpi_setWPIError(error)
|
||||
#define wpi_setStaticWPIErrorWithContext(object, error, context)
|
||||
#define wpi_setStaticWPIError(object, error)
|
||||
#define wpi_setGlobalWPIErrorWithContext(error, context)
|
||||
#define wpi_setGlobalWPIError(error)
|
||||
|
||||
/**
|
||||
* Base class for most objects.
|
||||
@@ -35,7 +34,7 @@ class ErrorBase
|
||||
{
|
||||
//TODO: Consider initializing instance variables and cleanup in destructor
|
||||
public:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,31 +10,6 @@
|
||||
#define NT_CRITICAL_REGION(s) { NTSynchronized _sync(s);
|
||||
#define NT_END_REGION }
|
||||
|
||||
#if defined WIN32
|
||||
|
||||
#include <semLib.h>
|
||||
|
||||
class NTReentrantSemaphore
|
||||
{
|
||||
public:
|
||||
explicit NTReentrantSemaphore(){
|
||||
m_semaphore = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
|
||||
};
|
||||
~NTReentrantSemaphore(){
|
||||
semDelete(m_semaphore);
|
||||
};
|
||||
void take(){
|
||||
semTake(m_semaphore, WAIT_FOREVER);
|
||||
};
|
||||
void give(){
|
||||
semGive(m_semaphore);
|
||||
};
|
||||
private:
|
||||
SEM_ID m_semaphore;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
class NTReentrantSemaphore
|
||||
@@ -59,7 +34,6 @@ private:
|
||||
pthread_mutexattr_t mta;
|
||||
pthread_mutex_t m_semaphore;
|
||||
};
|
||||
#endif // WIN32
|
||||
|
||||
/**
|
||||
* Provide easy support for critical regions.
|
||||
@@ -76,18 +50,9 @@ class NTSynchronized
|
||||
public:
|
||||
explicit NTSynchronized(NTReentrantSemaphore&);
|
||||
//TODO remove vxworks SEM_ID support
|
||||
#if defined WIN32
|
||||
explicit NTSynchronized(SEM_ID);
|
||||
#endif
|
||||
virtual ~NTSynchronized();
|
||||
private:
|
||||
#if defined WIN32
|
||||
bool usingSem;
|
||||
NTReentrantSemaphore* m_sem;
|
||||
SEM_ID m_semaphore;
|
||||
#else
|
||||
NTReentrantSemaphore& m_semaphore;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __NTTASK_H__
|
||||
#define __NTTASK_H__
|
||||
|
||||
#if defined WIN32
|
||||
|
||||
#include "NTErrorBase.h"
|
||||
|
||||
/**
|
||||
* WPI task is a wrapper for the native Task object.
|
||||
* All WPILib tasks are managed by a static task manager for simplified cleanup.
|
||||
**/
|
||||
class NTTask : public ErrorBase
|
||||
{
|
||||
public:
|
||||
static const UINT32 kDefaultPriority = 101;
|
||||
static const INT32 kInvalidTaskID = -1;
|
||||
|
||||
NTTask(const char* name, FUNCPTR function, INT32 priority = kDefaultPriority, UINT32 stackSize = 20000);
|
||||
virtual ~NTTask();
|
||||
|
||||
NTTask(const NTTask&) = delete;
|
||||
NTTask& operator=(const NTTask&) = delete;
|
||||
|
||||
#ifdef WIN32
|
||||
bool Start(void * arg0);
|
||||
#else
|
||||
bool Start(UINT32 arg0 = 0, UINT32 arg1 = 0, UINT32 arg2 = 0, UINT32 arg3 = 0, UINT32 arg4 = 0,
|
||||
UINT32 arg5 = 0, UINT32 arg6 = 0, UINT32 arg7 = 0, UINT32 arg8 = 0, UINT32 arg9 = 0);
|
||||
#endif
|
||||
|
||||
bool Restart();
|
||||
bool Stop();
|
||||
|
||||
bool IsReady();
|
||||
bool IsSuspended();
|
||||
|
||||
bool Suspend();
|
||||
bool Resume();
|
||||
|
||||
bool Verify();
|
||||
|
||||
INT32 GetPriority();
|
||||
bool SetPriority(INT32 priority);
|
||||
const char* GetName();
|
||||
INT32 GetID();
|
||||
|
||||
#ifdef WIN32
|
||||
FUNCPTR m_function;
|
||||
void * m_Arg;
|
||||
#endif
|
||||
private:
|
||||
char* m_taskName;
|
||||
|
||||
#ifdef WIN32
|
||||
bool StartInternal();
|
||||
HANDLE m_Handle;
|
||||
DWORD m_ID;
|
||||
#else
|
||||
FUNCPTR m_function;
|
||||
INT32 m_taskID;
|
||||
#endif
|
||||
|
||||
UINT32 m_stackSize;
|
||||
INT32 m_priority;
|
||||
bool HandleError(STATUS results);
|
||||
};
|
||||
|
||||
#endif // WIN32
|
||||
#endif // __TASK_H__
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef BADMESSAGEEXCEPTION_H_
|
||||
#define BADMESSAGEEXCEPTION_H_
|
||||
|
||||
#include "NTBase.h"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -17,11 +17,7 @@ class PeriodicNTThread;
|
||||
#include "networktables2/thread/NTThreadManager.h"
|
||||
#include "networktables2/thread/NTThread.h"
|
||||
|
||||
#if defined WIN32
|
||||
#include "OSAL/Task.h"
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
class DefaultThreadManager : public NTThreadManager{
|
||||
public:
|
||||
@@ -30,21 +26,11 @@ public:
|
||||
|
||||
class PeriodicNTThread : public NTThread {
|
||||
private:
|
||||
#if defined WIN32
|
||||
const char* name;
|
||||
NTTask* thread;
|
||||
#else
|
||||
pthread_t thread;
|
||||
#endif
|
||||
PeriodicRunnable* r;
|
||||
bool run;
|
||||
#if defined WIN32
|
||||
int _taskMain();
|
||||
static int taskMain(PeriodicNTThread* o);
|
||||
#else//TODO make return int for pthread as well
|
||||
void _taskMain();
|
||||
static void* taskMain(PeriodicNTThread* o);
|
||||
#endif
|
||||
public:
|
||||
PeriodicNTThread(PeriodicRunnable* r, const char* name);
|
||||
virtual ~PeriodicNTThread();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef IOEXCEPTION_H_
|
||||
#define IOEXCEPTION_H_
|
||||
|
||||
#include "NTBase.h"
|
||||
#include <exception>
|
||||
|
||||
/**
|
||||
@@ -17,31 +18,31 @@ class IOException : public std::exception{
|
||||
public:
|
||||
/**
|
||||
* Creates a new IOException with the given message.
|
||||
*
|
||||
*
|
||||
* @param message The message to associate with this exception.
|
||||
*/
|
||||
IOException(const char* message);
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new IOException with the given message and
|
||||
* error value.
|
||||
*
|
||||
*
|
||||
* @param message The message to associate with this exception.
|
||||
* @param errorValue The integer code to associate with this exception.
|
||||
*/
|
||||
IOException(const char* message, int errorValue);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the message associated with this exception.
|
||||
*
|
||||
*
|
||||
* @return The message associated with this exception.
|
||||
*/
|
||||
const char* what() const noexcept;
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether this exception indicates that an EOF
|
||||
* was encountered.
|
||||
*
|
||||
*
|
||||
* @return True if this exception indicates that an EOF was encountered.
|
||||
* False otherwise.
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef ILLEGALSTATEEXCEPTION_H_
|
||||
#define ILLEGALSTATEEXCEPTION_H_
|
||||
|
||||
#include "NTBase.h"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -8,10 +8,9 @@
|
||||
#ifndef ITABLELISTENER_H_
|
||||
#define ITABLELISTENER_H_
|
||||
|
||||
|
||||
class ITableListener;
|
||||
|
||||
|
||||
#include "NTBase.h"
|
||||
#include "tables/ITable.h"
|
||||
|
||||
#include <memory>
|
||||
@@ -42,7 +41,11 @@ class ITableListener {
|
||||
|
||||
private:
|
||||
template <class T>
|
||||
struct[[deprecated]] NullDeleter {
|
||||
struct
|
||||
#if !defined(_MSC_VER)
|
||||
[[deprecated]]
|
||||
#endif
|
||||
NullDeleter {
|
||||
void operator()(T*) const noexcept {};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user