-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from RoboTeamTwente/BasestationConfig
Add basestation configuration
- Loading branch information
Showing
13 changed files
with
432 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4 | ||
5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// AUTOGENERATED. Run generator/main.py to regenerate | ||
/* | ||
[ 0 ] [ 1 ] | ||
11111111 -------- header | ||
-------- 1111---- remVersion | ||
-------- ----1--- channel | ||
*/ | ||
|
||
#ifndef __BASESTATION_CONFIGURATION_H | ||
#define __BASESTATION_CONFIGURATION_H | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include "BaseTypes.h" | ||
|
||
typedef struct _BasestationConfigurationPayload { | ||
uint8_t payload[PACKET_SIZE_BASESTATION_CONFIGURATION]; | ||
} BasestationConfigurationPayload; | ||
|
||
typedef struct _BasestationConfiguration { | ||
uint32_t header ; // integer [0, 255] Header byte indicating the type of packet | ||
uint32_t remVersion ; // integer [0, 15] Version of roboteam_embedded_messages | ||
bool channel ; // integer [0, 1] Channel on which the basestation and robots communicate | ||
} BasestationConfiguration; | ||
|
||
// ================================ GETTERS ================================ | ||
static inline uint32_t BasestationConfiguration_get_header(BasestationConfigurationPayload *bcp){ | ||
return ((bcp->payload[0])); | ||
} | ||
|
||
static inline uint32_t BasestationConfiguration_get_remVersion(BasestationConfigurationPayload *bcp){ | ||
return ((bcp->payload[1] & 0b11110000) >> 4); | ||
} | ||
|
||
static inline bool BasestationConfiguration_get_channel(BasestationConfigurationPayload *bcp){ | ||
return (bcp->payload[1] & 0b00001000) > 0; | ||
} | ||
|
||
// ================================ SETTERS ================================ | ||
static inline void BasestationConfiguration_set_header(BasestationConfigurationPayload *bcp, uint32_t header){ | ||
bcp->payload[0] = header; | ||
} | ||
|
||
static inline void BasestationConfiguration_set_remVersion(BasestationConfigurationPayload *bcp, uint32_t remVersion){ | ||
bcp->payload[1] = ((remVersion << 4) & 0b11110000) | (bcp->payload[1] & 0b00001111); | ||
} | ||
|
||
static inline void BasestationConfiguration_set_channel(BasestationConfigurationPayload *bcp, bool channel){ | ||
bcp->payload[1] = ((channel << 3) & 0b00001000) | (bcp->payload[1] & 0b11110111); | ||
} | ||
|
||
// ================================ ENCODE ================================ | ||
static inline void encodeBasestationConfiguration(BasestationConfigurationPayload *bcp, BasestationConfiguration *bc){ | ||
BasestationConfiguration_set_header (bcp, bc->header); | ||
BasestationConfiguration_set_remVersion (bcp, bc->remVersion); | ||
BasestationConfiguration_set_channel (bcp, bc->channel); | ||
} | ||
|
||
// ================================ DECODE ================================ | ||
static inline void decodeBasestationConfiguration(BasestationConfiguration *bc, BasestationConfigurationPayload *bcp){ | ||
bc->header = BasestationConfiguration_get_header(bcp); | ||
bc->remVersion = BasestationConfiguration_get_remVersion(bcp); | ||
bc->channel = BasestationConfiguration_get_channel(bcp); | ||
} | ||
|
||
#endif /*__BASESTATION_CONFIGURATION_H*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// AUTOGENERATED. Run generator/main.py to regenerate | ||
/* | ||
[ 0 ] | ||
11111111 header | ||
*/ | ||
|
||
#ifndef __BASESTATION_GET_CONFIGURATION_H | ||
#define __BASESTATION_GET_CONFIGURATION_H | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include "BaseTypes.h" | ||
|
||
typedef struct _BasestationGetConfigurationPayload { | ||
uint8_t payload[PACKET_SIZE_BASESTATION_GET_CONFIGURATION]; | ||
} BasestationGetConfigurationPayload; | ||
|
||
typedef struct _BasestationGetConfiguration { | ||
uint32_t header ; // integer [0, 255] Header byte indicating the type of packet | ||
} BasestationGetConfiguration; | ||
|
||
// ================================ GETTERS ================================ | ||
static inline uint32_t BasestationGetConfiguration_get_header(BasestationGetConfigurationPayload *bgcp){ | ||
return ((bgcp->payload[0])); | ||
} | ||
|
||
// ================================ SETTERS ================================ | ||
static inline void BasestationGetConfiguration_set_header(BasestationGetConfigurationPayload *bgcp, uint32_t header){ | ||
bgcp->payload[0] = header; | ||
} | ||
|
||
// ================================ ENCODE ================================ | ||
static inline void encodeBasestationGetConfiguration(BasestationGetConfigurationPayload *bgcp, BasestationGetConfiguration *bgc){ | ||
BasestationGetConfiguration_set_header (bgcp, bgc->header); | ||
} | ||
|
||
// ================================ DECODE ================================ | ||
static inline void decodeBasestationGetConfiguration(BasestationGetConfiguration *bgc, BasestationGetConfigurationPayload *bgcp){ | ||
bgc->header = BasestationGetConfiguration_get_header(bgcp); | ||
} | ||
|
||
#endif /*__BASESTATION_GET_CONFIGURATION_H*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// AUTOGENERATED. Run generator/main.py to regenerate | ||
/* | ||
[ 0 ] [ 1 ] | ||
11111111 -------- header | ||
-------- 1111---- remVersion | ||
-------- ----1--- channel | ||
*/ | ||
|
||
#ifndef __BASESTATION_SET_CONFIGURATION_H | ||
#define __BASESTATION_SET_CONFIGURATION_H | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include "BaseTypes.h" | ||
|
||
typedef struct _BasestationSetConfigurationPayload { | ||
uint8_t payload[PACKET_SIZE_BASESTATION_SET_CONFIGURATION]; | ||
} BasestationSetConfigurationPayload; | ||
|
||
typedef struct _BasestationSetConfiguration { | ||
uint32_t header ; // integer [0, 255] Header byte indicating the type of packet | ||
uint32_t remVersion ; // integer [0, 15] Version of roboteam_embedded_messages | ||
bool channel ; // integer [0, 1] Channel on which the basestation and robots communicate | ||
} BasestationSetConfiguration; | ||
|
||
// ================================ GETTERS ================================ | ||
static inline uint32_t BasestationSetConfiguration_get_header(BasestationSetConfigurationPayload *bscp){ | ||
return ((bscp->payload[0])); | ||
} | ||
|
||
static inline uint32_t BasestationSetConfiguration_get_remVersion(BasestationSetConfigurationPayload *bscp){ | ||
return ((bscp->payload[1] & 0b11110000) >> 4); | ||
} | ||
|
||
static inline bool BasestationSetConfiguration_get_channel(BasestationSetConfigurationPayload *bscp){ | ||
return (bscp->payload[1] & 0b00001000) > 0; | ||
} | ||
|
||
// ================================ SETTERS ================================ | ||
static inline void BasestationSetConfiguration_set_header(BasestationSetConfigurationPayload *bscp, uint32_t header){ | ||
bscp->payload[0] = header; | ||
} | ||
|
||
static inline void BasestationSetConfiguration_set_remVersion(BasestationSetConfigurationPayload *bscp, uint32_t remVersion){ | ||
bscp->payload[1] = ((remVersion << 4) & 0b11110000) | (bscp->payload[1] & 0b00001111); | ||
} | ||
|
||
static inline void BasestationSetConfiguration_set_channel(BasestationSetConfigurationPayload *bscp, bool channel){ | ||
bscp->payload[1] = ((channel << 3) & 0b00001000) | (bscp->payload[1] & 0b11110111); | ||
} | ||
|
||
// ================================ ENCODE ================================ | ||
static inline void encodeBasestationSetConfiguration(BasestationSetConfigurationPayload *bscp, BasestationSetConfiguration *bsc){ | ||
BasestationSetConfiguration_set_header (bscp, bsc->header); | ||
BasestationSetConfiguration_set_remVersion (bscp, bsc->remVersion); | ||
BasestationSetConfiguration_set_channel (bscp, bsc->channel); | ||
} | ||
|
||
// ================================ DECODE ================================ | ||
static inline void decodeBasestationSetConfiguration(BasestationSetConfiguration *bsc, BasestationSetConfigurationPayload *bscp){ | ||
bsc->header = BasestationSetConfiguration_get_header(bscp); | ||
bsc->remVersion = BasestationSetConfiguration_get_remVersion(bscp); | ||
bsc->channel = BasestationSetConfiguration_get_channel(bscp); | ||
} | ||
|
||
#endif /*__BASESTATION_SET_CONFIGURATION_H*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// AUTOGENERATED. Run generator/main.py to regenerate | ||
/* | ||
[ 0 ] [ 1 ] | ||
11111111 -------- header | ||
-------- 1111---- remVersion | ||
-------- ----1--- channel | ||
*/ | ||
|
||
syntax="proto3"; | ||
|
||
package proto; | ||
|
||
message BasestationConfiguration { | ||
uint32 header = 1; // integer [0, 255] Header byte indicating the type of packet | ||
uint32 remVersion = 2; // integer [0, 15] Version of roboteam_embedded_messages | ||
bool channel = 3; // integer [0, 1] Channel on which the basestation and robots communicate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// AUTOGENERATED. Run generator/main.py to regenerate | ||
/* | ||
[ 0 ] | ||
11111111 header | ||
*/ | ||
|
||
syntax="proto3"; | ||
|
||
package proto; | ||
|
||
message BasestationGetConfiguration { | ||
uint32 header = 1; // integer [0, 255] Header byte indicating the type of packet | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// AUTOGENERATED. Run generator/main.py to regenerate | ||
/* | ||
[ 0 ] [ 1 ] | ||
11111111 -------- header | ||
-------- 1111---- remVersion | ||
-------- ----1--- channel | ||
*/ | ||
|
||
syntax="proto3"; | ||
|
||
package proto; | ||
|
||
message BasestationSetConfiguration { | ||
uint32 header = 1; // integer [0, 255] Header byte indicating the type of packet | ||
uint32 remVersion = 2; // integer [0, 15] Version of roboteam_embedded_messages | ||
bool channel = 3; // integer [0, 1] Channel on which the basestation and robots communicate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# AUTOGENERATED. Run generator/main.py to regenerate | ||
""" | ||
[ 0 ] [ 1 ] | ||
11111111 -------- header | ||
-------- 1111---- remVersion | ||
-------- ----1--- channel | ||
""" | ||
|
||
import numpy as np | ||
from . import BaseTypes | ||
|
||
|
||
|
||
class BasestationConfiguration: | ||
header = 0 # integer [0, 255] Header byte indicating the type of packet | ||
remVersion = 0 # integer [0, 15] Version of roboteam_embedded_messages | ||
channel = 0 # integer [0, 1] Channel on which the basestation and robots communicate | ||
|
||
|
||
|
||
# ================================ GETTERS ================================ | ||
@staticmethod | ||
def get_header(payload): | ||
return ((payload[0])); | ||
|
||
@staticmethod | ||
def get_remVersion(payload): | ||
return ((payload[1] & 0b11110000) >> 4); | ||
|
||
@staticmethod | ||
def get_channel(payload): | ||
return (payload[1] & 0b00001000) > 0; | ||
|
||
# ================================ SETTERS ================================ | ||
@staticmethod | ||
def set_header(payload, header): | ||
payload[0] = header; | ||
|
||
@staticmethod | ||
def set_remVersion(payload, remVersion): | ||
payload[1] = ((remVersion << 4) & 0b11110000) | (payload[1] & 0b00001111); | ||
|
||
@staticmethod | ||
def set_channel(payload, channel): | ||
payload[1] = ((channel << 3) & 0b00001000) | (payload[1] & 0b11110111); | ||
|
||
# ================================ ENCODE ================================ | ||
def encode(self): | ||
payload = np.zeros(BaseTypes.PACKET_SIZE_BASESTATION_CONFIGURATION, dtype=np.uint8) | ||
BasestationConfiguration.set_header (payload, self.header) | ||
BasestationConfiguration.set_remVersion (payload, self.remVersion) | ||
BasestationConfiguration.set_channel (payload, self.channel) | ||
return payload | ||
|
||
|
||
# ================================ DECODE ================================ | ||
def decode(self, payload): | ||
self.header = BasestationConfiguration.get_header(payload) | ||
self.remVersion = BasestationConfiguration.get_remVersion(payload) | ||
self.channel = BasestationConfiguration.get_channel(payload) | ||
|
||
|
||
def print_bit_string(self): | ||
payload = self.encode() | ||
for i in range(len(payload)): | ||
print(format(payload[i], '08b'), end=" ") | ||
print() |
Oops, something went wrong.