odrivetool

Odrive cli tool.

Usage no npm install needed!

<script type="module">
  import odrivetool from 'https://cdn.skypack.dev/odrivetool';
</script>

README

odrivetool

A node.js tool for Odrive.

The project relies heavely on a few core modules:

  • odrive - Object marshaling via the Fibre protocol.
  • @primeeuler/fibre - JavaScript port of the Fibre protocol.
  • repl - Interactive shell to interface with Odrive.

Example: >odrive.unmarshal(odrv0)

{ vbus_voltage: 15.904614448547363,
  serial_number: 56488237806902,
  hw_version_major: 3,
  hw_version_minor: 6,
  hw_version_variant: 56,
  fw_version_major: 0,
  fw_version_minor: 4,
  fw_version_revision: 11,
  fw_version_unreleased: 0,
  user_config_loaded: true,
  brake_resistor_armed: true,
  system_stats: 
   { uptime: 20826033,
     min_heap_space: 4216,
     min_stack_space_axis0: 7868,
     min_stack_space_axis1: 7868,
     min_stack_space_comms: 9668,
     min_stack_space_usb: 2768,
     min_stack_space_uart: 3932,
     min_stack_space_usb_irq: 1788,
     min_stack_space_startup: 604,
     usb: { rx_cnt: 13556, tx_cnt: 13495, tx_overrun_cnt: 0 },
     i2c: { addr: 0, addr_match_cnt: 0, rx_cnt: 0, error_cnt: 0 } },
  config: 
   { brake_resistance: 2,
     enable_uart: true,
     enable_i2c_instead_of_can: false,
     enable_ascii_protocol_on_usb: true,
     dc_bus_undervoltage_trip_level: 8,
     dc_bus_overvoltage_trip_level: 59.92000198364258,
     gpio1_pwm_mapping: { endpoint: '\u0000\u0000\u0000\u0000', min: 0, max: 0 },
     gpio2_pwm_mapping: { endpoint: '\u0000\u0000\u0000\u0000', min: 0, max: 0 },
     gpio3_pwm_mapping: { endpoint: '\u0000\u0000\u0000\u0000', min: 0, max: 0 },
     gpio4_pwm_mapping: { endpoint: '\u0000\u0000\u0000\u0000', min: 0, max: 0 },
     gpio3_analog_mapping: { endpoint: '\u0000\u0000\u0000\u0000', min: 0, max: 0 },
     gpio4_analog_mapping: { endpoint: '\u0000\u0000\u0000\u0000', min: 0, max: 0 } },
  axis0: 
   { error: 'ERROR_NONE',
     step_dir_active: false,
     current_state: 'AXIS_STATE_IDLE',
     requested_state: 'AXIS_STATE_UNDEFINED',
     loop_counter: 166596020,
     lockin_state: 0,
     config: 
      { startup_motor_calibration: false,
        startup_encoder_index_search: false,
        startup_encoder_offset_calibration: false,
        startup_closed_loop_control: false,
        startup_sensorless_control: false,
        enable_step_dir: false,
        counts_per_step: 2,
        watchdog_timeout: 0,
        step_gpio_pin: 1,
        dir_gpio_pin: 2,
        calibration_lockin: [Object],
        sensorless_ramp: [Object],
        general_lockin: [Object] },
     motor: 
      { error: 'ERROR_NONE',
        armed_state: 0,
        is_calibrated: false,
        current_meas_phB: 0.4102337658405304,
        current_meas_phC: 0.06978216767311096,
        DC_calib_phB: 0.15359695255756378,
        DC_calib_phC: 0.4537855088710785,
        phase_current_rev_gain: 0.02500000037252903,
        thermal_current_lim: 45.388389587402344,
        get_inverter_temp: [Object],
        current_control: [Object],
        gate_driver: [Object],
        timing_log: [Object],
        config: [Object] },
     controller: 
      { error: 'ERROR_NONE',
        pos_setpoint: 0,
        vel_setpoint: 0,
        vel_integrator_current: 0,
        current_setpoint: 0,
        vel_ramp_target: 0,
        vel_ramp_enable: false,
        config: [Object],
        set_pos_setpoint: [Object],
        set_vel_setpoint: [Object],
        set_current_setpoint: [Object],
        move_to_pos: [Object],
        move_incremental: [Object],
        start_anticogging_calibration: [Object] },
     encoder: 
      { error: 'ERROR_NONE',
        is_ready: false,
        index_found: false,
        shadow_count: 0,
        count_in_cpr: 0,
        interpolation: 0.5,
        phase: 0.002684466540813446,
        pos_estimate: 0,
        pos_cpr: 0,
        hall_state: 7,
        vel_estimate: 0,
        calib_scan_response: 0,
        config: [Object],
        set_linear_count: [Object] },
     sensorless_estimator: 
      { error: 'ERROR_NONE',
        phase: 0,
        pll_pos: 0,
        vel_estimate: 0,
        config: [Object] },
     trap_traj: { config: [Object] },
     watchdog_feed: { inputs: {}, outputs: {} } },
  axis1: 
   { error: 'ERROR_NONE',
     step_dir_active: false,
     current_state: 'AXIS_STATE_IDLE',
     requested_state: 'AXIS_STATE_UNDEFINED',
     loop_counter: 166597727,
     lockin_state: 0,
     config: 
      { startup_motor_calibration: false,
        startup_encoder_index_search: false,
        startup_encoder_offset_calibration: false,
        startup_closed_loop_control: false,
        startup_sensorless_control: false,
        enable_step_dir: false,
        counts_per_step: 2,
        watchdog_timeout: 0,
        step_gpio_pin: 7,
        dir_gpio_pin: 8,
        calibration_lockin: [Object],
        sensorless_ramp: [Object],
        general_lockin: [Object] },
     motor: 
      { error: 'ERROR_NONE',
        armed_state: 0,
        is_calibrated: false,
        current_meas_phB: 0.03801960498094559,
        current_meas_phC: 0.0553433895111084,
        DC_calib_phB: 0.1230957955121994,
        DC_calib_phC: -0.8207171559333801,
        phase_current_rev_gain: 0.02500000037252903,
        thermal_current_lim: 46.38920211791992,
        get_inverter_temp: [Object],
        current_control: [Object],
        gate_driver: [Object],
        timing_log: [Object],
        config: [Object] },
     controller: 
      { error: 'ERROR_NONE',
        pos_setpoint: 0,
        vel_setpoint: 0,
        vel_integrator_current: 0,
        current_setpoint: 0,
        vel_ramp_target: 0,
        vel_ramp_enable: false,
        config: [Object],
        set_pos_setpoint: [Object],
        set_vel_setpoint: [Object],
        set_current_setpoint: [Object],
        move_to_pos: [Object],
        move_incremental: [Object],
        start_anticogging_calibration: [Object] },
     encoder: 
      { error: 'ERROR_NONE',
        is_ready: false,
        index_found: false,
        shadow_count: 0,
        count_in_cpr: 0,
        interpolation: 0.5,
        phase: 0.002684466540813446,
        pos_estimate: 0,
        pos_cpr: 0,
        hall_state: 7,
        vel_estimate: 0,
        calib_scan_response: 0,
        config: [Object],
        set_linear_count: [Object] },
     sensorless_estimator: 
      { error: 'ERROR_NONE',
        phase: 0,
        pll_pos: 0,
        vel_estimate: 0,
        config: [Object] },
     trap_traj: { config: [Object] },
     watchdog_feed: { inputs: {}, outputs: {} } },
  can: 
   { node_id: 0,
     TxMailboxCompleteCallbackCnt: 0,
     TxMailboxAbortCallbackCnt: 0,
     received_msg_cnt: 0,
     received_ack: 0,
     unexpected_errors: 0,
     unhandled_messages: 0 },
  test_property: 0,
  test_function: { inputs: { delta: 0 }, outputs: { result: 0 } },
  get_oscilloscope_val: { inputs: { index: 0 }, outputs: { result: 0 } },
  get_adc_voltage: { inputs: { gpio: 0 }, outputs: { result: 0.8113036751747131 } },
  save_configuration: { inputs: {}, outputs: {} },
  erase_configuration: { inputs: {}, outputs: {} },
  reboot: { inputs: {}, outputs: {} },
  enter_dfu_mode: { inputs: {}, outputs: {} } }