reorganized and added aerpawlib submodule
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -48,3 +48,7 @@ sandbox/*
|
|||||||
|
|
||||||
# Figures
|
# Figures
|
||||||
*.fig
|
*.fig
|
||||||
|
|
||||||
|
# Python Virtual Environment
|
||||||
|
aerpaw/venv/
|
||||||
|
aerpaw/venv/*
|
||||||
|
|||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "aerpaw/aerpawlib"]
|
||||||
|
path = aerpaw/aerpawlib
|
||||||
|
url = https://github.com/morzack/aerpawlib-vehicle-control.git
|
||||||
1
aerpaw/aerpawlib
Submodule
1
aerpaw/aerpawlib
Submodule
Submodule aerpaw/aerpawlib added at 705fc699ef
@@ -1,85 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <thread>
|
|
||||||
#include <vector>
|
|
||||||
#include <cstring>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define SERVER_PORT 5000
|
|
||||||
#define SERVER_IP "127.0.0.1"
|
|
||||||
|
|
||||||
#define OPCODE_SHUTDOWN 0xFF
|
|
||||||
|
|
||||||
// Socket init
|
|
||||||
void initSockets() {}
|
|
||||||
void cleanupSockets() {}
|
|
||||||
|
|
||||||
int serverSocket = -1;
|
|
||||||
std::vector<int> clientSockets;
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
// Initialize server (call once)
|
|
||||||
void initServer() {
|
|
||||||
initSockets();
|
|
||||||
serverSocket = socket(AF_INET, SOCK_STREAM, 0);
|
|
||||||
if(serverSocket < 0) { std::cerr << "Socket creation failed\n"; return; }
|
|
||||||
|
|
||||||
sockaddr_in serverAddr;
|
|
||||||
serverAddr.sin_family = AF_INET;
|
|
||||||
serverAddr.sin_addr.s_addr = INADDR_ANY;
|
|
||||||
serverAddr.sin_port = htons(SERVER_PORT);
|
|
||||||
|
|
||||||
int opt = 1;
|
|
||||||
setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, (char*)&opt, sizeof(opt));
|
|
||||||
|
|
||||||
if(bind(serverSocket, (sockaddr*)&serverAddr, sizeof(serverAddr)) < 0) {
|
|
||||||
std::cerr << "Bind failed\n"; return;
|
|
||||||
}
|
|
||||||
if(listen(serverSocket, 5) < 0) {
|
|
||||||
std::cerr << "Listen failed\n"; return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "Server initialized, waiting for clients...\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Accept client connections (call once per client)
|
|
||||||
void acceptClient(int clientId) {
|
|
||||||
sockaddr_in clientAddr;
|
|
||||||
socklen_t addrLen = sizeof(clientAddr);
|
|
||||||
int clientSock = accept(serverSocket, (sockaddr*)&clientAddr, &addrLen);
|
|
||||||
if(clientSock < 0) { std::cerr << "Accept failed for client " << clientId << "\n"; return; }
|
|
||||||
clientSockets.push_back(clientSock);
|
|
||||||
std::cout << "Client " << clientId << " connected\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send a message to a specific client
|
|
||||||
void sendMessage(int clientId) {
|
|
||||||
if(clientId <= 0 || clientId > clientSockets.size()) return;
|
|
||||||
const char* msg = "Hello from server";
|
|
||||||
send(clientSockets[clientId-1], msg, strlen(msg), 0);
|
|
||||||
std::cout << "Sent message to client " << clientId << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receive ACK from a specific client
|
|
||||||
int receiveAck(int clientId) {
|
|
||||||
if(clientId <= 0 || clientId > clientSockets.size()) return 0;
|
|
||||||
char buffer[1024];
|
|
||||||
int len = recv(clientSockets[clientId-1], buffer, sizeof(buffer)-1, 0);
|
|
||||||
if(len <= 0) return 0;
|
|
||||||
buffer[len] = '\0';
|
|
||||||
std::cout << "Received ACK from client " << clientId << ": " << buffer << "\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanup server
|
|
||||||
void closeServer() {
|
|
||||||
for(auto sock : clientSockets) {
|
|
||||||
close(sock);
|
|
||||||
}
|
|
||||||
close(serverSocket);
|
|
||||||
cleanupSockets();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#g++ -I/home/kdee/matlab/R2025a/extern/include controller_main.cpp controller.cpp controller_impl.cpp -o controller_app -lpthread
|
|
||||||
|
|
||||||
#wd=$(pwd)
|
|
||||||
#cd /home/kdee/Desktop/miSim/aerpaw/codegen
|
|
||||||
g++ -I/home/kdee/matlab/R2025a/extern/include -I. controller_main.cpp controller.cpp controller_impl.cpp controller_initialize.cpp controller_terminate.cpp -o controller_app -lpthread
|
|
||||||
#cd $wd
|
|
||||||
|
|
||||||
#g++ controller_main.cpp controller.cpp controller_impl.cpp controller_initialize.cpp controller_terminate.cpp
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
//
|
|
||||||
// Academic License - for use in teaching, academic research, and meeting
|
|
||||||
// course requirements at degree granting institutions only. Not for
|
|
||||||
// government, commercial, or other organizational use.
|
|
||||||
//
|
|
||||||
// controller.cpp
|
|
||||||
//
|
|
||||||
// Code generation for function 'controller'
|
|
||||||
//
|
|
||||||
|
|
||||||
// Include files
|
|
||||||
#include "controller.h"
|
|
||||||
#include "controller_impl.h"
|
|
||||||
|
|
||||||
// Function Definitions
|
|
||||||
void controller(int numClients)
|
|
||||||
{
|
|
||||||
static const char b_filename[12]{"targets.txt"};
|
|
||||||
double targets[12];
|
|
||||||
char filename[12];
|
|
||||||
// Maximum clients supported
|
|
||||||
// Allocate targets array (MAX_CLIENTS x 3)
|
|
||||||
// Load targets from file
|
|
||||||
// Define filename as null-terminated character array for C compatibility
|
|
||||||
for (int i{0}; i < 12; i++) {
|
|
||||||
targets[i] = 0.0;
|
|
||||||
filename[i] = b_filename[i];
|
|
||||||
}
|
|
||||||
// loadTargets fills targets array (row-major: x1,y1,z1,x2,y2,z2,...)
|
|
||||||
loadTargets(&filename[0], &targets[0], 4);
|
|
||||||
// Initialize server
|
|
||||||
initServer();
|
|
||||||
// Accept clients
|
|
||||||
for (int i{0}; i < numClients; i++) {
|
|
||||||
acceptClient(i + 1);
|
|
||||||
}
|
|
||||||
// Send target coordinates to each client
|
|
||||||
for (int i{0}; i < numClients; i++) {
|
|
||||||
double target[3];
|
|
||||||
// Get target for this client (1x3 array)
|
|
||||||
target[0] = targets[i];
|
|
||||||
target[1] = targets[i + 4];
|
|
||||||
target[2] = targets[i + 8];
|
|
||||||
sendTarget(i + 1, &target[0]);
|
|
||||||
}
|
|
||||||
// Receive TARGET acknowledgments
|
|
||||||
for (int i{0}; i < numClients; i++) {
|
|
||||||
receiveTargetAck(i + 1);
|
|
||||||
}
|
|
||||||
// Check all ACKs received
|
|
||||||
// Wait for READY signals (UAVs have reached their targets)
|
|
||||||
for (int i{0}; i < numClients; i++) {
|
|
||||||
waitForReady(i + 1);
|
|
||||||
}
|
|
||||||
// Check all READY signals received
|
|
||||||
// Send COMPLETE to all clients before closing
|
|
||||||
for (int i{0}; i < numClients; i++) {
|
|
||||||
sendFinished(i + 1);
|
|
||||||
}
|
|
||||||
// Close server
|
|
||||||
closeServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
// End of code generation (controller.cpp)
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
//
|
|
||||||
// Academic License - for use in teaching, academic research, and meeting
|
|
||||||
// course requirements at degree granting institutions only. Not for
|
|
||||||
// government, commercial, or other organizational use.
|
|
||||||
//
|
|
||||||
// controller.h
|
|
||||||
//
|
|
||||||
// Code generation for function 'controller'
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CONTROLLER_H
|
|
||||||
#define CONTROLLER_H
|
|
||||||
|
|
||||||
// Include files
|
|
||||||
#include "rtwtypes.h"
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
// Function Declarations
|
|
||||||
extern void controller(int numClients);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// End of code generation (controller.h)
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
//
|
|
||||||
// Academic License - for use in teaching, academic research, and meeting
|
|
||||||
// course requirements at degree granting institutions only. Not for
|
|
||||||
// government, commercial, or other organizational use.
|
|
||||||
//
|
|
||||||
// controller_data.h
|
|
||||||
//
|
|
||||||
// Code generation for function 'controller_data'
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CONTROLLER_DATA_H
|
|
||||||
#define CONTROLLER_DATA_H
|
|
||||||
|
|
||||||
// Include files
|
|
||||||
#include "rtwtypes.h"
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// End of code generation (controller_data.h)
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
//
|
|
||||||
// Academic License - for use in teaching, academic research, and meeting
|
|
||||||
// course requirements at degree granting institutions only. Not for
|
|
||||||
// government, commercial, or other organizational use.
|
|
||||||
//
|
|
||||||
// controller_initialize.cpp
|
|
||||||
//
|
|
||||||
// Code generation for function 'controller_initialize'
|
|
||||||
//
|
|
||||||
|
|
||||||
// Include files
|
|
||||||
#include "controller_initialize.h"
|
|
||||||
|
|
||||||
// Function Definitions
|
|
||||||
void controller_initialize()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// End of code generation (controller_initialize.cpp)
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
//
|
|
||||||
// Academic License - for use in teaching, academic research, and meeting
|
|
||||||
// course requirements at degree granting institutions only. Not for
|
|
||||||
// government, commercial, or other organizational use.
|
|
||||||
//
|
|
||||||
// controller_initialize.h
|
|
||||||
//
|
|
||||||
// Code generation for function 'controller_initialize'
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CONTROLLER_INITIALIZE_H
|
|
||||||
#define CONTROLLER_INITIALIZE_H
|
|
||||||
|
|
||||||
// Include files
|
|
||||||
#include "rtwtypes.h"
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
// Function Declarations
|
|
||||||
extern void controller_initialize();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// End of code generation (controller_initialize.h)
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
//
|
|
||||||
// Academic License - for use in teaching, academic research, and meeting
|
|
||||||
// course requirements at degree granting institutions only. Not for
|
|
||||||
// government, commercial, or other organizational use.
|
|
||||||
//
|
|
||||||
// controller_terminate.cpp
|
|
||||||
//
|
|
||||||
// Code generation for function 'controller_terminate'
|
|
||||||
//
|
|
||||||
|
|
||||||
// Include files
|
|
||||||
#include "controller_terminate.h"
|
|
||||||
|
|
||||||
// Function Definitions
|
|
||||||
void controller_terminate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// End of code generation (controller_terminate.cpp)
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
//
|
|
||||||
// Academic License - for use in teaching, academic research, and meeting
|
|
||||||
// course requirements at degree granting institutions only. Not for
|
|
||||||
// government, commercial, or other organizational use.
|
|
||||||
//
|
|
||||||
// controller_terminate.h
|
|
||||||
//
|
|
||||||
// Code generation for function 'controller_terminate'
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CONTROLLER_TERMINATE_H
|
|
||||||
#define CONTROLLER_TERMINATE_H
|
|
||||||
|
|
||||||
// Include files
|
|
||||||
#include "rtwtypes.h"
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
// Function Declarations
|
|
||||||
extern void controller_terminate();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// End of code generation (controller_terminate.h)
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
//
|
|
||||||
// Academic License - for use in teaching, academic research, and meeting
|
|
||||||
// course requirements at degree granting institutions only. Not for
|
|
||||||
// government, commercial, or other organizational use.
|
|
||||||
//
|
|
||||||
// controller_types.h
|
|
||||||
//
|
|
||||||
// Code generation for function 'controller'
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CONTROLLER_TYPES_H
|
|
||||||
#define CONTROLLER_TYPES_H
|
|
||||||
|
|
||||||
// Include files
|
|
||||||
#include "rtwtypes.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// End of code generation (controller_types.h)
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cp ../codegen/*.h .
|
|
||||||
cp ../codegen/*.cpp .
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
//
|
|
||||||
// Academic License - for use in teaching, academic research, and meeting
|
|
||||||
// course requirements at degree granting institutions only. Not for
|
|
||||||
// government, commercial, or other organizational use.
|
|
||||||
//
|
|
||||||
// rtwtypes.h
|
|
||||||
//
|
|
||||||
// Code generation for function 'controller'
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef RTWTYPES_H
|
|
||||||
#define RTWTYPES_H
|
|
||||||
|
|
||||||
/*=======================================================================*
|
|
||||||
* Fixed width word size data types: *
|
|
||||||
* int64_T - signed 64 bit integers *
|
|
||||||
* uint64_T - unsigned 64 bit integers *
|
|
||||||
*=======================================================================*/
|
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
#ifndef INT64_T
|
|
||||||
#define INT64_T long
|
|
||||||
#define FMT64 "l"
|
|
||||||
#if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG)
|
|
||||||
#define INT_TYPE_64_IS_LONG
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
#ifndef UINT64_T
|
|
||||||
#define UINT64_T unsigned long
|
|
||||||
#define FMT64 "l"
|
|
||||||
#if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG)
|
|
||||||
#define INT_TYPE_64_IS_LONG
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Include files
|
|
||||||
#include "tmwtypes.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// End of code generation (rtwtypes.h)
|
|
||||||
@@ -1,888 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1984-2023 The MathWorks, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
# pragma once
|
|
||||||
#endif
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3))
|
|
||||||
# pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef tmwtypes_h
|
|
||||||
#define tmwtypes_h
|
|
||||||
|
|
||||||
#ifndef __TMWTYPES__
|
|
||||||
#define __TMWTYPES__
|
|
||||||
/*
|
|
||||||
* File : tmwtypes.h
|
|
||||||
* Abstract:
|
|
||||||
* Data types for use with MATLAB/SIMULINK and the Real-Time Workshop.
|
|
||||||
*
|
|
||||||
* When compiling stand-alone model code, data types can be overridden
|
|
||||||
* via compiler switches.
|
|
||||||
*
|
|
||||||
* Define NO_FLOATS to eliminate reference to real_T, etc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef MW_LIBTOOLING
|
|
||||||
#include "mwstdint.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
/* __STDC_VERSION__ version check below means "check for a C99 compiler".
|
|
||||||
|
|
||||||
Visual Studio (checked on versions 2015 and 2017) does
|
|
||||||
not define __STDC_VERSION__, however it has stdbool.h available,
|
|
||||||
thus a separate check for _MSC_VER below.
|
|
||||||
*/
|
|
||||||
#if defined(__APPLE_CC__) \
|
|
||||||
|| (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) \
|
|
||||||
|| (defined(_MSC_VER) && (_MSC_VER >= 1900))
|
|
||||||
#ifndef tmwtypes_do_not_include_stdbool
|
|
||||||
#include <stdbool.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOGICAL_IS_A_TYPE
|
|
||||||
#define SPARSE_GENERALIZATION
|
|
||||||
|
|
||||||
#ifdef NO_FLOATS
|
|
||||||
# define double double_not_allowed
|
|
||||||
# define float float_not_allowed
|
|
||||||
#endif /*NO_FLOATS*/
|
|
||||||
|
|
||||||
#ifndef NO_FLOATS
|
|
||||||
|
|
||||||
#ifndef __MWERKS__
|
|
||||||
# ifdef __STDC__
|
|
||||||
# include <float.h>
|
|
||||||
# else
|
|
||||||
# ifndef FLT_MANT_DIG
|
|
||||||
# define FLT_MANT_DIG 24
|
|
||||||
# endif
|
|
||||||
# ifndef DBL_MANT_DIG
|
|
||||||
# define DBL_MANT_DIG 53
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*NO_FLOATS*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following data types cannot be overridden when building MEX files.
|
|
||||||
*/
|
|
||||||
#ifdef MATLAB_MEX_FILE
|
|
||||||
# undef CHARACTER_T
|
|
||||||
# undef INTEGER_T
|
|
||||||
# undef BOOLEAN_T
|
|
||||||
# undef REAL_T
|
|
||||||
# undef TIME_T
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The uchar_T, ushort_T and ulong_T types are needed for compilers which do
|
|
||||||
* not allow defines to be specified, at the command line, with spaces in them.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef unsigned char uchar_T;
|
|
||||||
typedef unsigned short ushort_T;
|
|
||||||
typedef unsigned long ulong_T;
|
|
||||||
|
|
||||||
#if (defined(_MSC_VER) && _MSC_VER >= 1500) \
|
|
||||||
|| defined(__x86_64__) || defined(__LP64__) \
|
|
||||||
|| defined(__LCC64__)
|
|
||||||
|
|
||||||
typedef unsigned long long ulonglong_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*=======================================================================*
|
|
||||||
* Fixed width word size data types: *
|
|
||||||
* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
|
|
||||||
* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
|
|
||||||
* real32_T, real64_T - 32 and 64 bit floating point numbers *
|
|
||||||
*=======================================================================*/
|
|
||||||
|
|
||||||
/* When used with Real Time Workshop generated code, this
|
|
||||||
* header file can be used with a variety of compilers.
|
|
||||||
*
|
|
||||||
* The compiler could be for an 8 bit embedded processor that
|
|
||||||
* only had 8 bits per integer and 16 bits per long.
|
|
||||||
* In that example, a 32 bit integer size is not even available.
|
|
||||||
* This header file should be robust to that.
|
|
||||||
*
|
|
||||||
* For the case of an 8 bit processor, the preprocessor
|
|
||||||
* may be limited to 16 bit math like its target. That limitation
|
|
||||||
* would mean that 32 bit comparisons can't be done accurately.
|
|
||||||
* To increase robustness to this, comparisons are done against
|
|
||||||
* smaller values first. An inaccurate 32 bit comparison isn't
|
|
||||||
* attempted if the 16 bit comparison has already succeeded.
|
|
||||||
*
|
|
||||||
* Limitations on preprocessor math can also be stricter than
|
|
||||||
* for the target. There are known cases where a compiler
|
|
||||||
* targeting processors with 64 bit longs can't do accurate
|
|
||||||
* preprocessor comparisons on more than 32 bits.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Determine the number of bits for int, long, short, and char.
|
|
||||||
* If one fails to be determined, set the number of bits to -1
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TMW_BITS_PER_INT
|
|
||||||
# if INT_MAX == 0x7FL
|
|
||||||
# define TMW_BITS_PER_INT 8
|
|
||||||
# elif INT_MAX == 0x7FFFL
|
|
||||||
# define TMW_BITS_PER_INT 16
|
|
||||||
# elif INT_MAX == 0x7FFFFFFFL
|
|
||||||
# define TMW_BITS_PER_INT 32
|
|
||||||
# else
|
|
||||||
# define TMW_BITS_PER_INT -1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TMW_BITS_PER_LONG
|
|
||||||
# if LONG_MAX == 0x7FL
|
|
||||||
# define TMW_BITS_PER_LONG 8
|
|
||||||
# elif LONG_MAX == 0x7FFFL
|
|
||||||
# define TMW_BITS_PER_LONG 16
|
|
||||||
# elif LONG_MAX == 0x7FFFFFFFL
|
|
||||||
# define TMW_BITS_PER_LONG 32
|
|
||||||
# else
|
|
||||||
# define TMW_BITS_PER_LONG -1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TMW_BITS_PER_SHRT
|
|
||||||
# if SHRT_MAX == 0x7FL
|
|
||||||
# define TMW_BITS_PER_SHRT 8
|
|
||||||
# elif SHRT_MAX == 0x7FFFL
|
|
||||||
# define TMW_BITS_PER_SHRT 16
|
|
||||||
# elif SHRT_MAX == 0x7FFFFFFFL
|
|
||||||
# define TMW_BITS_PER_SHRT 32
|
|
||||||
# else
|
|
||||||
# define TMW_BITS_PER_SHRT -1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TMW_BITS_PER_SCHAR
|
|
||||||
# if SCHAR_MAX == 0x7FL
|
|
||||||
# define TMW_BITS_PER_SCHAR 8
|
|
||||||
# elif SCHAR_MAX == 0x7FFFL
|
|
||||||
# define TMW_BITS_PER_SCHAR 16
|
|
||||||
# elif SCHAR_MAX == 0x7FFFFFFFL
|
|
||||||
# define TMW_BITS_PER_SCHAR 32
|
|
||||||
# else
|
|
||||||
# define TMW_BITS_PER_SCHAR -1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TMW_CHAR_SIGNED
|
|
||||||
# if SCHAR_MAX == CHAR_MAX
|
|
||||||
# define TMW_CHAR_SIGNED 1
|
|
||||||
# else
|
|
||||||
# define TMW_CHAR_SIGNED 0
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* It is common for one or more of the integer types
|
|
||||||
* to be the same size. For example, on many embedded
|
|
||||||
* processors, both shorts and ints are 16 bits. On
|
|
||||||
* processors used for workstations, it is quite common
|
|
||||||
* for both int and long to be 32 bits.
|
|
||||||
* When there is more than one choice for typdef'ing
|
|
||||||
* a portable type like int16_T or uint32_T, in
|
|
||||||
* concept, it should not matter which choice is made.
|
|
||||||
* However, some style guides and some code checking
|
|
||||||
* tools do identify and complain about seemingly
|
|
||||||
* irrelevant differences. For example, a code
|
|
||||||
* checking tool may complain about an implicit
|
|
||||||
* conversion from int to short even though both
|
|
||||||
* are 16 bits. To reduce these types of
|
|
||||||
* complaints, it is best to make int the
|
|
||||||
* preferred choice when more than one is available.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INT8_T
|
|
||||||
# if defined(MW_LIBTOOLING)
|
|
||||||
# define INT8_T int8_t
|
|
||||||
# elif TMW_BITS_PER_INT == 8
|
|
||||||
# define INT8_T int
|
|
||||||
# elif TMW_BITS_PER_LONG == 8
|
|
||||||
# define INT8_T long
|
|
||||||
# elif TMW_BITS_PER_SCHAR == 8
|
|
||||||
# define INT8_T signed char
|
|
||||||
# elif TMW_BITS_PER_SHRT == 8
|
|
||||||
# define INT8_T short
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef INT8_T
|
|
||||||
typedef INT8_T int8_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef UINT8_T
|
|
||||||
# if defined(MW_LIBTOOLING)
|
|
||||||
# define UINT8_T uint8_t
|
|
||||||
# elif TMW_BITS_PER_INT == 8
|
|
||||||
# define UINT8_T unsigned int
|
|
||||||
# elif TMW_BITS_PER_LONG == 8
|
|
||||||
# define UINT8_T unsigned long
|
|
||||||
# elif TMW_BITS_PER_SCHAR == 8
|
|
||||||
# define UINT8_T unsigned char
|
|
||||||
# elif TMW_BITS_PER_SHRT == 8
|
|
||||||
# define UINT8_T unsigned short
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef UINT8_T
|
|
||||||
typedef UINT8_T uint8_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef INT16_T
|
|
||||||
# if defined(MW_LIBTOOLING)
|
|
||||||
# define INT16_T int16_t
|
|
||||||
# elif TMW_BITS_PER_INT == 16
|
|
||||||
# define INT16_T int
|
|
||||||
# elif TMW_BITS_PER_LONG == 16
|
|
||||||
# define INT16_T long
|
|
||||||
# elif TMW_BITS_PER_SCHAR == 16
|
|
||||||
# define INT16_T signed char
|
|
||||||
# elif TMW_BITS_PER_SHRT == 16
|
|
||||||
# define INT16_T short
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef INT16_T
|
|
||||||
typedef INT16_T int16_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef UINT16_T
|
|
||||||
# if defined(MW_LIBTOOLING)
|
|
||||||
# define UINT16_T uint16_t
|
|
||||||
# elif TMW_BITS_PER_INT == 16
|
|
||||||
# define UINT16_T unsigned int
|
|
||||||
# elif TMW_BITS_PER_LONG == 16
|
|
||||||
# define UINT16_T unsigned long
|
|
||||||
# elif TMW_BITS_PER_SCHAR == 16
|
|
||||||
# define UINT16_T unsigned char
|
|
||||||
# elif TMW_BITS_PER_SHRT == 16
|
|
||||||
# define UINT16_T unsigned short
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef UINT16_T
|
|
||||||
typedef UINT16_T uint16_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef INT32_T
|
|
||||||
# if defined(MW_LIBTOOLING)
|
|
||||||
# define INT32_T int32_t
|
|
||||||
# elif TMW_BITS_PER_INT == 32
|
|
||||||
# define INT32_T int
|
|
||||||
# elif TMW_BITS_PER_LONG == 32
|
|
||||||
# define INT32_T long
|
|
||||||
# elif TMW_BITS_PER_SCHAR == 32
|
|
||||||
# define INT32_T signed char
|
|
||||||
# elif TMW_BITS_PER_SHRT == 32
|
|
||||||
# define INT32_T short
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef INT32_T
|
|
||||||
typedef INT32_T int32_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef UINT32_T
|
|
||||||
# if defined(MW_LIBTOOLING)
|
|
||||||
# define UINT32_T uint32_t
|
|
||||||
# elif TMW_BITS_PER_INT == 32
|
|
||||||
# define UINT32_T unsigned int
|
|
||||||
# elif TMW_BITS_PER_LONG == 32
|
|
||||||
# define UINT32_T unsigned long
|
|
||||||
# elif TMW_BITS_PER_SCHAR == 32
|
|
||||||
# define UINT32_T unsigned char
|
|
||||||
# elif TMW_BITS_PER_SHRT == 32
|
|
||||||
# define UINT32_T unsigned short
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef UINT32_T
|
|
||||||
typedef UINT32_T uint32_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The following is used to emulate smaller integer types when only
|
|
||||||
* larger types are available. For example, compilers for TI C3x/C4x DSPs
|
|
||||||
* define char and short to be 32 bits, so 8 and 16 bits are not directly
|
|
||||||
* available. This target is commonly used with RTW rapid prototyping.
|
|
||||||
* Other DSPs define char to be 16 bits, so 8 bits is not directly
|
|
||||||
* available.
|
|
||||||
*/
|
|
||||||
#ifndef INT8_T
|
|
||||||
# ifdef INT16_T
|
|
||||||
# define INT8_T INT16_T
|
|
||||||
typedef INT8_T int8_T;
|
|
||||||
# else
|
|
||||||
# ifdef INT32_T
|
|
||||||
# define INT8_T INT32_T
|
|
||||||
typedef INT8_T int8_T;
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef UINT8_T
|
|
||||||
# ifdef UINT16_T
|
|
||||||
# define UINT8_T UINT16_T
|
|
||||||
typedef UINT8_T uint8_T;
|
|
||||||
# else
|
|
||||||
# ifdef UINT32_T
|
|
||||||
# define UINT8_T UINT32_T
|
|
||||||
typedef UINT8_T uint8_T;
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef INT16_T
|
|
||||||
# ifdef INT32_T
|
|
||||||
# define INT16_T INT32_T
|
|
||||||
typedef INT16_T int16_T;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef UINT16_T
|
|
||||||
# ifdef UINT32_T
|
|
||||||
# define UINT16_T UINT32_T
|
|
||||||
typedef UINT16_T uint16_T;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_FLOATS
|
|
||||||
|
|
||||||
#ifndef REAL32_T
|
|
||||||
# ifndef __MWERKS__
|
|
||||||
# if FLT_MANT_DIG >= 23
|
|
||||||
# define REAL32_T float
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# define REAL32_T float
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef REAL32_T
|
|
||||||
typedef REAL32_T real32_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef REAL64_T
|
|
||||||
# ifndef __MWERKS__
|
|
||||||
# if DBL_MANT_DIG >= 52
|
|
||||||
# define REAL64_T double
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# define REAL64_T double
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef REAL64_T
|
|
||||||
typedef REAL64_T real64_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* NO_FLOATS*/
|
|
||||||
|
|
||||||
/*=======================================================================*
|
|
||||||
* Fixed width word size data types: *
|
|
||||||
* int64_T - signed 64 bit integers *
|
|
||||||
* uint64_T - unsigned 64 bit integers *
|
|
||||||
*=======================================================================*/
|
|
||||||
|
|
||||||
# if defined(MW_LIBTOOLING)
|
|
||||||
# ifdef INT64_T
|
|
||||||
# undef INT64_T
|
|
||||||
# endif
|
|
||||||
# define INT64_T int64_t
|
|
||||||
# ifdef UINT64_T
|
|
||||||
# undef UINT64_T
|
|
||||||
# endif
|
|
||||||
# define UINT64_T uint64_t
|
|
||||||
# endif
|
|
||||||
#if !defined(INT64_T) || !defined(UINT64_T) || !defined(FMT64)
|
|
||||||
# if defined(__APPLE__) || defined(__clang__)
|
|
||||||
# ifndef INT64_T
|
|
||||||
# define INT64_T long long
|
|
||||||
# endif
|
|
||||||
# ifndef UINT64_T
|
|
||||||
# define UINT64_T unsigned long long
|
|
||||||
# endif
|
|
||||||
# ifndef FMT64
|
|
||||||
# define FMT64 "ll"
|
|
||||||
# endif
|
|
||||||
# if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG)
|
|
||||||
# define INT_TYPE_64_IS_LONG
|
|
||||||
# endif
|
|
||||||
# elif (defined(__x86_64__) || defined(__LP64__))&& !defined(__MINGW64__)
|
|
||||||
# ifndef INT64_T
|
|
||||||
# define INT64_T long
|
|
||||||
# endif
|
|
||||||
# ifndef UINT64_T
|
|
||||||
# define UINT64_T unsigned long
|
|
||||||
# endif
|
|
||||||
# ifndef FMT64
|
|
||||||
# define FMT64 "l"
|
|
||||||
# endif
|
|
||||||
# if !defined(INT_TYPE_64_IS_LONG)
|
|
||||||
# define INT_TYPE_64_IS_LONG
|
|
||||||
# endif
|
|
||||||
# elif defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \
|
|
||||||
|| (defined(__WATCOMC__) && __WATCOMC__ >= 1100)
|
|
||||||
# ifndef INT64_T
|
|
||||||
# define INT64_T __int64
|
|
||||||
# endif
|
|
||||||
# ifndef UINT64_T
|
|
||||||
# define UINT64_T unsigned __int64
|
|
||||||
# endif
|
|
||||||
# ifndef FMT64
|
|
||||||
# define FMT64 "I64"
|
|
||||||
# endif
|
|
||||||
# elif defined(__GNUC__) || defined(TMW_ENABLE_INT64) \
|
|
||||||
|| defined(__LCC64__)
|
|
||||||
# ifndef INT64_T
|
|
||||||
# define INT64_T long long
|
|
||||||
# endif
|
|
||||||
# ifndef UINT64_T
|
|
||||||
# define UINT64_T unsigned long long
|
|
||||||
# endif
|
|
||||||
# ifndef FMT64
|
|
||||||
# define FMT64 "ll"
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(INT64_T)
|
|
||||||
# if defined(__GNUC__) && \
|
|
||||||
((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9)))
|
|
||||||
__extension__
|
|
||||||
# endif
|
|
||||||
typedef INT64_T int64_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN64) || (defined(__APPLE__) && defined(__LP64__)) \
|
|
||||||
|| defined(__x86_64__) \
|
|
||||||
|| defined(__LP64__)
|
|
||||||
# define INT_TYPE_64_IS_SUPPORTED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(UINT64_T)
|
|
||||||
# if defined(__GNUC__) && \
|
|
||||||
((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9)))
|
|
||||||
__extension__
|
|
||||||
# endif
|
|
||||||
typedef UINT64_T uint64_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*===========================================================================*
|
|
||||||
* Format string modifiers for using size_t variables in printf statements. *
|
|
||||||
*===========================================================================*/
|
|
||||||
|
|
||||||
#ifndef FMT_SIZE_T
|
|
||||||
# if (defined( __GNUC__ ) || defined(_STDC_C99))&& !defined(__MINGW64__)
|
|
||||||
# define FMT_SIZE_T "z"
|
|
||||||
# elif defined (__WATCOMC__)
|
|
||||||
# define FMT_SIZE_T "l"
|
|
||||||
# elif defined (_WIN32 )
|
|
||||||
# define FMT_SIZE_T "I"
|
|
||||||
# else
|
|
||||||
# define FMT_SIZE_T "l"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FMT_PTRDIFF_T
|
|
||||||
# if defined(__APPLE__)
|
|
||||||
# define FMT_PTRDIFF_T "l"
|
|
||||||
# elif defined( __GNUC__ ) || defined(_STDC_C99)
|
|
||||||
# define FMT_PTRDIFF_T "t"
|
|
||||||
# elif defined (__WATCOMC__)
|
|
||||||
# define FMT_PTRDIFF_T "l"
|
|
||||||
# elif defined (_WIN32 )
|
|
||||||
# define FMT_PTRDIFF_T "I"
|
|
||||||
# else
|
|
||||||
# define FMT_PTRDIFF_T "l"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*===========================================================================*
|
|
||||||
* General or logical data types where the word size is not guaranteed. *
|
|
||||||
* real_T - possible settings include real32_T or real64_T *
|
|
||||||
* time_T - possible settings include real32_T or real64_T *
|
|
||||||
* boolean_T *
|
|
||||||
* char_T *
|
|
||||||
* int_T *
|
|
||||||
* uint_T *
|
|
||||||
* byte_T *
|
|
||||||
*===========================================================================*/
|
|
||||||
|
|
||||||
#ifndef NO_FLOATS
|
|
||||||
|
|
||||||
#ifndef REAL_T
|
|
||||||
# ifdef REAL64_T
|
|
||||||
# define REAL_T real64_T
|
|
||||||
# else
|
|
||||||
# ifdef REAL32_T
|
|
||||||
# define REAL_T real32_T
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef REAL_T
|
|
||||||
typedef REAL_T real_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TIME_T
|
|
||||||
# ifdef REAL_T
|
|
||||||
# define TIME_T real_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifdef TIME_T
|
|
||||||
typedef TIME_T time_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* NO_FLOATS */
|
|
||||||
|
|
||||||
#ifndef BOOLEAN_T
|
|
||||||
# if defined(UINT8_T)
|
|
||||||
# define BOOLEAN_T UINT8_T
|
|
||||||
# else
|
|
||||||
# define BOOLEAN_T unsigned int
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
typedef BOOLEAN_T boolean_T;
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef CHARACTER_T
|
|
||||||
# define CHARACTER_T char
|
|
||||||
#endif
|
|
||||||
typedef CHARACTER_T char_T;
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef INTEGER_T
|
|
||||||
# define INTEGER_T int
|
|
||||||
#endif
|
|
||||||
typedef INTEGER_T int_T;
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef UINTEGER_T
|
|
||||||
# define UINTEGER_T unsigned
|
|
||||||
#endif
|
|
||||||
typedef UINTEGER_T uint_T;
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BYTE_T
|
|
||||||
# define BYTE_T unsigned char
|
|
||||||
#endif
|
|
||||||
typedef BYTE_T byte_T;
|
|
||||||
|
|
||||||
|
|
||||||
/*===========================================================================*
|
|
||||||
* Define Complex Structures *
|
|
||||||
*===========================================================================*/
|
|
||||||
#ifndef NO_FLOATS
|
|
||||||
|
|
||||||
#ifndef CREAL32_T
|
|
||||||
# ifdef REAL32_T
|
|
||||||
typedef struct {
|
|
||||||
real32_T re, im;
|
|
||||||
} creal32_T;
|
|
||||||
# define CREAL32_T creal32_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CREAL64_T
|
|
||||||
# ifdef REAL64_T
|
|
||||||
typedef struct {
|
|
||||||
real64_T re, im;
|
|
||||||
} creal64_T;
|
|
||||||
# define CREAL64_T creal64_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CREAL_T
|
|
||||||
# ifdef REAL_T
|
|
||||||
typedef struct {
|
|
||||||
real_T re, im;
|
|
||||||
} creal_T;
|
|
||||||
# define CREAL_T creal_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* NO_FLOATS */
|
|
||||||
|
|
||||||
#ifndef CINT8_T
|
|
||||||
# ifdef INT8_T
|
|
||||||
typedef struct {
|
|
||||||
int8_T re, im;
|
|
||||||
} cint8_T;
|
|
||||||
# define CINT8_T cint8_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CUINT8_T
|
|
||||||
# ifdef UINT8_T
|
|
||||||
typedef struct {
|
|
||||||
uint8_T re, im;
|
|
||||||
} cuint8_T;
|
|
||||||
# define CUINT8_T cuint8_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CINT16_T
|
|
||||||
# ifdef INT16_T
|
|
||||||
typedef struct {
|
|
||||||
int16_T re, im;
|
|
||||||
} cint16_T;
|
|
||||||
# define CINT16_T cint16_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CUINT16_T
|
|
||||||
# ifdef UINT16_T
|
|
||||||
typedef struct {
|
|
||||||
uint16_T re, im;
|
|
||||||
} cuint16_T;
|
|
||||||
# define CUINT16_T cuint16_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CINT32_T
|
|
||||||
# ifdef INT32_T
|
|
||||||
typedef struct {
|
|
||||||
int32_T re, im;
|
|
||||||
} cint32_T;
|
|
||||||
# define CINT32_T cint32_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CUINT32_T
|
|
||||||
# ifdef UINT32_T
|
|
||||||
typedef struct {
|
|
||||||
uint32_T re, im;
|
|
||||||
} cuint32_T;
|
|
||||||
# define CUINT32_T cuint32_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CINT64_T
|
|
||||||
# ifdef INT64_T
|
|
||||||
typedef struct {
|
|
||||||
int64_T re, im;
|
|
||||||
} cint64_T;
|
|
||||||
# define CINT64_T cint64_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CUINT64_T
|
|
||||||
# ifdef UINT64_T
|
|
||||||
typedef struct {
|
|
||||||
uint64_T re, im;
|
|
||||||
} cuint64_T;
|
|
||||||
# define CUINT64_T cuint64_T
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*=======================================================================*
|
|
||||||
* Min and Max: *
|
|
||||||
* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
|
|
||||||
* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
|
|
||||||
*=======================================================================*/
|
|
||||||
|
|
||||||
#define MAX_int8_T ((int8_T)(127)) /* 127 */
|
|
||||||
#define MIN_int8_T ((int8_T)(-128)) /* -128 */
|
|
||||||
#define MAX_uint8_T ((uint8_T)(255)) /* 255 */
|
|
||||||
#define MIN_uint8_T ((uint8_T)(0))
|
|
||||||
|
|
||||||
#define MAX_int16_T ((int16_T)(32767)) /* 32767 */
|
|
||||||
#define MIN_int16_T ((int16_T)(-32768)) /* -32768 */
|
|
||||||
#define MAX_uint16_T ((uint16_T)(65535)) /* 65535 */
|
|
||||||
#define MIN_uint16_T ((uint16_T)(0))
|
|
||||||
|
|
||||||
#define MAX_int32_T ((int32_T)(2147483647)) /* 2147483647 */
|
|
||||||
#define MIN_int32_T ((int32_T)(-2147483647-1)) /* -2147483648 */
|
|
||||||
#define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU)) /* 4294967295 */
|
|
||||||
#define MIN_uint32_T ((uint32_T)(0))
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \
|
|
||||||
|| (defined(__WATCOMC__) && __WATCOMC__ >= 1100) \
|
|
||||||
|| defined(__LCC64__)
|
|
||||||
# ifdef INT64_T
|
|
||||||
# define MAX_int64_T ((int64_T)(9223372036854775807LL))
|
|
||||||
# define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL))
|
|
||||||
# endif
|
|
||||||
# ifdef UINT64_T
|
|
||||||
# define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL))
|
|
||||||
# define MIN_uint64_T ((uint64_T)(0))
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# ifdef INT64_T
|
|
||||||
# ifdef INT_TYPE_64_IS_LONG
|
|
||||||
# define MAX_int64_T ((int64_T)(9223372036854775807L))
|
|
||||||
# define MIN_int64_T ((int64_T)(-9223372036854775807L-1L))
|
|
||||||
# else
|
|
||||||
# define MAX_int64_T ((int64_T)(9223372036854775807LL))
|
|
||||||
# define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL))
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# ifdef UINT64_T
|
|
||||||
# ifdef INT_TYPE_64_IS_LONG
|
|
||||||
# define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFUL))
|
|
||||||
# define MIN_uint64_T ((uint64_T)(0))
|
|
||||||
# else
|
|
||||||
# define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL))
|
|
||||||
# define MIN_uint64_T ((uint64_T)(0))
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(_MSC_VER) && !defined(__clang__))
|
|
||||||
|
|
||||||
/* Conversion from unsigned __int64 to double is not implemented in Visual Studio
|
|
||||||
* and results in a compile error, thus the value must first be cast to
|
|
||||||
* signed __int64, and then to double.
|
|
||||||
*
|
|
||||||
* If the 64 bit int value is greater than 2^63-1, which is the signed int64 max,
|
|
||||||
* the macro below provides a workaround for casting a uint64 value to a double
|
|
||||||
* in windows.
|
|
||||||
*/
|
|
||||||
# define uint64_to_double(u) ( ((u) > _I64_MAX) ? \
|
|
||||||
(double)(__int64)((u) - _I64_MAX - 1) + (double)_I64_MAX + 1: \
|
|
||||||
(double)(__int64)(u) )
|
|
||||||
|
|
||||||
/* The following inline function should only be used in the macro double_to_uint64,
|
|
||||||
* as it only handles the specfic range of double between 2^63 and 2^64-1 */
|
|
||||||
__forceinline
|
|
||||||
uint64_T double_to_uint64_helper(double d) {
|
|
||||||
union double_to_uint64_union_type {
|
|
||||||
double dd;
|
|
||||||
uint64_T i64;
|
|
||||||
} di;
|
|
||||||
di.dd = d;
|
|
||||||
return (((di.i64 & 0x000fffffffffffff) | 0x0010000000000000) << 11);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The largest double value that can be cast to uint64 in windows is the
|
|
||||||
* signed int64 max, which is 2^63-1. The macro below provides
|
|
||||||
* a workaround for casting large double values to uint64 in windows.
|
|
||||||
*/
|
|
||||||
/* The magic number 18446744073709551616.0 is 2^64 */
|
|
||||||
/* The magic number 9223372036854775808.0 is 2^63 */
|
|
||||||
# define double_to_uint64(d) ( ((d) >= 18446744073709551616.0) ? \
|
|
||||||
0xffffffffffffffffULL : \
|
|
||||||
((d) >= 0.0) ? \
|
|
||||||
((d) >= 9223372036854775808.0) ? \
|
|
||||||
double_to_uint64_helper(d) : \
|
|
||||||
(unsigned __int64)(d) : \
|
|
||||||
0ULL )
|
|
||||||
#else
|
|
||||||
# define uint64_to_double(u) ((double)(u))
|
|
||||||
# if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__TICCSC__)
|
|
||||||
/* double_to_uint64 defined only for MSVC and UNIX */
|
|
||||||
# else
|
|
||||||
# define double_to_uint64(d) ( ((d) >= 18446744073709551616.0) ? \
|
|
||||||
(unsigned long long) 0xffffffffffffffffULL : \
|
|
||||||
((d) >= 0) ? (unsigned long long)(d) : (unsigned long long) 0 )
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__cplusplus) && !defined(__bool_true_false_are_defined)
|
|
||||||
|
|
||||||
#ifndef _bool_T
|
|
||||||
#define _bool_T
|
|
||||||
|
|
||||||
typedef boolean_T bool;
|
|
||||||
|
|
||||||
#ifndef false
|
|
||||||
#define false (0)
|
|
||||||
#endif
|
|
||||||
#ifndef true
|
|
||||||
#define true (1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _bool_T */
|
|
||||||
|
|
||||||
#endif /* !__cplusplus */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This software assumes that the code is being compiled on a target using a
|
|
||||||
* 2's complement representation for signed integer values.
|
|
||||||
*/
|
|
||||||
#if ((SCHAR_MIN + 1) != -SCHAR_MAX)
|
|
||||||
#error "This code must be compiled using a 2's complement representation for signed integer values"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Maximum length of a MATLAB identifier (function/variable/model)
|
|
||||||
* including the null-termination character.
|
|
||||||
*/
|
|
||||||
#define TMW_NAME_LENGTH_MAX 2049
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Maximum values for indices and dimensions
|
|
||||||
*/
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#ifdef MX_COMPAT_32
|
|
||||||
typedef int mwSize;
|
|
||||||
typedef int mwIndex;
|
|
||||||
typedef int mwSignedIndex;
|
|
||||||
#else
|
|
||||||
typedef size_t mwSize; /* unsigned pointer-width integer */
|
|
||||||
typedef size_t mwIndex; /* unsigned pointer-width integer */
|
|
||||||
typedef ptrdiff_t mwSignedIndex; /* a signed pointer-width integer */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* for the individual dim */
|
|
||||||
/* If updating SLSize or SLIndex, update defintions in sl_types_def.h
|
|
||||||
as well. */
|
|
||||||
#ifndef SLSIZE_SLINDEX
|
|
||||||
#define SLSIZE_SLINDEX
|
|
||||||
#ifdef INT_TYPE_64_IS_SUPPORTED
|
|
||||||
typedef int64_T SLIndex;
|
|
||||||
typedef int64_T SLSize;
|
|
||||||
#else
|
|
||||||
typedef int SLIndex;
|
|
||||||
typedef int SLSize;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* for the total size */
|
|
||||||
#define SLIndexType size_t
|
|
||||||
#define INVALID_SIZET_VALUE (std::numeric_limits<SLIndexType>::max())
|
|
||||||
#define MAX_VALID_SIZET_VALUE (std::numeric_limits<SLIndexType>::max() -1)
|
|
||||||
|
|
||||||
|
|
||||||
#if (defined(_LP64) || defined(_WIN64)) && !defined(MX_COMPAT_32)
|
|
||||||
/* Currently 2^48 based on hardware limitations */
|
|
||||||
# define MWSIZE_MAX 281474976710655UL
|
|
||||||
# define MWINDEX_MAX 281474976710655UL
|
|
||||||
# define MWSINDEX_MAX 281474976710655L
|
|
||||||
# define MWSINDEX_MIN -281474976710655L
|
|
||||||
#else
|
|
||||||
# define MWSIZE_MAX 2147483647UL
|
|
||||||
# define MWINDEX_MAX 2147483647UL
|
|
||||||
# define MWSINDEX_MAX 2147483647L
|
|
||||||
# define MWSINDEX_MIN -2147483647L
|
|
||||||
#endif
|
|
||||||
#define MWSIZE_MIN 0UL
|
|
||||||
#define MWINDEX_MIN 0UL
|
|
||||||
|
|
||||||
/** UTF-16 character type */
|
|
||||||
|
|
||||||
#if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT)
|
|
||||||
typedef char16_t CHAR16_T;
|
|
||||||
#define U16_STRING_LITERAL_PREFIX u
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
typedef wchar_t CHAR16_T;
|
|
||||||
#define U16_STRING_LITERAL_PREFIX L
|
|
||||||
#else
|
|
||||||
typedef UINT16_T CHAR16_T;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __TMWTYPES__ */
|
|
||||||
|
|
||||||
#endif /* tmwtypes_h */
|
|
||||||
BIN
aerpaw/build/controller_app
Executable file
BIN
aerpaw/build/controller_app
Executable file
Binary file not shown.
22
aerpaw/compile.sh
Executable file
22
aerpaw/compile.sh
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Build controller_app from codegen + impl sources
|
||||||
|
|
||||||
|
AERPAW_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
CODEGEN="$AERPAW_DIR/codegen"
|
||||||
|
IMPL="$AERPAW_DIR/impl"
|
||||||
|
BUILD="$AERPAW_DIR/build"
|
||||||
|
|
||||||
|
mkdir -p "$BUILD"
|
||||||
|
|
||||||
|
g++ -I/home/kdee/matlab/R2025a/extern/include \
|
||||||
|
-I"$CODEGEN" \
|
||||||
|
-I"$IMPL" \
|
||||||
|
"$IMPL/controller_main.cpp" \
|
||||||
|
"$CODEGEN/controller.cpp" \
|
||||||
|
"$IMPL/controller_impl.cpp" \
|
||||||
|
"$CODEGEN/controller_initialize.cpp" \
|
||||||
|
"$CODEGEN/controller_terminate.cpp" \
|
||||||
|
-o "$BUILD/controller_app" \
|
||||||
|
-lpthread
|
||||||
|
|
||||||
|
echo "Built: $BUILD/controller_app"
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
</Artifacts>
|
</Artifacts>
|
||||||
<BuildFolder type="coderapp.internal.util.mfz.FileSpec"/>
|
<BuildFolder type="coderapp.internal.util.mfz.FileSpec"/>
|
||||||
<Success>true</Success>
|
<Success>true</Success>
|
||||||
<Timestamp>2026-01-29T16:33:06</Timestamp>
|
<Timestamp>2026-01-29T19:44:44</Timestamp>
|
||||||
</MainBuildResult>
|
</MainBuildResult>
|
||||||
</coderapp.internal.mlc.mfz.MatlabCoderProjectState>
|
</coderapp.internal.mlc.mfz.MatlabCoderProjectState>
|
||||||
</MF0>
|
</MF0>
|
||||||
|
|||||||
@@ -14,15 +14,15 @@ targets = zeros(MAX_CLIENTS, 3);
|
|||||||
% Load targets from file
|
% Load targets from file
|
||||||
if coder.target('MATLAB')
|
if coder.target('MATLAB')
|
||||||
disp('Loading targets from file (simulation)...');
|
disp('Loading targets from file (simulation)...');
|
||||||
targetsLoaded = readmatrix('targets.txt');
|
targetsLoaded = readmatrix('config/targets.txt');
|
||||||
numTargets = min(size(targetsLoaded, 1), numClients);
|
numTargets = min(size(targetsLoaded, 1), numClients);
|
||||||
targets(1:numTargets, :) = targetsLoaded(1:numTargets, :);
|
targets(1:numTargets, :) = targetsLoaded(1:numTargets, :);
|
||||||
disp(['Loaded ', num2str(numTargets), ' targets']);
|
disp(['Loaded ', num2str(numTargets), ' targets']);
|
||||||
else
|
else
|
||||||
coder.cinclude('controller_impl.h');
|
coder.cinclude('controller_impl.h');
|
||||||
% Define filename as null-terminated character array for C compatibility
|
% Define filename as null-terminated character array for C compatibility
|
||||||
filename = ['targets.txt', char(0)];
|
filename = ['config/targets.txt', char(0)];
|
||||||
% loadTargets fills targets array (row-major: x1,y1,z1,x2,y2,z2,...)
|
% loadTargets fills targets array (column-major for MATLAB compatibility)
|
||||||
coder.ceval('loadTargets', coder.ref(filename), ...
|
coder.ceval('loadTargets', coder.ref(filename), ...
|
||||||
coder.ref(targets), int32(MAX_CLIENTS));
|
coder.ref(targets), int32(MAX_CLIENTS));
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info location="controller.cpp" type="File"/>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info location="compile.sh" type="File"/>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info location="rtwtypes.h" type="File"/>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info>
|
|
||||||
<Category UUID="FileClassCategory">
|
|
||||||
<Label UUID="design"/>
|
|
||||||
</Category>
|
|
||||||
</Info>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info location="controller.h" type="File"/>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info Ref="aerpaw/basic_demo" Type="Relative"/>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info location="35fde29d-17b6-4432-a3a6-2d363f1c0267" type="Reference"/>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info location="basic_demo" type="File"/>
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Info location="handcode" type="File"/>
|
<Info location="impl" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="build" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="client" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="config" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="controller_app" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="1" type="DIR_SIGNIFIER"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="1" type="DIR_SIGNIFIER"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="targets.txt" type="File"/>
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info>
|
|
||||||
<Category UUID="FileClassCategory">
|
|
||||||
<Label UUID="design"/>
|
|
||||||
</Category>
|
|
||||||
</Info>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info location="comms.cpp" type="File"/>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info>
|
|
||||||
<Category UUID="FileClassCategory">
|
|
||||||
<Label UUID="design"/>
|
|
||||||
</Category>
|
|
||||||
</Info>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info>
|
|
||||||
<Category UUID="FileClassCategory">
|
|
||||||
<Label UUID="design"/>
|
|
||||||
</Category>
|
|
||||||
</Info>
|
|
||||||
Reference in New Issue
Block a user