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

Replicate pbcmd #24

Merged
merged 12 commits into from
Aug 24, 2022
Merged

Replicate pbcmd #24

merged 12 commits into from
Aug 24, 2022

Conversation

andermi
Copy link
Collaborator

@andermi andermi commented Aug 20, 2022

The physical buoy has a cli called pbcmd with several aliases for commands:

available commands aliases for pbcmd (help message):

pbcmd: Multi-call command Power Buoy dispatcher
Supported commands:
*             bender  - Sets the state of the bender module
*      reset_battery  - Reset battery controller (caution - no args)

*               pump  - Spring Controller pump  off or on for a time in minutes <= 127
*              valve  - Spring Controller valve off or on for a time in seconds <= 127
*             tether  - Spring Controller tether power on or off
*       sc_pack_rate  - Set the CANBUS packet rate from the spring controller
*       reset_spring  - Reset Spring Controller (caution - no args)

*           pc_Scale  - Set the scale factor
*         pc_Retract  - Set the retract factor
*        pc_VTargMax  - Set the max target voltage
*   pc_ChargeCurrLim  - Set the maximum battery charge current
*     pc_DrawCurrLim  - Set the maximum battery current draw
*      pc_BattSwitch  - Set the battery switch state
*            pc_Gain  - Set the gain scheduler gain
*      pc_StdDevTarg  - Set the target RPM standard deviation
*        pc_WindCurr  - Set the winding current target
*        pc_BiasCurr  - Set the winding current bias
*        pc_PackRate  - Set the CANBUS packet rate

*          tf_SetPos  - Open/close the doors in the heave-cone
*    tf_SetActualPos  - Open/close the doors in the heave-cone
*         tf_SetMode  - Set controller mode
*   tf_SetChargeMode  - Set Battery Charge mode
* tf_SetStateMachine  - Set Battery Charge mode
*      tf_SetCurrLim  - Set controller current limit
*        tf_WatchDog  - Toggle controller watchdog (caution - no args)
*           tf_Reset  - Reset Controller (caution - no args)


For help on a command use the command name, i.e., "bender"

Except the reset commands which take no arguments.

DO NOT enter reset_power and expect to get help. The command will execute!

For the Sim, only a few of these are implemented:
aliases TODO:

  • pump
  • valve
  • sc_pack_rate
  • pc_Scale
  • pc_Retract
  • pc_WindCurr
  • pc_BiasCurr
  • pc_PackRate

Usage:

As part of the build, the post-install step will run the alias installer and install aliases to ~/.local/bin

To test:

Build and source the workspace and run the sim, then inspect ~/.local/bin to see symlinks installed.

In a new terminal, source the workspace and try running commands:

$ pbcmd

should print the available commands like above.

try other commands like:

$ valve -h
usage: valve [-h] duration_sec

positional arguments:
  duration_sec  Executing valve to Spring Controller valve off or on for a time in seconds <= 12...

optional arguments:
  -h, --help    show this help message and exit

should print valve usage

missing args should print something like

$ valve
usage: valve [-h] duration_sec
valve: error: the following arguments are required: duration_sec

and using the command properly:

$ valve 10
Executing valve to Spring Controller valve: 10 second(s)
[INFO] [1660956604.401288018] [pbcmd]: /pc_pack_rate_command not available
[INFO] [1660956604.652030356] [pbcmd]: /sc_pack_rate_command not available
[INFO] [1660956604.654093281] [pbcmd]: Command Successful
done!
[INFO] [1660956615.447699560] [spring_controller]: [ROS 2 Spring Control] ValveCommand Received (10s)
[INFO] [1660956623.602440647] [spring_controller]: Valve open (10s)

should run the valve in the sim for 10 seconds and:

$ valve off
Executing valve to Spring Controller valve: off
[INFO] [1660957253.049844816] [pbcmd]: /pc_pack_rate_command not available
[INFO] [1660957253.300562933] [pbcmd]: /sc_pack_rate_command not available
[INFO] [1660957253.303867220] [pbcmd]: Command Successful
done!
[INFO] [1660957253.301667417] [spring_controller]: [ROS 2 Spring Control] ValveCommand Received (0s)
[INFO] [1660957510.409397573] [spring_controller]: Valve closed after (2.53s)

should turn it off

commands that aren't implemented should let the user know:

$ tether
tether not currently implemented

Signed-off-by: Michael Anderson <[email protected]>
Signed-off-by: Michael Anderson <[email protected]>
Signed-off-by: Michael Anderson <[email protected]>
Signed-off-by: Michael Anderson <[email protected]>
@andermi andermi changed the base branch from main to andermi/reorg August 20, 2022 00:03
Signed-off-by: Michael Anderson <[email protected]>
Signed-off-by: Michael Anderson <[email protected]>
@andermi
Copy link
Collaborator Author

andermi commented Aug 20, 2022

Also todo (in buoy_sim osrf/mbari_wec_gz#85):

  • add test for command busy (trying to run pump and valve at the same time)

Signed-off-by: Michael Anderson <[email protected]>
Base automatically changed from andermi/reorg to main August 22, 2022 20:18
@andermi andermi marked this pull request as ready for review August 22, 2022 22:19
ln -sf $SCRIPT_DIR/pbcmd $ALIAS_INSTALL_DIR/tf_SetStateMachine
ln -sf $SCRIPT_DIR/pbcmd $ALIAS_INSTALL_DIR/tf_SetCurrLim
ln -sf $SCRIPT_DIR/pbcmd $ALIAS_INSTALL_DIR/tf_WatchDog
ln -sf $SCRIPT_DIR/pbcmd $ALIAS_INSTALL_DIR/tf_Reset
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably better to automate this?

for directory in $ALIAS_INSTALL_DIR; do
    ln -sf $SCRIPT_DIR/pbcmd $ALIAS_INSTALL_DIR/$directory
done

Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why this shouldn't be installed with the package itself instead of running the script manually?

Copy link
Collaborator Author

@andermi andermi Aug 23, 2022

Choose a reason for hiding this comment

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

I wasn't sure if everybody wanted to install it. And I wasn't sure about having a sudo blocking the build

Copy link
Contributor

Choose a reason for hiding this comment

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

We could have a flag to integrate this. Hmm, I'm not sure about the sudo too.
@mjcarroll thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

~/.local/bin doesn't exist by default, but if you create the directory, it will be added to $PATH automatically in Ubuntu. So, the install script could create the directory, and then create the symlinks locally so it wouldn't require sudo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

see the latest commit... I believe I did it!

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome! Tested, works out of the box. But system doesn't recognize pbcmd directly, had to use .local/bin/pbcmd

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Try in a new terminal.
$ echo $PATH
Should also show ~/.local/bin

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, source ~/.profile should update $PATH to include ~/.local/bin after the folder is created buy the install script

Copy link
Contributor

@quarkytale quarkytale left a comment

Choose a reason for hiding this comment

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

Cool tool, tried them all, works for me! Good to go after comments on installation.

@andermi andermi merged commit c531d98 into main Aug 24, 2022
@andermi andermi deleted the andermi/replicate_pbcmd branch August 24, 2022 00:17
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.

2 participants