Skip to content

Commit

Permalink
INTEGER type
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Weaver <tyler@picknik.ai>
  • Loading branch information
tylerjw committed Aug 18, 2022
1 parent c3181c4 commit 26de692
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
18 changes: 18 additions & 0 deletions example/src/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,21 @@ admittance_controller:
default_value: false,
description: "if enabled, the velocity commanded to the admittance controller is added to its calculated admittance velocity"
}
one_number: {
type: int,
default: 14540,
readonly: true,
validation: {
bounds<>: [ 1024, 65535 ]
}
}
three_numbers: {
type: int_array,
default: [3,4,5],
readonly: true,
}
three_numbers_of_five: {
type: int_array_fixed_5,
default: [3,3,3],
readonly: true,
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,20 @@ def bool_array_fixed_to_str(values: Optional[list]):
return "{{" + ", ".join(bool_to_str(x) for x in values) + "}}"


@typechecked
def int_to_integer_str(value: str):
return value.replace("int", "integer")


class CodeGenVariableBase:
defined_type_to_cpp_type = {
"bool": lambda defined_type, templates: "bool",
"double": lambda defined_type, templates: "double",
"int": lambda defined_type, templates: "int",
"int": lambda defined_type, templates: "int64_t",
"string": lambda defined_type, templates: "std::string",
"bool_array": lambda defined_type, templates: "std::vector<bool>",
"double_array": lambda defined_type, templates: "std::vector<double>",
"int_array": lambda defined_type, templates: "std::vector<int>",
"int_array": lambda defined_type, templates: "std::vector<int64_t>",
"string_array": lambda defined_type, templates: "std::vector<std::string>",
"double_array_fixed": lambda defined_type, templates: f"parameter_traits::FixedSizeArray<{templates[0]}, {templates[1]}>",
"int_array_fixed": lambda defined_type, templates: f"parameter_traits::FixedSizeArray<{templates[0]}, {templates[1]}>",
Expand Down Expand Up @@ -377,7 +382,7 @@ def process_type(self, defined_type):
return defined_type, None

def get_parameter_type(self):
return self.defined_type.upper()
return int_to_integer_str(self.defined_type).upper()


class CodeGenFixedVariable(CodeGenVariableBase):
Expand All @@ -391,7 +396,7 @@ def process_type(self, defined_type):
return defined_type, (cpp_base_type, size)

def get_parameter_type(self):
return get_fixed_base_type(self.defined_type).upper()
return int_to_integer_str(get_fixed_base_type(self.defined_type)).upper()


# Each template has a corresponding class with the str filling in the template with jinja
Expand Down
Binary file not shown.

0 comments on commit 26de692

Please sign in to comment.