Skip to content

Commit

Permalink
[ros2controlcli] Fix the missing exported state interface printing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor authored Oct 16, 2024
1 parent 0ba1428 commit 0a2838a
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions ros2controlcli/ros2controlcli/verb/list_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import warnings
from controller_manager import list_controllers, bcolors

from ros2cli.node.direct import add_arguments
Expand Down Expand Up @@ -50,10 +51,14 @@ def print_controller_state(c, args, col_width_name, col_width_state, col_width_t
for connection in c.chain_connections:
for reference in connection.reference_interfaces:
print(f"\t\t{reference:20s}")
if args.reference_interfaces or args.verbose:
if args.reference_interfaces or args.exported_interfaces or args.verbose:
print("\texported reference interfaces:")
for reference_interfaces in c.reference_interfaces:
print(f"\t\t{reference_interfaces}")
for reference_interface in c.reference_interfaces:
print(f"\t\t{reference_interface}")
if args.reference_interfaces or args.exported_interfaces or args.verbose:
print("\texported state interfaces:")
for exported_state_interface in c.exported_state_interfaces:
print(f"\t\t{exported_state_interface}")


class ListControllersVerb(VerbExtension):
Expand Down Expand Up @@ -86,6 +91,11 @@ def add_arguments(self, parser, cli_name):
action="store_true",
help="List controller's exported references",
)
parser.add_argument(
"--exported-interfaces",
action="store_true",
help="List controller's exported state and reference interfaces",
)
parser.add_argument(
"--verbose",
"-v",
Expand All @@ -98,6 +108,13 @@ def main(self, *, args):
with NodeStrategy(args).direct_node as node:
response = list_controllers(node, args.controller_manager)

if args.reference_interfaces:
warnings.filterwarnings("always")
warnings.warn(
"The '--reference-interfaces' argument is deprecated and will be removed in future releases. Use '--exported-interfaces' instead.",
DeprecationWarning,
)

if not response.controller:
print("No controllers are currently loaded!")
return 0
Expand Down

0 comments on commit 0a2838a

Please sign in to comment.