Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cli interface #176

Merged
merged 6 commits into from
Nov 11, 2020
Merged

Add cli interface #176

merged 6 commits into from
Nov 11, 2020

Conversation

v-lopez
Copy link
Contributor

@v-lopez v-lopez commented Oct 2, 2020

Added command line interface for controller manager

Missing unit tests, waiting until we have a controller manager node or something similar like what is proposed on #147 or I could do them with mock services.

Implemented verbs:

list

$ ros2 control list -h
usage: ros2 control list [-h] [--spin-time SPIN_TIME] [--no-daemon] [-c CONTROLLER_MANAGER] [--include-hidden-nodes]

Output the list of loaded controllers, their type and status

optional arguments:
  -h, --help            show this help message and exit
  --spin-time SPIN_TIME
                        Spin time in seconds to wait for discovery (only applies when not using an already running daemon)
  -c CONTROLLER_MANAGER, --controller-manager CONTROLLER_MANAGER
                        Name of the controller manager ROS node
  --include-hidden-nodes
                        Consider hidden nodes as well
$ ros2 control list 
test_controller_name[test_controller]    active 

list_types

$ ros2 control list_types -h
usage: ros2 control list_types [-h] [--spin-time SPIN_TIME] [--no-daemon] [-c CONTROLLER_MANAGER] [--include-hidden-nodes]

Output the available controller types and their base classes

optional arguments:
  -h, --help            show this help message and exit
  --spin-time SPIN_TIME
                        Spin time in seconds to wait for discovery (only applies when not using an already running daemon)
  -c CONTROLLER_MANAGER, --controller-manager CONTROLLER_MANAGER
                        Name of the controller manager ROS node
  --include-hidden-nodes
                        Consider hidden nodes as well
$ ros2 control list_types 
diff_drive_controller/DiffDriveController                              controller_interface::ControllerInterface
joint_state_controller/JointStateController                            controller_interface::ControllerInterface
joint_trajectory_controller/JointTrajectoryController                  controller_interface::ControllerInterface
test_controller      

load

$ ros2 control load -h
usage: ros2 control load [-h] [--spin-time SPIN_TIME] [--no-daemon] [-c CONTROLLER_MANAGER] [--include-hidden-nodes] controller_name

Load a controller in a controller manager

positional arguments:
  controller_name       Name of the controller

optional arguments:
  -h, --help            show this help message and exit
  --spin-time SPIN_TIME
                        Spin time in seconds to wait for discovery (only applies when not using an already running daemon)
  -c CONTROLLER_MANAGER, --controller-manager CONTROLLER_MANAGER
                        Name of the controller manager ROS node
  --include-hidden-nodes
                        Consider hidden nodes as well

reload_libraries

$ ros2 control reload_libraries -h
usage: ros2 control reload_libraries [-h] [--spin-time SPIN_TIME] [--force-kill] [-c CONTROLLER_MANAGER] [--include-hidden-nodes]

Reload controller libraries

optional arguments:
  -h, --help            show this help message and exit
  --spin-time SPIN_TIME
                        Spin time in seconds to wait for discovery (only applies when not using an already running daemon)
  --force-kill          Force stop of loaded controllers
  -c CONTROLLER_MANAGER, --controller-manager CONTROLLER_MANAGER
                        Name of the controller manager ROS node
  --include-hidden-nodes
                        Consider hidden nodes as well

switch

$ ros2 control switch -h
usage: ros2 control switch [-h] [--spin-time SPIN_TIME] [--no-daemon] [--stop-controllers [STOP_CONTROLLERS [STOP_CONTROLLERS ...]]]
                           [--start-controllers [START_CONTROLLERS [START_CONTROLLERS ...]]] [--strict] [--start-asap]
                           [--switch-timeout SWITCH_TIMEOUT] [-c CONTROLLER_MANAGER] [--include-hidden-nodes]

Switch controllers in a controller manager

optional arguments:
  -h, --help            show this help message and exit
  --spin-time SPIN_TIME
                        Spin time in seconds to wait for discovery (only applies when not using an already running daemon)
  --stop-controllers [STOP_CONTROLLERS [STOP_CONTROLLERS ...]]
                        Name of the controllers to be stopped
  --start-controllers [START_CONTROLLERS [START_CONTROLLERS ...]]
                        Name of the controllers to be started
  --strict              Strict switch
  --start-asap          Start asap controllers
  --switch-timeout SWITCH_TIMEOUT
                        Timeout for switching controllers
  -c CONTROLLER_MANAGER, --controller-manager CONTROLLER_MANAGER
                        Name of the controller manager ROS node
  --include-hidden-nodes
                        Consider hidden nodes as well

unload

$ ros2 control unload -h
usage: ros2 control unload [-h] [--spin-time SPIN_TIME] [--no-daemon] [-c CONTROLLER_MANAGER] [--include-hidden-nodes] controller_name

Unload a controller in a controller manager

positional arguments:
  controller_name       Name of the controller

optional arguments:
  -h, --help            show this help message and exit
  --spin-time SPIN_TIME
                        Spin time in seconds to wait for discovery (only applies when not using an already running daemon)
  -c CONTROLLER_MANAGER, --controller-manager CONTROLLER_MANAGER
                        Name of the controller manager ROS node
  --include-hidden-nodes
                        Consider hidden nodes as well

Copy link
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good.

I have a few comments, but nothing ground-braking :)

Are these python test files really needed? It looks like a lot of copy-paste action across many repositories (@Karsten1987 )?

ros2controlcli/README.md Show resolved Hide resolved
ros2controlcli/package.xml Show resolved Hide resolved
ros2controlcli/ros2controlcli/api/__init__.py Outdated Show resolved Hide resolved
ros2controlcli/test/test_copyright.py Show resolved Hide resolved
ros2controlcli/README.md Show resolved Hide resolved
ros2controlcli/package.xml Outdated Show resolved Hide resolved
Copy link
Member

@bmagyar bmagyar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get the CI green

@codecov-io
Copy link

Codecov Report

Merging #176 (061f525) into master (c47791a) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #176   +/-   ##
=======================================
  Coverage   34.61%   34.61%           
=======================================
  Files          52       52           
  Lines        2981     2981           
  Branches     1855     1855           
=======================================
  Hits         1032     1032           
  Misses        310      310           
  Partials     1639     1639           
Flag Coverage Δ
unittests 34.61% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants