### Example: Configure 3D Printer Style Min Endstop Source: https://github.com/odriverobotics/odrive/blob/master/docs/endstops.rst Example configuration for a minimum endstop using GPIO 5, set as active high, with an offset of -0.25 turns. This setup is typical for 3D printer homing. ```Python .config.gpio5_mode = GPIO_MODE_DIGITAL ..min_endstop.config.gpio_num = 5 ..min_endstop.config.is_active_high = False ..min_endstop.config.offset = -0.25 ``` -------------------------------- ### Install project dependencies Source: https://github.com/odriverobotics/odrive/blob/master/GUI/README.md Installs all necessary Node.js dependencies for the project. Run this command in the project's root directory. ```bash npm install ``` -------------------------------- ### Verify Development Tool Installation Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Run these commands to check if the necessary development tools are correctly installed and accessible in your PATH. ```Bash arm-none-eabi-gcc --version arm-none-eabi-gdb --version openocd --version # should be 0.10.0 or later tup --version # should be 0.7.5 or later python --version # should be 3.7 or later ``` -------------------------------- ### Install Teensyduino Prerequisites on Raspberry Pi Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Install necessary libraries on the Raspberry Pi for setting up the Teensyduino development environment. ```Bash sudo apt-get install libfontconfig libxft2 libusb-dev ``` -------------------------------- ### Example ODrive CAN Configuration Source: https://github.com/odriverobotics/odrive/blob/master/docs/can-guide.rst An example demonstrating how to set the node IDs for axis 0 and axis 1, and configure the CAN bus baud rate to 250 kbps. ```Python odrv0.axis0.config.can.node_id = 0 odrv0.axis1.config.can.node_id = 1 odrv0.can.config.baud_rate = 250000 ``` -------------------------------- ### ASCII Protocol Connection Examples Source: https://context7.com/odriverobotics/odrive/llms.txt Shows how to connect to the ODrive using its ASCII protocol over UART or USB serial. Examples are provided for Linux/macOS using `screen` and for Windows using PuTTY. ```bash # Connect via serial terminal (Linux/macOS) screen /dev/ttyACM0 115200 ``` ```bash # Connect via serial terminal (Windows) # Use PuTTY with appropriate COM port at 115200 baud ``` -------------------------------- ### Start development server with hot-reloading Source: https://github.com/odriverobotics/odrive/blob/master/GUI/README.md Compiles the project and starts a development server that automatically reloads on code changes. Ideal for active development. ```bash npm run serve ``` -------------------------------- ### Install Homebrew on macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst Run this command to install Homebrew, a package manager for macOS, if you don't already have it. ```bash /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ``` -------------------------------- ### Download Teensyduino Installer on Raspberry Pi Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Download the Teensyduino installer script onto the Raspberry Pi. ```Bash wget https://www.pjrc.com/teensy/td_153/TeensyduinoInstall.linuxarm ``` -------------------------------- ### Install Teensyduino Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Installs Teensyduino to a specified directory. This command assumes the installer script is in your current directory. ```Bash ./TeensyduinoInstall.linuxarm --dir=arduino-1.8.13 ``` -------------------------------- ### OpenOCD Success Output Example Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Example output indicating a successful firmware write operation using OpenOCD. This confirms that the firmware has been flashed correctly. ```Bash wrote 262144 bytes from file ODriveFirmware_v3.4-24V.elf in 10.194110s (25.113 KiB/s) ``` -------------------------------- ### Install dfu-util on Linux Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Installs the dfu-util utility required for flashing firmware via USB on Linux systems. Ensure you have sudo privileges. ```Bash sudo apt install dfu-util ``` -------------------------------- ### Install odrivetool on Windows Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst Use this command to install or upgrade odrivetool on Windows after installing Python 3. ```bash pip install --upgrade odrive ``` -------------------------------- ### Install and Compile OpenOCD from Source Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Install necessary dependencies and compile the latest version of OpenOCD from source to support newer microcontrollers like STM32F722. ```Bash sudo apt-get install libtool libusb-1.0 git clone https://git.code.sf.net/p/openocd/code openocd cd openocd/ ./bootstrap ./configure --enable-stlink make sudo make install ``` -------------------------------- ### Install Python 3 and pip on Linux (Ubuntu/Raspbian) Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst Install Python 3 and its package installer pip on Ubuntu or Raspbian systems. ```bash sudo apt install python3 python3-pip ``` -------------------------------- ### Install dfu-util on macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Installs the dfu-util utility using Homebrew for flashing firmware via USB on macOS. If using MacPorts, an alternative command is provided. ```Bash brew install dfu-util ``` ```Bash sudo port install dfu-util ``` -------------------------------- ### Prepare for GDB Debugging Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Run this command in the Firmware directory to reset and halt the program at the start, preparing for debugging with GDB. This allows setting breakpoints and stepping through the code. ```bash make gdb ``` -------------------------------- ### Install odrivetool on macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst Install or upgrade odrivetool using pip3 after ensuring Python 3 and necessary dependencies are installed. ```bash pip3 install --upgrade odrive ``` -------------------------------- ### Install odrivetool with sudo on macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst If you encounter permission errors during installation, run the odrivetool installation command with sudo. ```bash sudo pip3 install --upgrade odrive ``` -------------------------------- ### Run ODrive Host Setup Script Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Executes the ODrive test runner script with the '--setup-host' argument. This command is intended to be run after every reboot to prepare the host system for testing. ```Bash sudo -E ipython3 --pdb test_runner.py -- --setup-host ``` -------------------------------- ### Install Python on macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst Install Python 3 using Homebrew. If Python 2 is already installed, this command will upgrade it to Python 3. ```bash brew install python ``` -------------------------------- ### Install a specific module with sudo on macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst If the odrivetool installation fails due to missing dependencies, install the specific module using pip3 with sudo and retry. ```bash sudo pip3 install module_name ``` -------------------------------- ### Install ODrive Testing Prerequisites on Raspberry Pi Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Install essential Python packages and development tools required for ODrive automated testing on a Raspberry Pi. This includes libraries for IPython, YAML, Jinja2, USB, serial communication, CAN, SciPy, Matplotlib, and IPDB, as well as Git and OpenOCD. Optionally, install the ARM GCC compiler for firmware compilation. ```Bash sudo apt-get install ipython3 python3-appdirs python3-yaml python3-jinja2 python3-usb python3-serial python3-can python3-scipy python3-matplotlib python3-ipdb git openocd # Optionally, to be able to compile the firmware: sudo apt-get install gcc-arm-none-eabi ``` -------------------------------- ### Setup ODrive udev Rules Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Runs a script to set up udev rules for ODrive devices. This is typically done from within the ODrive tools directory. ```Bash sudo ../../odrivetool udev-setup ``` -------------------------------- ### Start odrivetool and Inspect Bus Voltage Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst Launches the ODrive control utility and shows how to inspect the main supply voltage. Ensure your ODrive is connected. ```iPython ODrive control utility v0.5.4 Please connect your ODrive. Type help() for help. Connected to ODrive 306A396A3235 as odrv0 In [1]: odrv0.vbus_voltage Out[1]: 11.97055721282959 ``` -------------------------------- ### Install Development Tools (Arch Linux) Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Installs the ARM GCC toolchain, GDB, Git LFS, Tup, and Python packages for Arch Linux. ```Bash sudo pacman -S arm-none-eabi-gcc arm-none-eabi-binutils ``` ```Bash sudo pacman -S arm-none-eabi-gdb ``` ```Bash sudo pacman -S git-lfs ``` ```Bash sudo pacman -S tup ``` ```Bash sudo pacman -S python python-yaml python-jinja python-jsonschema ``` -------------------------------- ### Install Python Packages (Windows) Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Installs required Python packages for ODrive development on Windows using pip. ```Bash pip install PyYAML Jinja2 jsonschema ``` -------------------------------- ### Install Development Tools (Mac) Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Installs ARM GCC, Tup, OpenOCD, Git LFS, and Python packages on macOS using Homebrew and pip. ```Bash brew install armmbed/formulae/arm-none-eabi-gcc ``` ```Bash brew install --cask osxfuse && brew install tup ``` ```Bash brew install openocd ``` ```Bash brew install git-lfs ``` ```Bash pip3 install PyYAML Jinja2 jsonschema ``` -------------------------------- ### Install GCC ARM Embedded (Linux Ubuntu < 20.04) Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Installs the ARM GCC compiler and related tools on older Ubuntu versions using a PPA. ```Bash sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa ``` ```Bash sudo apt-get update ``` ```Bash sudo apt-get install gcc-arm-embedded ``` ```Bash sudo apt-get install openocd ``` ```Bash sudo apt-get install git-lfs ``` ```Bash sudo add-apt-repository ppa:jonathonf/tup && sudo apt-get update && sudo apt-get install tup ``` ```Bash sudo apt-get install python3 python3-yaml python3-jinja2 python3-jsonschema ``` -------------------------------- ### Start Liveplotter Tool Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Launches the ODrive liveplotter tool from the command line. This tool visualizes ODrive parameters in real time. Ensure no other instances are running. ```Bash odrivetool liveplotter ``` -------------------------------- ### ODrive Position Control Example Source: https://context7.com/odriverobotics/odrive/llms.txt Implement position control to command the motor to specific angular positions. This example configures velocity and current limits, enters closed-loop control, and sets the controller to position mode with passthrough input. It demonstrates moving to a direct position setpoint, then performing sinusoidal motion. Finally, it reads and prints the current position and velocity estimates before returning to idle. ```python import odrive from odrive.enums import * import time import math odrv0 = odrive.find_any() # Set velocity and current limits odrv0.axis0.controller.config.vel_limit = 10 # turns/s odrv0.axis0.motor.config.current_lim = 20 # Amps # Enter closed-loop control odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL # Direct position control (units: turns) odrv0.axis0.controller.config.control_mode = CONTROL_MODE_POSITION_CONTROL odrv0.axis0.controller.config.input_mode = INPUT_MODE_PASSTHROUGH # Move to position 2.0 turns odrv0.axis0.controller.input_pos = 2.0 time.sleep(1) # Move with velocity and torque feed-forward # input_pos, vel_ff (turns/s), torque_ff (Nm) odrv0.axis0.controller.input_pos = 0.0 # Read current position and velocity print(f"Position: {odrv0.axis0.encoder.pos_estimate:.3f} turns") print(f"Velocity: {odrv0.axis0.encoder.vel_estimate:.3f} turns/s") # Sinusoidal motion example t0 = time.monotonic() for _ in range(500): setpoint = 2.0 * math.sin((time.monotonic() - t0) * 2) odrv0.axis0.controller.input_pos = setpoint time.sleep(0.01) # Return to idle odrv0.axis0.requested_state = AXIS_STATE_IDLE ``` -------------------------------- ### Install C/C++ Extension for VSCode Source: https://github.com/odriverobotics/odrive/blob/master/docs/configuring-vscode.rst Install the C/C++ extension for VSCode. This extension provides core C/C++ language support. ```shell ext install ms-vscode.cpptools ``` -------------------------------- ### Initialize and Discover ODrive Devices Source: https://github.com/odriverobotics/odrive/blob/master/GUI/fibre-js/multidevice_example.html Initializes the libfibre library, starts discovering ODrive devices using a specific USB filter, and sets up UI elements for connection and status display. The discovery process calls `onFoundObject` for each discovered device. ```javascript const filter = 'usb:idVendor=0x1209,idProduct=0x0D32,bInterfaceClass=0,bInterfaceSubClass=1,bInterfaceProtocol=0'; let showStatus = (status) => document.getElementById("textcontent").innerHTML = status; var connectedObjects = []; displayLoop = async () => { while (connectedObjects.length) { console.log(connectedObjects.length); let results = await Promise.all(connectedObjects.map(async (dev) => await dev.vbus_voltage.read())); showStatus('connected to ' + results.length + ' devices' + results.map((x) => "
vbus_voltage: " + x + "V").join()); await new Promise((resolve) => setTimeout(resolve, 100)); } showStatus("no devices connected"); } let onFoundObject = async (obj) => { connectedObjects.push(obj); obj._onLost.then(() => connectedObjects.splice(connectedObjects.indexOf(obj), 1)); if (connectedObjects.length == 1) { displayLoop(); } } fibreOpen().then((libfibre) => { libfibre.startDiscovery(filter, onFoundObject); document.getElementById("connectBtn").onclick = libfibre.usbDiscoverer.showDialog; document.getElementById("connectBtn").removeAttribute('disabled'); showStatus("loaded WASM libfibre version " + libfibre.version.major + "." + libfibre.version.minor + "." + libfibre.version.patch); }); ``` -------------------------------- ### Copy Arduino to System Directory Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Copies the installed Arduino IDE to the system's share directory for system-wide access. Requires superuser privileges. ```Bash sudo cp -R arduino-1.8.13 /usr/share/arduino ``` -------------------------------- ### Install OpenOCD on Linux Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Installs OpenOCD, a utility for programming and debugging embedded devices, on Linux systems. This is part of the STLink flashing procedure. ```Bash sudo apt-get install openocd ``` -------------------------------- ### Live Plotting with ODrive Utils Source: https://context7.com/odriverobotics/odrive/llms.txt Visualize ODrive encoder and controller setpoints in real-time using `start_liveplotter`. Ensure matplotlib is installed. ```python import odrive from odrive.utils import start_liveplotter, BulkCapture, step_and_plot from odrive.enums import * odrv0 = odrive.find_any() odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL # Live plotting (opens matplotlib window) cancel_token = start_liveplotter(lambda: [ odrv0.axis0.encoder.pos_estimate, odrv0.axis0.controller.pos_setpoint ]) # Close plot window to stop, or: cancel_token.set() ``` -------------------------------- ### Make Teensyduino Executable Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Grants execute permissions to the Teensyduino installer script. Ensure this script is in your current directory. ```Bash chmod +x TeensyduinoInstall.linuxarm ``` -------------------------------- ### Install OpenOCD on macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Installs OpenOCD using Homebrew on macOS. This is required for flashing firmware using an STLink programmer. ```Bash brew install openocd ``` -------------------------------- ### Install GCC ARM Embedded (Linux Ubuntu >= 20.04) Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Installs the ARM GCC compiler and related tools on newer Ubuntu versions using apt. ```Bash sudo apt install gcc-arm-none-eabi ``` ```Bash sudo apt install openocd ``` ```Bash sudo apt install git-lfs ``` ```Bash sudo apt install tup ``` ```Bash sudo apt install python3 python3-yaml python3-jinja2 python3-jsonschema ``` -------------------------------- ### Initialize and Discover ODrives with fibre-js Source: https://github.com/odriverobotics/odrive/blob/master/GUI/fibre-js/example.html This code initializes the fibre-js library and starts a discovery process for ODrives. It filters for specific USB IDs and sets up a callback function to handle found devices. The `startDiscovery` function requires a filter string and a callback. The `usbDiscoverer.showDialog` can be used to trigger a device selection dialog. ```javascript import { fibreOpen } from './fibre.js'; fibreOpen().then((libfibre) => { const filter = 'usb:idVendor=0x1209,idProduct=0x0D32,bInterfaceClass=0,bInterfaceSubClass=1,bInterfaceProtocol=0'; const onFoundObject = async (obj) => { console.log("found an object!", obj); while (true) { document.getElementById("statusText").innerHTML = "vbus_voltage: " + (await obj.vbus_voltage.read()); await new Promise((resolve) => setTimeout(resolve, 100)); } } libfibre.startDiscovery(filter, onFoundObject); document.getElementById("connectBtn").onclick = libfibre.usbDiscoverer.showDialog; document.getElementById("connectBtn").removeAttribute('disabled'); }); ``` -------------------------------- ### Download Arduino IDE for Teensyduino on Raspberry Pi Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Download the Arduino IDE, a prerequisite for installing Teensyduino, onto the Raspberry Pi. ```Bash wget https://downloads.arduino.cc/arduino-1.8.13-linuxarm.tar.xz ``` -------------------------------- ### Install ARM GCC for macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Installs the GNU Arm Embedded Toolchain using Homebrew, which is necessary for converting firmware binaries on macOS. ```Bash brew install --cask gcc-arm-embedded ``` -------------------------------- ### Start Liveplotter for Position Feedback Source: https://github.com/odriverobotics/odrive/blob/master/docs/control.rst Initiate the liveplotter tool to visualize the motor's position estimate against the commanded position setpoint. Requires ODrive tool. ```python start_liveplotter(lambda:[odrv0.axis0.encoder.pos_estimate, odrv0.axis0.controller.pos_setpoint]) ``` -------------------------------- ### Compile libfibre on Ubuntu Source: https://github.com/odriverobotics/odrive/blob/master/Firmware/fibre-cpp/README.md Compile libfibre on Ubuntu by installing the libusb development package and running make. ```bash sudo apt-get install libusb-1.0-0-dev make ``` -------------------------------- ### CAN DBC Example Script Source: https://github.com/odriverobotics/odrive/blob/master/docs/can-guide.rst An example Python script demonstrating the usage of encode_message() and decode_message() with a CAN DBC file. This is the recommended method for data serialization. ```python can_dbc_example.py ``` -------------------------------- ### Install Teensy Loader CLI Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Copies the compiled Teensy Loader executable to the system's bin directory for global access. Requires superuser privileges. ```Bash sudo cp teensy_loader_cli /usr/bin/ ``` -------------------------------- ### Configure Automatic Startup for Closed-Loop Control Source: https://github.com/odriverobotics/odrive/blob/master/docs/hoverboard.rst Enable automatic startup for closed-loop control on both axes and save the configuration. This allows the ODrive to start in closed-loop control mode after booting without external intervention. ```Bash odrv0.axis0.config.startup_closed_loop_control = True odrv0.axis1.config.startup_closed_loop_control = True odrv0.save_configuration() odrv0.reboot() ``` -------------------------------- ### Install Cortex-Debug Device Support Pack for STM32F4 Source: https://github.com/odriverobotics/odrive/blob/master/docs/configuring-vscode.rst Install the device support pack for STM32F4 microcontrollers within the Cortex-Debug extension. This enables specific debugging features for STM32F4 devices. ```shell ext install marus25.cortex-debug-dp-stm32f4 ``` -------------------------------- ### Compile libfibre on macOS Source: https://github.com/odriverobotics/odrive/blob/master/Firmware/fibre-cpp/README.md Compile libfibre on macOS using Homebrew to install libusb and then running make. ```bash brew install libusb make ``` -------------------------------- ### Start Liveplotter from odrivetool Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Initiate the liveplotter directly from the interactive odrivetool prompt to plot variables while interacting with the ODrive. Multiple parameters can be plotted by separating them with commas within the square brackets. ```ipython start_liveplotter(lambda: [odrv0.axis0.encoder.pos_estimate]) ``` -------------------------------- ### ODrive Firmware Update Process Output Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Example output during an ODrive firmware update process, showing connection, version checks, download, and flashing status. ```iPython ODrive control utility v0.3.7.dev Waiting for ODrive... Found ODrive 308039673235 (v3.5-24V) with firmware v0.3.7-dev Checking online for newest firmware... found v0.3.7 Downloading firmware... Putting device 308039673235 into DFU mode... Erasing... done Flashing... done Verifying... done ``` -------------------------------- ### Find and Print ODrive Bus Voltage (Python) Source: https://github.com/odriverobotics/odrive/blob/master/docs/native-protocol.rst This Python snippet demonstrates how to find an ODrive device and print its bus voltage. Ensure the 'odrive' library is installed. ```Python import odrive odrv0 = odrive.find_any() print(str(odrv0.vbus_voltage)) ``` -------------------------------- ### Serve Electron version of GUI Source: https://github.com/odriverobotics/odrive/blob/master/GUI/README.md Launches the GUI as a desktop application using Electron, suitable for testing the packaged version during development. ```bash npm run electron:serve ``` -------------------------------- ### Manually add udev rules on Linux Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst If automatic udev rule installation fails, manually add the rules for ODRI VE USB devices to ensure proper communication. ```bash echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="0d[0-9][0-9]", MODE="0666"' | sudo tee /etc/udev/rules.d/91-odrive.rules sudo udevadm control --reload-rules sudo udevadm trigger ``` -------------------------------- ### Initiate Motor Calibration Source: https://github.com/odriverobotics/odrive/blob/master/docs/hoverboard.rst Set the axis state to start the motor calibration process. Ensure the motor is free to move before initiating this step. ```bash odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION ``` -------------------------------- ### Checkout STM32CubeMX-start Branch Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Use this command to switch to the STM32CubeMX-start branch for code regeneration. ```bash git checkout STM32CubeMX-start ``` -------------------------------- ### Install odrivetool without dependencies on macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst Use this command to install odrivetool without its dependencies if you are experiencing installation issues. Be aware this may lead to runtime errors. ```bash sudo pip3 install odrive --no-deps ``` -------------------------------- ### Map RC PWM Inputs to Velocity Setpoints Source: https://github.com/odriverobotics/odrive/blob/master/docs/hoverboard.rst Configure GPIO pins 3 and 4 to map the full RC stick range to velocity setpoints for axis 0 and axis 1 respectively. This setup is necessary before saving the configuration and rebooting. ```Bash odrv0.config.gpio3_pwm_mapping.min = -2 odrv0.config.gpio3_pwm_mapping.max = 2 odrv0.config.gpio3_pwm_mapping.endpoint = odrv0.axis0.controller._input_vel_property odrv0.config.gpio4_pwm_mapping.min = -2 odrv0.config.gpio4_pwm_mapping.max = 2 odrv0.config.gpio4_pwm_mapping.endpoint = odrv0.axis1.controller._input_vel_property ``` -------------------------------- ### Install libusb on macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst Install libusb, which is required for odrivetool to communicate with the ODRI VE hardware. ```bash brew install libusb ``` -------------------------------- ### Run GUI from source with local dependencies Source: https://github.com/odriverobotics/odrive/blob/master/GUI/README.md Launches the GUI using local dependencies from the repository, useful for testing unreleased changes. The path argument specifies the location of local tools. ```bash npm run electron:serve -- ../tools/ ``` -------------------------------- ### Trapezoidal Trajectory Control Setup and Execution Source: https://context7.com/odriverobotics/odrive/llms.txt Sets up and executes point-to-point motion using trapezoidal trajectory control. Configure acceleration, deceleration, cruise velocity, and optional inertia. Safety limits should be set slightly higher than trajectory limits. The `trajectory_done` flag can be polled to wait for move completion. ```python import odrive from odrive.enums import * import time odrv0 = odrive.find_any() # Configure trajectory planner odrv0.axis0.trap_traj.config.vel_limit = 5.0 # turns/s cruise speed odrv0.axis0.trap_traj.config.accel_limit = 2.0 # turns/s^2 odrv0.axis0.trap_traj.config.decel_limit = 2.0 # turns/s^2 odrv0.axis0.controller.config.inertia = 0.0 # Optional: improves response # Set safety limits slightly higher than trajectory limits odrv0.axis0.controller.config.vel_limit = 6.0 odrv0.axis0.motor.config.current_lim = 20 # Enable trajectory mode odrv0.axis0.controller.config.control_mode = CONTROL_MODE_POSITION_CONTROL odrv0.axis0.controller.config.input_mode = INPUT_MODE_TRAP_TRAJ odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL # Execute absolute move to position 10 turns odrv0.axis0.controller.input_pos = 10.0 # Wait for move to complete while not odrv0.axis0.controller.trajectory_done: time.sleep(0.1) print("Move complete!") # Execute incremental move (+5 turns from current goal) odrv0.axis0.controller.move_incremental(5.0, True) # from_goal_point=True # Execute incremental move (+2 turns from current actual position) odrv0.axis0.controller.move_incremental(2.0, False) # from_goal_point=False odrv0.axis0.requested_state = AXIS_STATE_IDLE ``` -------------------------------- ### Reading Object Properties Periodically Source: https://github.com/odriverobotics/odrive/blob/master/GUI/fibre-js/README.md This example demonstrates how to continuously read a property (vbus_voltage) from a discovered object and update the UI every 100ms. It requires the object to have the specified readable property. ```javascript while (true) { document.getElementById("statusText").innerHTML = "vbus_voltage: " + (await obj.vbus_voltage.read()); await new Promise((resolve) => setTimeout(resolve, 100)); } ``` -------------------------------- ### Configure Startup Procedures Source: https://github.com/odriverobotics/odrive/blob/master/docs/commands.rst Set startup procedures to True to enable them. The ODrive will execute enabled startup actions in a specific order. ```python .config.startup_motor_calibration = True ``` ```python .config.startup_encoder_index_search = True ``` ```python .config.startup_encoder_offset_calibration = True ``` ```python .config.startup_closed_loop_control = True ``` -------------------------------- ### Loading and Initializing fibre-js Source: https://github.com/odriverobotics/odrive/blob/master/GUI/fibre-js/README.md This script tag demonstrates how to import and initialize fibre-js, preparing it for use after the library is loaded. ```javascript import { fibreOpen } from './fibre.js'; fibreOpen().then((libfibre) => { // fibre-js is ready to use! }); ``` -------------------------------- ### Install Cortex-Debug Extension for VSCode Source: https://github.com/odriverobotics/odrive/blob/master/docs/configuring-vscode.rst Install the Cortex-Debug extension for VSCode. This extension is essential for debugging ARM Cortex projects. ```shell ext install marus25.cortex-debug ``` -------------------------------- ### Enter Teensy Loader Directory Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Navigates into the cloned teensy_loader_cli directory to prepare for compilation. Use 'popd' to return to the previous directory. ```Bash pushd teensy_loader_cli ``` -------------------------------- ### Checkout STM32CubeMX-end Branch for Rebasing Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Switch to the STM32CubeMX-end branch to prepare for rebasing changes from STM32CubeMX-start. ```bash git checkout STM32CubeMX-end ``` -------------------------------- ### Configure Step/Dir Pins and Enable Source: https://github.com/odriverobotics/odrive/blob/master/docs/step-direction.rst Assign specific GPIO pins to be used for step and direction signals, and then enable the step/dir control mode for the axis. ```python .config.step_gpio_pin = 7 .config.dir_gpio_pin = 8 .config.enable_step_dir = True ``` -------------------------------- ### Initiate Encoder Index Search Source: https://github.com/odriverobotics/odrive/blob/master/docs/encoders.rst After a reboot and with pre-calibration enabled, initiate the encoder index search. This should complete without errors if calibration was successful. ```Python .requested_state = AXIS_STATE_ENCODER_INDEX_SEARCH ``` -------------------------------- ### Enable Homing at Startup Source: https://github.com/odriverobotics/odrive/blob/master/docs/endstops.rst Configure the ODrive to automatically initiate the homing sequence immediately after startup. This ensures the axis is homed before any other operations. ```Python ..config.startup_homing = True ``` -------------------------------- ### Flash Firmware using dfu-util on Linux Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Flashes the compiled ODrive firmware binary to the device using dfu-util. This command requires the firmware file to be in the 'build' directory and the ODrive to be in DFU mode. ```Bash sudo dfu-util -a 0 -s 0x08000000 -D build/ODriveFirmware.bin ``` -------------------------------- ### Install PhantomJS for ARM builds Source: https://github.com/odriverobotics/odrive/blob/master/GUI/README.md Installs PhantomJS, a required dependency for building the Electron app on ARM platforms like Raspberry Pi. This command is typically run on Debian-based systems. ```bash sudo apt install phantomjs ``` -------------------------------- ### ODrive Error Code Example Source: https://github.com/odriverobotics/odrive/blob/master/docs/troubleshooting.rst This is an example of the output you might see when dump_errors() encounters an AttributeError due to a version mismatch between odrivetool and the ODrive firmware. It shows the traceback leading to the error. ```python In [1]: dump_errors(odrv0) axis0 --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) File "~/.local/lib/python3.6/site-packages/fibre/shell.py", line 78, in dump_errors(odrv0) File "~/.local/lib/python3.6/site-packages/odrive/utils.py", line 80, in dump_errors ('fet_thermistor', axis.fet_thermistor, {k: v for k, v in odrive.enums.__dict__ .items() if k.startswith("THERMISTOR_CURRENT_LIMITER_ERROR")}), File "~/.local/lib/python3.6/site-packages/fibre/remote_object.py", line 245, in __getattribute__ return object.__getattribute__(self, name) AttributeError: 'RemoteObject' object has no attribute 'fet_thermistor' ``` -------------------------------- ### Rebase STM32CubeMX-end onto STM32CubeMX-start Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Apply changes from the STM32CubeMX-start branch onto the STM32CubeMX-end branch. Resolve any conflicts that occur. ```bash git rebase STM32CubeMX-start ``` -------------------------------- ### Start Motor in Closed Loop Control Source: https://github.com/odriverobotics/odrive/blob/master/docs/commands.rst Initiates closed-loop control for the motor axis after sensorless mode has been configured. ```python odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL ``` -------------------------------- ### Flash Firmware with odrivetool Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Use this command after connecting the ODrive via USB and powering it up to flash the compiled firmware. Refer to `odrivetool dfu` documentation for more details. ```bash odrivetool dfu ``` -------------------------------- ### OpenOCD Flashing Output with LIBUSB_ERROR_IO Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Example output from OpenOCD indicating a LIBUSB_ERROR_IO when attempting to flash the ODrive using STLink/v2. ```text Open On-Chip Debugger 0.10.0 Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "hla_swd". To override use 'transport select '. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD adapter speed: 2000 kHz adapter_nsrst_delay: 100 none separate Info : Unable to match requested speed 2000 kHz, using 1800 kHz Info : Unable to match requested speed 2000 kHz, using 1800 kHz Info : clock speed 1800 kHz Error: libusb_open() failed with LIBUSB_ERROR_IO Error: open failed in procedure 'init' in procedure 'ocd_bouncer' ``` -------------------------------- ### Create ODrive Test Directory Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Creates a directory for ODrive testing and sets the current user as the owner. Requires superuser privileges for creation. ```Bash sudo mkdir /opt/odrivetest && sudo chown $USER /opt/odrivetest ``` -------------------------------- ### Upgrade Python on macOS Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst If you encounter an error indicating Python 2.7 is already installed, use this command to upgrade to Python 3. ```bash brew upgrade python ``` -------------------------------- ### Create Arduino Symbolic Link Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Creates a symbolic link for the Arduino executable in the system's bin directory, allowing it to be run from anywhere. Requires superuser privileges. ```Bash sudo ln -s /usr/share/arduino/arduino /usr/bin/arduino ``` -------------------------------- ### OpenOCD Flashing Output with Target Identification Warning Source: https://github.com/odriverobotics/odrive/blob/master/docs/developer-guide.rst Example output from OpenOCD showing a warning about not identifying the target as an STM32 family during flashing. ```text [...] ** Programming Started ** auto erase enabled Info : device id = 0x10006452 Warn : Cannot identify target as a STM32 family. Error: auto_probe failed ``` -------------------------------- ### Build Electron app for multiple platforms Source: https://github.com/odriverobotics/odrive/blob/master/GUI/README.md Creates executable builds for Windows, macOS, and Linux. The `-mwl` flag specifies the target platforms. ```bash npm run electron:build -- -mwl ``` -------------------------------- ### CAN Simple Frame Structure Example Source: https://github.com/odriverobotics/odrive/blob/master/docs/can-protocol.rst Illustrates how the 11-bit Arbitration ID is constructed by combining the Axis ID and Command ID in the CAN Simple protocol. ```Python can_id = axis_id << 5 | cmd_id ``` ```Python 0x01 << 5 | 0x0C = 0x2C ``` -------------------------------- ### Package Electron app into an executable Source: https://github.com/odriverobotics/odrive/blob/master/GUI/README.md Builds the Electron application into a distributable executable file. This is the command for creating the final application package. ```bash npm run electron:build ``` -------------------------------- ### Upgrade odrivetool Source: https://github.com/odriverobotics/odrive/blob/master/docs/troubleshooting.rst Install the latest version of the odrivetool to resolve potential version mismatches with ODrive firmware. This command uses pip for package management. ```bash pip install odrive --upgrade ``` -------------------------------- ### ASCII Protocol Read Commands Source: https://context7.com/odriverobotics/odrive/llms.txt Demonstrates basic read commands using the ODrive's ASCII protocol to query bus voltage and encoder position. ```bash # Read bus voltage r vbus_voltage # Response: 24.087744 ``` ```bash # Read encoder position r axis0.encoder.pos_estimate ``` -------------------------------- ### Add local bin to PATH on Linux Source: https://github.com/odriverobotics/odrive/blob/master/docs/getting-started.rst If odrivetool is not recognized after installation, add ~/.local/bin to your system's PATH environment variable by editing the .bashrc file. ```bash nano ~/.bashrc export PATH=$PATH:~/.local/bin ``` -------------------------------- ### Set Encoder Pre-Calibrated and Enable Index Search on Startup Source: https://github.com/odriverobotics/odrive/blob/master/docs/encoders.rst Confirms the encoder offset is valid with respect to the index pulse and enables automatic index searching on startup for faster machine initialization. ```Python .encoder.config.pre_calibrated = True ``` ```Python .config.startup_encoder_index_search = True ``` -------------------------------- ### Start Encoder Offset Calibration Source: https://github.com/odriverobotics/odrive/blob/master/docs/encoders.rst Initiates the encoder offset calibration process for an axis. Ensure the rotor can rotate freely without biased load during this phase. ```Python .requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION ``` -------------------------------- ### Compile libfibre with Docker Source: https://github.com/odriverobotics/odrive/blob/master/Firmware/fibre-cpp/README.md Use these Docker commands to build libfibre for the linux-amd64 target. Ensure the output directory is mounted correctly. ```bash docker build -t fibre-compiler . docker run -it -v /tmp/build:/build/cpp/build --entrypoint bash fibre-compiler -c "rm -rd /build/cpp/build/*" docker run -it -v "$(pwd)":/build -v /tmp/build:/build/build -w /build fibre-compiler configs/linux-amd64.config ``` -------------------------------- ### Enable and Configure Endstop Source: https://github.com/odriverobotics/odrive/blob/master/docs/endstops.rst Enable the minimum endstop and set the GPIO mode for pull-up resistors. This is a prerequisite for endstop functionality. ```Python ..min_endstop.config.enabled = True .config.gpio5_mode = GPIO_MODE_DIGITAL_PULL_UP ``` -------------------------------- ### Add Teensy udev Rules Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Downloads and installs udev rules for Teensy devices, allowing non-root access. This is crucial for the Teensy Loader CLI to function correctly. ```Bash curl https://www.pjrc.com/teensy/49-teensy.rules | sudo tee /etc/udev/rules.d/49-teensy.rules ``` -------------------------------- ### Enter Docker Container Interactively Source: https://github.com/odriverobotics/odrive/blob/master/Firmware/fibre-cpp/README.md If compilation fails, use this command to enter the Docker container interactively for debugging. Ensure volumes are mounted as needed. ```bash docker run -it -v "$(pwd)":/build -v /tmp/build:/build/build -w /build --entrypoint bash fibre-compiler ``` -------------------------------- ### Build ODrive Firmware Source: https://github.com/odriverobotics/odrive/blob/master/docs/configuring-vscode.rst Initiate the firmware build process using the 'make -j4' command within VSCode's integrated terminal. This command compiles the ODrive firmware with parallel job execution for faster builds. ```shell make -j4 ``` -------------------------------- ### Compile libfibre on Windows Source: https://github.com/odriverobotics/odrive/blob/master/Firmware/fibre-cpp/README.md Instructions for compiling libfibre on Windows using MinGW. Ensure MinGW is in your PATH and libusb binaries are correctly placed. ```bash make ``` -------------------------------- ### Set Filter Bandwidth for Position Control Source: https://github.com/odriverobotics/odrive/blob/master/docs/control-modes.rst Set the filter bandwidth in Hz for the second-order position filter. A good starting point is half of your setpoint command rate. ```ipython axis.controller.config.input_filter_bandwidth = 2.0 ``` -------------------------------- ### Display ODrive Serial Numbers from lsusb Output Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Example output from the lsusb command, showing the iSerial field for connected ODrives. Multiple ODrives may be listed. ```Bash iSerial 3 385F324D3037 iSerial 3 306A396A3235 ``` -------------------------------- ### Connect to ODrive and Enter Interactive Shell Source: https://github.com/odriverobotics/odrive/blob/master/docs/odrivetool.rst Run odrivetool to connect to an ODrive and enter its interactive shell. The serial number is displayed upon successful connection. ```iPython Connected to ODrive 306A396A3235 as odrv0 In [1]: ``` -------------------------------- ### Get Motor Feedback (Position and Velocity) Source: https://github.com/odriverobotics/odrive/blob/master/docs/ascii-protocol.rst Use 'f' followed by the motor number to request feedback. The response provides encoder position in turns and velocity in turns/s. ```ascii f motor ``` ```ascii pos vel ``` -------------------------------- ### Enable SPI on Raspberry Pi Source: https://github.com/odriverobotics/odrive/blob/master/docs/testing.rst Add SPI enable and overlay configurations to the Raspberry Pi's boot configuration file. ```Bash dtparam=spi=on ``` ```Bash dtoverlay=spi-bcm2835-overlay ```