FluxGrip: System Test

image

Last week we ran a full system test of the FluxGrip (yes, the name has changed). The test was a success:

In this blog, I will offer a detailed description of how we conducted the test, in case some of our customers want to replicate it.

The test went as follows:

  1. Put FluxGrip into a drop test rig (coat rack)
  2. Connect FluxGrip to laptop using CanFace
  3. On laptop (Ubuntu, this won’t work on macOS/Windows):
  • Create a fluxgrip folder
mkdir ~/fluxgrip
pip install yakut
  • Clone all necessary DSDL
cd ~/fluxgrip
git clone https://github.com/OpenCyphal/public_regulated_data_types/ # Standard Cyphal DSDL types
git clone https://github.com/Zubax/zubax_dsdl/ # Zubax-specific DSDL types
  • Clone setup_slcan and configure SocketCAN interface
cd ~/fluxgrip
# The following command will download the setup_slcan script:
wget https://gist.github.com/pavel-kirienko/32e395683e8b7f49e71413aebf5e1a89/raw/f08e426e6c963a5d68868084cd2fab2a469bf76f/setup_slcan
chmod +x ./setup_slcan
# Optional:
# (script will be accessible from anywhere, not just ~/fluxgrip)
# sudo mv ./setup_slcan /usr/local/bin
# This will set up the SocketCAN interface:
sudo setup_slcan --remove-all -r /dev/serial/by-id/usb-*Zubax*Babel*

The SocketCAN interfaces appear as follows:

(I have 2, since I’m using CF2)

  • Create an environment setup script: ~/fluxgrip/env.sh
export CYPHAL_PATH="$HOME/fluxgrip/zubax_dsdl:$HOME/fluxgrip/public_regulated_data_types"
export UAVCAN__CAN__IFACE='socketcan:slcan0'
export UAVCAN__CAN__MTU=8
export UAVCAN__NODE__ID=$(yakut accommodate)

echo "Auto-selected node-ID for this session: $UAVCAN__NODE__ID"
  • Source the environment file:
source ~/fluxgrip/env.sh
  • Run yakut monitor --plug-and-play ./pnp, we should see our FluxGrip appear as one of the Cyphal nodes:

Assume the ports are configured as follows:
1000 → magnet command topic
1001 → magnet state feedback topic

  • Open another terminal window, source the env script from before and subscribe to the Feedback from FluxGrip:
source ~/fluxgrip/env.sh
yakut sub 1001:zubax.fluxgrip.Feedback --redraw +M

It should appear as follows:

  • Now we’re ready to start controlling the magnet:
source ~/fluxgrip/env.sh
yakut pub -N1 1000:uavcan.primitive.scalar.integer8 0 # Turn FluxGrip off
yakut pub -N1 1000:uavcan.primitive.scalar.integer8 1 # Turn FluxGrip on
yakut pub -N1 1000:uavcan.primitive.scalar.integer8 2 # Force FluxGrip on

The last command (Force) is meant to be used when you want to execute a magnetization cycle, regardless whether it is currently magnetized or not. (If FluxGrip is magnetized it will ignore an ON command.)

  • After you’ve turned on the magnet one time, the Feedback window should show the following:

The “1” indicates that the magnet has been turned on 1 time (makes sense).

If you have any questions, feel free to post them below.

1 Like

:blue_square: Windows instructions

Git installation

git --version

Should show up as follows:

Python installation

python --version

Update environment variables

The above might not work (it will say that “Python command was not found”). To address this, you will need to add the path to where Python is installed, in my case:

For detailed instructions on how to do this, see this tutorial. I recommend updating the Path of System variables, that way you can’t go wrong. (User variables are user-specific.)

Tip: If you’re not sure whether your Path variable has been set correctly, open Powershell and type $Env:Path.

Yakut installation

  • Open PowerShell
  • Verify that pip is installed (this should be part of your Python installation from above):
pip --version
  • Install Yakut using pip (from PowerShell)
pip install yakut
  • Check if installed correctly:
yakut --version

Setup

  • Open PowerShell

  • Create a fluxgrip folder in your home directory

New-Item -Path "$HOME\fluxgrip" -ItemType Directory
  • Clone all necessary DSDL files
Set-Location "$HOME\fluxgrip"
git clone https://github.com/OpenCyphal/public_regulated_data_types.git
git clone https://github.com/Zubax/zubax_dsdl.git
  • Create an environment variables setup script called env.ps1 in folder fluxgrip

  • Open env.ps1 and copy the following:

Make sure to update the COM port value!!!

# Set the CYPHAL_PATH environment variable
$env:CYPHAL_PATH = "$HOME\fluxgrip\zubax_dsdl;$HOME\fluxgrip\public_regulated_data_types"
# Set the UAVCAN__CAN__IFACE environment variable
$env:UAVCAN__CAN__IFACE = 'slcan:COM18' # UPDATE THIS VALUE!!!
# Set the UAVCAN__CAN__MTU environment variable
$env:UAVCAN__CAN__MTU = 8
$env:UAVCAN__CAN__BITRATE = "1000000 1000000"
# Set the UAVCAN__NODE__ID environment variable by running `yakut accommodate` and capturing the output
$env:UAVCAN__NODE__ID = & yakut accommodate

# Echo the selected node ID for this session
Write-Output "Auto-selected node-ID for this session: $env:UAVCAN__NODE__ID"

The value for UAVCAN__CAN__IFACE can be found after connecting your CanFace to the PC and consulting the device manager:

(Pro tip: connect/disconnect the CanFace to find out which of the COM ports is the correct one.)

To run the following commands, you’ll need to run Powershell as Administrator! (Open Powershell with right mouse click, and select “Run as Administrator”)

To allow us to run the following commands, we’ll need to:

Set-Location "$HOME\fluxgrip"
Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Then, source the environment file you’ve just created:

.\env.ps1

The result should look like this:

In the same window, we use yakut monitor --plug-and-play .\pnp. If you’ve done everything correctly, it should look like this:

(If you don’t see FluxGrip show up in the list, try to re-connect it to the CanFace)

If you’re able to see fluxgrip in the list of devices that shows up, you can now start sending command to turn it on/off.
First quit the monitoring process (CTRL+C) and then (same window) type the following command

yakut pub -N1 1000:uavcan.primitive.scalar.integer8 1 # This will turn the magnet ON
yakut pub -N1 1000:uavcan.primitive.scalar.integer8 0 # This will turn the magnet OFF

Note: the downside of working with Windows is that we’re not able to both monitor the nodes on the network, as well as subscribe to Feedback from the magnet, and send commands (since only 1 process can access the serial).

If you have any further question, feel free to post them below.