rename Odrive interface to ODrive

This commit is contained in:
Samuel Sadok
2020-05-29 10:19:10 +02:00
parent b4213a83e3
commit 6902fd6b34
7 changed files with 17 additions and 12 deletions
+1 -1
View File
@@ -214,7 +214,7 @@ enum TimingLog_t {
// general system functions defined in main.cpp
class ODrive : public OdriveIntf {
class ODrive : public ODriveIntf {
public:
void save_configuration() override;
void erase_configuration() override;
+1 -1
View File
@@ -3,7 +3,7 @@ tup.include('build.lua')
tup.frule{inputs={'fibre/cpp/interfaces_template.j2'}, command='python3 interface_generator.py --definitions odrive-interface.yaml --template %f --output %o', outputs='autogen/interfaces.hpp'}
tup.frule{inputs={'fibre/cpp/function_stubs_template.j2'}, command='python3 interface_generator.py --definitions odrive-interface.yaml --template %f --output %o', outputs='autogen/function_stubs.hpp'}
tup.frule{inputs={'fibre/cpp/endpoints_template.j2'}, command='python3 interface_generator.py --definitions odrive-interface.yaml --generate-endpoints Odrive --template %f --output %o', outputs='autogen/endpoints.hpp'}
tup.frule{inputs={'fibre/cpp/endpoints_template.j2'}, command='python3 interface_generator.py --definitions odrive-interface.yaml --generate-endpoints ODrive --template %f --output %o', outputs='autogen/endpoints.hpp'}
tup.frule{inputs={'fibre/cpp/type_info_template.j2'}, command='python3 interface_generator.py --definitions odrive-interface.yaml --template %f --output %o', outputs='autogen/type_info.hpp'}
tup.frule{command='python3 interface_generator.py --definitions odrive-interface.yaml --template enums_template.j2 --output ../tools/odrive/enums.py'}
+1 -1
View File
@@ -29,7 +29,7 @@
/* Private variables ---------------------------------------------------------*/
static Introspectable root_obj = OdriveTypeInfo<ODrive>::make_introspectable(odrv);
static Introspectable root_obj = ODriveTypeInfo<ODrive>::make_introspectable(odrv);
/* Private function prototypes -----------------------------------------------*/
/* Function implementations --------------------------------------------------*/
+1 -1
View File
@@ -19,7 +19,7 @@ enum {
CAN_BAUD_1M = 1000000
};
class ODriveCAN : public OdriveIntf::CanIntf {
class ODriveCAN : public ODriveIntf::CanIntf {
public:
struct Config_t {
uint32_t baud_rate = CAN_BAUD_250K;
+6 -3
View File
@@ -78,6 +78,7 @@ properties:
ns: {type: string}
version: {type: string}
summary: {type: string}
dictionary: {type: array, items: {type: string}}
interfaces:
type: object
additionalProperties: { "$ref": "#/definitions/interface" }
@@ -105,13 +106,14 @@ class SafeLineLoader(yaml.SafeLoader):
# #mapping['__column__'] = node.start_mark.column + 1
# return mapping
dictionary = []
def get_words(string):
"""
Splits a string in PascalCase into a list of lower case words
"""
return [w.lower() for w in re.findall('[a-z0-9]+|[A-Z][a-z0-9]*', string)]
regex = ''.join((re.escape(w) + '|') for w in dictionary) + '[a-z0-9]+|[A-Z][a-z0-9]*'
return [(w if w in dictionary else w.lower()) for w in re.findall(regex, string)]
def join_name(*names, delimiter: str = '.'):
"""
@@ -128,7 +130,7 @@ def split_name(name, delimiter: str = '.'):
yield c if (parenthesis_depth == 0) or (c != delimiter) else ':'
return [part.replace(':', '.') for part in ''.join(replace_delimiter_in_parentheses()).split('.')]
def to_pascal_case(s): return ''.join([w.title() for w in get_words(s)])
def to_pascal_case(s): return ''.join([(w.title() if not w in dictionary else w) for w in get_words(s)])
def to_camel_case(s): return ''.join([(c.lower() if i == 0 else c) for i, c in enumerate(''.join([w.title() for w in get_words(s)]))])
def to_macro_case(s): return '_'.join(get_words(s)).upper()
def to_snake_case(s): return '_'.join(get_words(s)).lower()
@@ -519,6 +521,7 @@ for definition_file in definition_files:
raise Exception(err.message + '\nat ' + str(list(err.absolute_path)))
interfaces = {**interfaces, **get_dict(file_content, 'interfaces')}
value_types = {**value_types, **get_dict(file_content, 'valuetypes')}
dictionary += file_content.get('dictionary', None) or []
# Preprocess definitions
+5 -3
View File
@@ -3,8 +3,10 @@ version: 0.0.1
ns: com.odriverobotics
summary: ODrive Interface Definitions
dictionary: [ODrive] # Prevent the word 'ODrive' from being detected as two words 'O' and 'Drive'
interfaces:
Odrive:
ODrive:
c_is_class: True
attributes:
vbus_voltage: readonly float32
@@ -162,7 +164,7 @@ interfaces:
reboot:
enter_dfu_mode:
Odrive.Can:
ODrive.Can:
c_is_class: True
attributes:
error:
@@ -625,7 +627,7 @@ interfaces:
valuetypes:
Odrive.Can.Protocol:
ODrive.Can.Protocol:
values: {Simple: }
Axis.AxisState: # TODO: remove redundant "Axis" in name
+2 -2
View File
@@ -1,7 +1,7 @@
# TODO: This file is dangerous because the enums could potentially change between API versions. Should transmit as part of the JSON.
# Odrive.Can.Protocol
# ODrive.Can.Protocol
PROTOCOL_SIMPLE = 0
# Axis.AxisState
@@ -47,7 +47,7 @@ MOTOR_TYPE_HIGH_CURRENT = 0
MOTOR_TYPE_GIMBAL = 2
MOTOR_TYPE_ACIM = 3
# Odrive.Can.Error
# ODrive.Can.Error
CAN_ERROR_NONE = 0x00000000
CAN_ERROR_DUPLICATE_CAN_IDS = 0x00000001