Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Common/Controllers/NintendoSwitch2_WiredController_State.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Nintendo Switch 2 - Wired Controller State
*
* From: https://github.com/PokemonAutomation/
*
*/

#include <string.h>
#include "NintendoSwitch2_WiredController_State.h"


const pa_NintendoSwitch2_WiredController_State pa_NintendoSwitch2_WiredController_State_NEUTRAL_STATE = {
.buttons0 = 0,
.buttons1 = 0,
.dpad_byte = 8,
.left_joystick_x = 128,
.left_joystick_y = 128,
.right_joystick_x = 128,
.right_joystick_y = 128,
};

bool pa_NintendoSwitch2_WiredController_State_equals(
const pa_NintendoSwitch2_WiredController_State* state0,
const pa_NintendoSwitch2_WiredController_State* state1
){
return memcmp(state0, state1, sizeof(pa_NintendoSwitch2_WiredController_State)) == 0;
}
41 changes: 41 additions & 0 deletions Common/Controllers/NintendoSwitch2_WiredController_State.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Nintendo Switch 2 - Wired Controller State
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_NintendoSwitch2_WiredController_State_H
#define PokemonAutomation_NintendoSwitch2_WiredController_State_H

#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif



typedef struct{
uint8_t buttons0;
uint8_t buttons1;
uint8_t dpad_byte;
uint8_t left_joystick_x;
uint8_t left_joystick_y;
uint8_t right_joystick_x;
uint8_t right_joystick_y;
} pa_NintendoSwitch2_WiredController_State;

extern const pa_NintendoSwitch2_WiredController_State pa_NintendoSwitch2_WiredController_State_NEUTRAL_STATE;

bool pa_NintendoSwitch2_WiredController_State_equals(
const pa_NintendoSwitch2_WiredController_State* state0,
const pa_NintendoSwitch2_WiredController_State* state1
);



#ifdef __cplusplus
}
#endif
#endif
30 changes: 30 additions & 0 deletions Common/Controllers/NintendoSwitch_WirelessController_State.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Nintendo Switch - Wireless Controller State
*
* From: https://github.com/PokemonAutomation/
*
*/


#include <string.h>
#include "NintendoSwitch_WirelessController_State.h"


const pa_NintendoSwitch_WirelessController_State0x30 pa_NintendoSwitch_WirelessController_State0x30_NEUTRAL_STATE = {
.buttons = {
.button3 = 0,
.button4 = 0,
.button5 = 0,
.left_joystick = {0x00, 0x08, 0x80},
.right_joystick = {0x00, 0x08, 0x80},
.vibrator = 0x80,
},
.gyro = {},
};

bool pa_NintendoSwitch_WirelessController_State0x30_equals(
const pa_NintendoSwitch_WirelessController_State0x30* state0,
const pa_NintendoSwitch_WirelessController_State0x30* state1
){
return memcmp(state0, state1, sizeof(pa_NintendoSwitch_WirelessController_State0x30)) == 0;
}

64 changes: 64 additions & 0 deletions Common/Controllers/NintendoSwitch_WirelessController_State.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* Nintendo Switch - Wireless Controller State
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_NintendoSwitch_WirelessController_State_H
#define PokemonAutomation_NintendoSwitch_WirelessController_State_H

#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif




typedef struct{
uint8_t button3;
uint8_t button4;
uint8_t button5;
uint8_t left_joystick[3];
uint8_t right_joystick[3];
uint8_t vibrator;
} pa_NintendoSwitch_WirelessController_State0x30_Buttons;

typedef struct{
int16_t accel_x;
int16_t accel_y;
int16_t accel_z;
int16_t rotation_x;
int16_t rotation_y;
int16_t rotation_z;
} pa_NintendoSwitch_WirelessController_State0x30_Gyro;

typedef struct{
pa_NintendoSwitch_WirelessController_State0x30_Gyro time0;
pa_NintendoSwitch_WirelessController_State0x30_Gyro time1;
pa_NintendoSwitch_WirelessController_State0x30_Gyro time2;
} pa_NintendoSwitch_WirelessController_State0x30_GyroX3;

typedef struct{
pa_NintendoSwitch_WirelessController_State0x30_Buttons buttons;
pa_NintendoSwitch_WirelessController_State0x30_GyroX3 gyro;
} pa_NintendoSwitch_WirelessController_State0x30;




extern const pa_NintendoSwitch_WirelessController_State0x30 pa_NintendoSwitch_WirelessController_State0x30_NEUTRAL_STATE;

bool pa_NintendoSwitch_WirelessController_State0x30_equals(
const pa_NintendoSwitch_WirelessController_State0x30* state0,
const pa_NintendoSwitch_WirelessController_State0x30* state1
);



#ifdef __cplusplus
}
#endif
#endif
2 changes: 1 addition & 1 deletion Common/Cpp/Concurrency/ComputationThreadPoolCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define PokemonAutomation_ComputationThreadPoolCore_H

#include <functional>
#include <list>
//#include <list>
#include <deque>
#include <thread>
#include "Common/Cpp/CpuUtilization/CpuUtilization.h"
Expand Down
30 changes: 3 additions & 27 deletions Common/SerialPABotBase/SerialPABotBase_Messages_ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef PokemonAutomation_SerialPABotBase_Messages_ESP32_H
#define PokemonAutomation_SerialPABotBase_Messages_ESP32_H

#include "../Controllers/NintendoSwitch_WirelessController_State.h"
#include "SerialPABotBase_Protocol.h"

#if _WIN32
Expand All @@ -32,30 +33,6 @@ typedef struct{
uint8_t right_grip[3];
} PABB_NintendoSwitch_ControllerColors;

typedef struct{
uint8_t button3;
uint8_t button4;
uint8_t button5;
uint8_t left_joystick[3];
uint8_t right_joystick[3];
uint8_t vibrator;
} PABB_NintendoSwitch_ButtonState;

typedef struct{
int16_t accel_x;
int16_t accel_y;
int16_t accel_z;
int16_t rotation_x;
int16_t rotation_y;
int16_t rotation_z;
} PABB_NintendoSwitch_GyroState;

typedef struct{
PABB_NintendoSwitch_GyroState time0;
PABB_NintendoSwitch_GyroState time1;
PABB_NintendoSwitch_GyroState time2;
} PABB_NintendoSwitch_GyroStateX3;




Expand All @@ -82,16 +59,15 @@ typedef struct{
typedef struct{
seqnum_t seqnum;
uint16_t milliseconds;
PABB_NintendoSwitch_ButtonState buttons;
pa_NintendoSwitch_WirelessController_State0x30_Buttons buttons;
} PABB_PACK pabb_Message_ESP32_CommandButtonState;


#define PABB_MSG_ESP32_CONTROLLER_STATE_FULL 0xa1
typedef struct{
seqnum_t seqnum;
uint16_t milliseconds;
PABB_NintendoSwitch_ButtonState buttons;
PABB_NintendoSwitch_GyroStateX3 gyro;
pa_NintendoSwitch_WirelessController_State0x30 state;
} PABB_PACK pabb_Message_ESP32_CommandFullState;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef PokemonAutomation_SerialPABotBase_Messages_NS2_WiredController_H
#define PokemonAutomation_SerialPABotBase_Messages_NS2_WiredController_H

#include "../Controllers/NintendoSwitch2_WiredController_State.h"
#include "SerialPABotBase_Protocol.h"

#if _WIN32
Expand All @@ -26,19 +27,10 @@ namespace SerialPABotBase{


#define PABB_MSG_REPORT_NS2_WIRED_CONTROLLER 0x90
typedef struct{
uint8_t buttons0;
uint8_t buttons1;
uint8_t dpad_byte;
uint8_t left_joystick_x;
uint8_t left_joystick_y;
uint8_t right_joystick_x;
uint8_t right_joystick_y;
} pabb_Report_NS2_WiredController;
typedef struct{
seqnum_t seqnum;
uint16_t milliseconds;
pabb_Report_NS2_WiredController report;
pa_NintendoSwitch2_WiredController_State report;
} PABB_PACK pabb_Message_Report_NS2_WiredController;


Expand Down
8 changes: 8 additions & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ file(GLOB MAIN_SOURCES
../Common/CRC32.cpp
../Common/CRC32.h
../Common/Compiler.h
../Common/Controllers/NintendoSwitch2_WiredController_State.h
../Common/Controllers/NintendoSwitch_WirelessController_State.h
../Common/Cpp/AbstractLogger.h
../Common/Cpp/BitmapConversion.cpp
../Common/Cpp/BitmapConversion.h
Expand Down Expand Up @@ -903,12 +905,18 @@ file(GLOB MAIN_SOURCES
Source/ML/DataLabeling/ML_SegmentAnythingModelConstants.h
Source/ML/ML_Panels.cpp
Source/ML/ML_Panels.h
Source/ML/Models/ML_ONNXRuntimeHelpers.cpp
Source/ML/Models/ML_ONNXRuntimeHelpers.h
Source/ML/Models/ML_YOLOv5Model.cpp
Source/ML/Models/ML_YOLOv5Model.h
Source/ML/Programs/ML_LabelImages.cpp
Source/ML/Programs/ML_LabelImages.h
Source/ML/Programs/ML_LabelImagesOverlayManager.cpp
Source/ML/Programs/ML_LabelImagesOverlayManager.h
Source/ML/Programs/ML_LabelImagesWidget.cpp
Source/ML/Programs/ML_LabelImagesWidget.h
Source/ML/Programs/ML_RunYOLO.cpp
Source/ML/Programs/ML_RunYOLO.h
Source/ML/UI/ML_ImageAnnotationCommandRow.cpp
Source/ML/UI/ML_ImageAnnotationCommandRow.h
Source/ML/UI/ML_ImageAnnotationDisplayOption.cpp
Expand Down
2 changes: 1 addition & 1 deletion SerialPrograms/Source/CommonFramework/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace PokemonAutomation{
const bool IS_BETA_VERSION = true;
const int PROGRAM_VERSION_MAJOR = 0;
const int PROGRAM_VERSION_MINOR = 55;
const int PROGRAM_VERSION_PATCH = 2;
const int PROGRAM_VERSION_PATCH = 3;

const std::string PROGRAM_VERSION_BASE =
"v" + std::to_string(PROGRAM_VERSION_MAJOR) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ImageViewRGB32 : public ImageViewPlanar32{
QImage to_QImage_owning() const; // Return a copy that owns its own buffer. (slow)
QImage scaled_to_QImage(size_t width, size_t height) const;

// convert to cv::Mat with BGRA color channel order
cv::Mat to_opencv_Mat() const;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ class MessageControllerWriteSpi : public BotBaseRequest{
class MessageControllerStateButtons : public BotBaseRequest{
public:
pabb_Message_ESP32_CommandButtonState params;
MessageControllerStateButtons(uint16_t milliseconds, const PABB_NintendoSwitch_ButtonState& state)
MessageControllerStateButtons(
uint16_t milliseconds,
const pa_NintendoSwitch_WirelessController_State0x30_Buttons& state
)
: BotBaseRequest(true)
{
params.seqnum = 0;
Expand All @@ -100,15 +103,15 @@ class MessageControllerStateFull : public BotBaseRequest{
pabb_Message_ESP32_CommandFullState params;
MessageControllerStateFull(
uint16_t milliseconds,
const PABB_NintendoSwitch_ButtonState& buttons,
const PABB_NintendoSwitch_GyroStateX3& gyro
const pa_NintendoSwitch_WirelessController_State0x30_Buttons& buttons,
const pa_NintendoSwitch_WirelessController_State0x30_GyroX3& gyro
)
: BotBaseRequest(true)
{
params.seqnum = 0;
params.milliseconds = milliseconds;
params.buttons = buttons;
params.gyro = gyro;
params.state.buttons = buttons;
params.state.gyro = gyro;
}
virtual BotBaseMessage message() const override{
return BotBaseMessage(PABB_MSG_ESP32_CONTROLLER_STATE_FULL, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,14 @@
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include "3rdParty/ONNX/OnnxToolsPA.h"
#include "ML/Models/ML_ONNXRuntimeHelpers.h"
#include "ML_SegmentAnythingModelConstants.h"
#include "ML_SegmentAnythingModel.h"
#include "ML_AnnotationIO.h"

namespace PokemonAutomation{
namespace ML{

Ort::SessionOptions create_session_option(){
return Ort::SessionOptions{};

// create session using Apple ML

// Ort::SessionOptions so;
// std::unordered_map<std::string, std::string> provider_options;
// provider_options["ModelFormat"] = "NeuralNetwork";
// so.AppendExecutionProvider("CoreML", provider_options);
// return so;
}


template<typename T, class Buffer, class Shape> Ort::Value create_tensor(const OrtMemoryInfo* memory_info, Buffer& buffer, const Shape& shape){
return Ort::Value::CreateTensor<T>(memory_info, buffer.data(), buffer.size(),
shape.data(), shape.size());
}


SAMEmbedderSession::SAMEmbedderSession(const std::string& model_path)
: session_options(create_session_option())
Expand Down
5 changes: 4 additions & 1 deletion SerialPrograms/Source/ML/ML_Panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include "CommonFramework/Panels/PanelTools.h"
#include "Pokemon/Pokemon_Strings.h"
#include "Programs/ML_LabelImages.h"

#include "Programs/ML_RunYOLO.h"
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
#include "ML_Panels.h"


Expand All @@ -26,6 +27,8 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
if (PreloadSettings::instance().DEVELOPER_MODE){
ret.emplace_back("---- Developer Tools ----");
ret.emplace_back(make_panel<LabelImages_Descriptor, LabelImages>());
// ret.emplace_back(make_panel<RunYOLO_Descriptor, RunYOLO>());
ret.emplace_back(NintendoSwitch::make_single_switch_program<RunYOLO_Descriptor, RunYOLO>());
// ret.emplace_back(make_single_switch_program<ThreeSegmentDudunsparceFinder_Descriptor, ThreeSegmentDudunsparceFinder>());
}

Expand Down
Loading
Loading