Skip to content

Commit

Permalink
Added functions to api
Browse files Browse the repository at this point in the history
  • Loading branch information
IliTheButterfly committed May 10, 2024
1 parent 960761f commit 7c9e68b
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 25 deletions.
83 changes: 78 additions & 5 deletions src/rove_control_board/api/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,34 @@

enum StatusCode : euint16_t
{
STNone = 0,
STNotInitialized = 0,
STInitialized = 1,
};

enum ErrorCode : euint16_t
{
ERNone = 0,
ERAdapterNotInit = 1,
ERServoXNACK = 2,
ERServoYNACK = 4,
ERServoYNACK = 3,
ERWinchLocked = 4,
};

enum ServoControlMode : euint32_t
enum ServoControlMode : euint16_t
{
SCMNone = 0,
SCMPosition = 1,
SCMSpeed = 2,
};

enum WinchMode : euint16_t
{
WMFreeWheel = 0,
WMBrake = 1,
WMReverse = 2,
WMForward = 3,
};




Expand Down Expand Up @@ -104,6 +114,13 @@ struct RGB
};
static_assert(sizeof(RGB) == 3);

struct RGBLed
{
euint8_t index;
RGB rgb;
};
static_assert(sizeof(RGBLed) == 4);

struct Report
{
Vector2D pos;
Expand Down Expand Up @@ -186,6 +203,48 @@ static_assert((sizeof(Void)+1) == 2);
Report getReport(Void);
static_assert((sizeof(Void)+1) == 2);

UShort getWinchMode(Void);
static_assert((sizeof(Void)+1) == 2);

Void setWinchMode(UShort);
static_assert((sizeof(UShort)+1) == 3);

Bool_ getWinchLock(Void);
static_assert((sizeof(Void)+1) == 2);

Bool_ setWinchLock(Void);
static_assert((sizeof(Void)+1) == 2);

UShort getServoControlMode(Void);
static_assert((sizeof(Void)+1) == 2);

UShort getServoControlMode(Void);
static_assert((sizeof(Void)+1) == 2);

Bool_ getGPIO1(Void);
static_assert((sizeof(Void)+1) == 2);

Bool_ setGPIO1(Bool_);
static_assert((sizeof(Bool_)+1) == 2);

Bool_ getGPIO2(Void);
static_assert((sizeof(Void)+1) == 2);

Bool_ setGPIO2(Bool_);
static_assert((sizeof(Bool_)+1) == 2);

Bool_ getGPIO3(Void);
static_assert((sizeof(Void)+1) == 2);

Bool_ setGPIO3(Bool_);
static_assert((sizeof(Bool_)+1) == 2);

RGB getRGBLed(Int);
static_assert((sizeof(Int)+1) == 5);

Bool_ setRGBLed(RGBLed);
static_assert((sizeof(RGBLed)+1) == 5);

static BaseFunction_ptr commands[] = {
new Function<Int, Int>(&ping),
new Function<ULong, Void>(&hashCheck),
Expand All @@ -209,8 +268,22 @@ static BaseFunction_ptr commands[] = {
new Function<Bool_, Void>(&getLEDBack),
new Function<Bool_, Void>(&getLEDStrobe),
new Function<Report, Void>(&getReport),
new Function<UShort, Void>(&getWinchMode),
new Function<Void, UShort>(&setWinchMode),
new Function<Bool_, Void>(&getWinchLock),
new Function<Bool_, Void>(&setWinchLock),
new Function<UShort, Void>(&getServoControlMode),
new Function<UShort, Void>(&getServoControlMode),
new Function<Bool_, Void>(&getGPIO1),
new Function<Bool_, Bool_>(&setGPIO1),
new Function<Bool_, Void>(&getGPIO2),
new Function<Bool_, Bool_>(&setGPIO2),
new Function<Bool_, Void>(&getGPIO3),
new Function<Bool_, Bool_>(&setGPIO3),
new Function<RGB, Int>(&getRGBLed),
new Function<Bool_, RGBLed>(&setRGBLed),
};
#define COMMANDS_COUNT 22
#define COMMANDS_COUNT 36
#define MAX_DECODED_SIZE 9
#define MAX_ENCODED_SIZE 13
#define API_HASH 6660753000537812969UL
#define API_HASH 3739127867455560190UL
14 changes: 14 additions & 0 deletions src/rove_control_board/config/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
rove_control_board:
ros_parameters:
tpv_x_step_count:
4096
tpv_x_min:
0
tpv_x_max:
360
tpv_y_step_count:
4096
tpv_y_min:
0
tpv_y_max:
90
83 changes: 76 additions & 7 deletions src/rove_control_board/rove_control_board/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,29 @@

@manager.enum('H')
class StatusCode(Enum):
STNone = 0
STNotInitialized = 0
STInitialized = 1

@manager.enum('H')
class ErrorCode(Enum):
ERNone = 0b00000000
ERAdapterNotInit = 0b00000001
ERServoXNACK = 0b00000010
ERServoYNACK = 0b00000100
ERNone = 0
ERAdapterNotInit = 1
ERServoXNACK = 2
ERServoYNACK = 3
ERWinchLocked = 4

@manager.enum("I")
@manager.enum("H")
class ServoControlMode(Enum):
SCMNone = 0
SCMPosition = 1
SCMSpeed = 2

@manager.enum("H")
class WinchMode(Enum):
WMFreeWheel = 0
WMBrake = 1
WMReverse = 2
WMForward = 3

@manager.struct('hh')
class Vector2D(comm.BinaryData):
Expand All @@ -30,14 +39,21 @@ def __init__(self, x:int=0, y:int=0):
self.x:int
self.y:int

@manager.struct('BBB')
@manager.struct('BBBx')
class RGB(comm.BinaryData):
def __init__(self, r:int=0,g:int=0,b:int=0):
super().__init__(r=r,g=g,b=b)
self.r:int
self.g:int
self.b:int

@manager.struct('_B')
class RGBLed(comm.BinaryData):
def __init__(self, rgb:RGB=RGB(), index:int=0,):
super().__init__(rgb=rgb, index=index)
self.index:int
self.rgb:RGB

@manager.struct('_HH')
class Report(comm.BinaryData):
def __init__(self, pos:Vector2D=Vector2D(), statusCode:int=0, errorCode:int=0):
Expand Down Expand Up @@ -133,5 +149,58 @@ def getLEDStrobe() -> comm.Bool_:
def getReport() -> Report:
pass

@manager.command(comm.Void, comm.UShort)
def getWinchMode() -> comm.UShort:
pass

@manager.command(comm.UShort, comm.Bool_)
def setWinchMode(winchMode:comm.UShort):
pass

@manager.command(comm.Void, comm.Bool_)
def getWinchLock() -> comm.Bool_:
pass

@manager.command(comm.Void, comm.Bool_)
def setWinchLock(lock:comm.Bool_):
pass

@manager.command(comm.Void, comm.UShort)
def getServoControlMode() -> comm.UShort:
pass

@manager.command(comm.UShort, comm.UShort)
def setServoControlMode(servoControlMode:comm.UShort) -> comm.Bool_:
pass

@manager.command(comm.Void, comm.Bool_)
def getGPIO1() -> comm.Bool_:
pass

@manager.command(comm.Bool_, comm.Bool_)
def setGPIO1(state:comm.Bool_) -> comm.Bool_:
pass

@manager.command(comm.Void, comm.Bool_)
def getGPIO2() -> comm.Bool_:
pass

@manager.command(comm.Bool_, comm.Bool_)
def setGPIO2(state:comm.Bool_) -> comm.Bool_:
pass

@manager.command(comm.Void, comm.Bool_)
def getGPIO3() -> comm.Bool_:
pass

@manager.command(comm.Bool_, comm.Bool_)
def setGPIO3(state:comm.Bool_) -> comm.Bool_:
pass

@manager.command(comm.Int, RGB)
def getRGBLed(index:comm.Int) -> RGB:
pass

@manager.command(RGBLed, comm.Bool_)
def setRGBLed(led:RGBLed) -> comm.Bool_:
pass
Loading

0 comments on commit 7c9e68b

Please sign in to comment.