Control
This module defines varuous language controls.
- CommandControl: Basic commands such as 'start', 'stop', 'restart', etc.
- MobileControl: Commands for mobile movement like 'move forward', 'move backward', etc.
- HeadControl: Commands for head movements such as 'look up', 'look down', etc.
- HandControl: Commands for hand movements like 'open hand', 'move hand forward', etc.
- MobileSingleArmControl: Comprehensive commands for a mobile single-arm robot, including movements and rotations.
The dynamically created Enums are: - LangControl: Combines CommandControl, MobileControl, HeadControl, and HandControl. - MobileSingleArmLangControl: Based on MobileSingleArmControl.
Example usage:
execute_command(LangControl.START) # Output: Starting the system...
execute_command(LangControl.MOVE_FORWARD) # Output: Moving forward...
command_str = "move forward"
command = get_command_from_string(command_str)
execute_command(command) # Execute: Moving forward...
create_enum_from_list(name, string_list)
Dynamically create an Enum type from a list of strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the Enum class. |
required |
string_list
|
list[str]
|
The list of strings to be converted into Enum members. |
required |
Returns:
Name | Type | Description |
---|---|---|
Enum |
Enum
|
A dynamically created Enum type with members based on the string list. |
Source code in mbodied/types/language/control.py
27 28 29 30 31 32 33 34 35 36 37 |
|
get_command_from_string(command_str)
Get the Enum member corresponding to a given command string.
Source code in mbodied/types/language/control.py
45 46 47 48 49 50 |
|
language_control_to_list(enum)
Convert an Enum type to a list of its values. So it's easier to pass i.e. as prompt.
Source code in mbodied/types/language/control.py
40 41 42 |
|