-
Notifications
You must be signed in to change notification settings - Fork 4
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 #52 from ipa320/rwu/feature/write_param_value_in_s…
…ystem Write param value in system model [Merge 1st]
- Loading branch information
Showing
11 changed files
with
109 additions
and
30 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
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,52 @@ | ||
import psutil | ||
from rclpy.parameter import Parameter | ||
from rcl_interfaces.msg import ParameterType | ||
|
||
|
||
def find_process_by_node_name(node_name, namespace): | ||
for process in psutil.process_iter(["pid", "cmdline"]): | ||
try: | ||
cmdline = process.info["cmdline"] | ||
if namespace in str(cmdline) and node_name in str(cmdline): | ||
cmdline_list = cmdline[0].split("/") | ||
if len(cmdline_list) >= 3: | ||
return cmdline_list[-2], cmdline_list[-1] | ||
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): | ||
pass | ||
return "TODO", "TODO" | ||
|
||
|
||
def get_param_value(pvalue: Parameter): | ||
if pvalue.type == ParameterType.PARAMETER_BOOL: | ||
label = "Boolean value is:" | ||
value = pvalue.bool_value | ||
elif pvalue.type == ParameterType.PARAMETER_INTEGER: | ||
label = "Integer value is:" | ||
value = pvalue.integer_value | ||
elif pvalue.type == ParameterType.PARAMETER_DOUBLE: | ||
label = "Double value is:" | ||
value = pvalue.double_value | ||
elif pvalue.type == ParameterType.PARAMETER_STRING: | ||
label = "String value is:" | ||
value = pvalue.string_value | ||
elif pvalue.type == ParameterType.PARAMETER_BYTE_ARRAY: | ||
label = "Byte values are:" | ||
value = pvalue.byte_array_value | ||
elif pvalue.type == ParameterType.PARAMETER_BOOL_ARRAY: | ||
label = "Boolean values are:" | ||
value = pvalue.bool_array_value | ||
elif pvalue.type == ParameterType.PARAMETER_INTEGER_ARRAY: | ||
label = "Integer values are:" | ||
value = pvalue.integer_array_value.tolist() | ||
elif pvalue.type == ParameterType.PARAMETER_DOUBLE_ARRAY: | ||
label = "Double values are:" | ||
value = pvalue.double_array_value.tolist() | ||
elif pvalue.type == ParameterType.PARAMETER_STRING_ARRAY: | ||
label = "String values are:" | ||
value = pvalue.string_array_value | ||
elif pvalue.type == ParameterType.PARAMETER_NOT_SET: | ||
label = "Parameter not set." | ||
value = None | ||
else: | ||
return f"Unknown parameter type '{pvalue.type}'" | ||
return value |
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
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 |
---|---|---|
|
@@ -22,3 +22,4 @@ test_model: | |
parameters: | ||
'shadows/min_angle': | ||
type: Double | ||
value: -1.52 |
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
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