roboticslab-uc3m / jr3-mbed-firmware

Mbed firmware for interfacing with a JR3 6-axis force-torque sensor through CAN
GNU Lesser General Public License v2.1
0 stars 1 forks source link

JR3 Mbed firmware

An Arm Mbed OS 6 application that performs data acquisition from a JR3 force-torque sensor and streams it through a CAN channel.

Incidentally, support was added for sending simple PWM commands to a Lacquey fetch gripper through a secondary optional CAN channel.

Installation

Since the Mbed Online Compiler has been discontinued, development and compilation should be carried out at https://studio.keil.arm.com/. Make sure you select "mbed LPC1768" as the compilation target. Once built, plug in the Mbed to a USB port of your PC and drag-and-drop the downloaded .bin file into it.

CAN protocol

command op code direction payload
(bytes)
details
sync 0x080 in 0
acknowledge 0x100 out 1-7 LSB byte: 0x00 - sensor ready; 0x01 - not initialized
6 MSB bytes (optional): see command details
start sync 0x180 in 2 low-pass filter cutoff frequency in 0.01*Hz (integer)
(e.g. 1025 = 10.25 Hz)
start async 0x200 in 6 2 LSB bytes: cutoff frequency (as above)
4 MSB bytes: period in us (integer)
stop 0x280 in 0
zero offsets 0x300 in 0
set filter 0x380 in 2 cutoff frequency (as above)
get state 0x400 in 0
get full scales
(forces)
0x480 in 0 acknowledge message carries force full scales
in the 6 MSB bytes (Fx, Fy, Fz)
get full scales
(moments)
0x500 in 0 acknowledge message carries moment full scales
in the 6 MSB bytes (Mx, My, Mz)
reset 0x580 in 0
force data 0x600 out 8 (3x) 2 LSB bytes: Fx, Fy, Fz (integer, signed)
2 MSB bytes: frame counter
moment data 0x680 out 8 (3x) 2 LSB bytes: Mx, My, Mz (integer, signed)
2 MSB bytes: frame counter
bootup 0x700 out 0
gripper PWM 0x780 in 4 PWM command between -100.0 and 100.0 (float)

Bolded incoming commands imply that the Mbed will respond with an acknowledge message.

Usage

On bootup, the calibration matrix and full scales are queried from the sensor and stored for later use. If successful, the bootup message is sent. This may take a few seconds from initial power up. A failure means that there is no connection to the sensor. Re-initialization may be requested during normal operation through the "reset" command. If the initialization succeeds, the JR3 controller is in "ready" state, otherwise it remains in "not initialized" state. All acknowledge messages carry this state information in their payload. The "get state" command is a no-op that can be used to ping the controller.

The JR3 sensor operates in two modes: synchronous and asynchronous. Both entail that a background thread will be performing data acquisition, decoupling, offset removal and filtering at full sensor bandwidth (8 KHz per channel).

The sensor is not calibrated by default. Use the "zero offsets" command to capture the current offset and substract it from subsequent filtered results. This command can be issued at any time.

It is highly recommended to enable raw data filtering by specifying the desired cutoff frequency to either start command. This firmware implements a simple first-order low-pass IIR filter, also known as an exponential moving average (see Wikipedia article). Its cutoff frequency can be modified through the "set filter" command.

Outgoing force and moment data requires post-processing on the receiver's side. These signed integer values should be multiplied by the corresponding full scale and divided by a factor of 16384 (=2^14) for forces and 16384*10 for moments. The resulting values will be expressed in Newtons and Newton*meters, respectively. Use the "get full scales" command to query the sensor full scales.

Configuration

See mbed-app.json for a list of configurable parameters and their description. The project should be recompiled after any changes to this file.

Additional tools

Most Linux kernels should support SocketCAN. In order to create a network interface for a CAN channel with a baudrate of 1 Mbps, run the following command:

sudo ip link set can0 up txqueuelen 1000 type can bitrate 1000000

To send a CAN message, install the can-utils package (apt install can-utils) and run:

cansend can0 201#C80010270000

This will start an ASYNC publisher on ID 1 with a period of 10 ms (10000 us = 0x2710) and a cutoff frequency of 2 Hz (200 Hz*0.01 = 0x00C8). Use the candump can0 command on a new terminal to inspect live traffic on the CAN bus, including any response from the Mbed.

A helper Python script is provided for visual inspection of filtered data, can-plotter.py. Example usage:

candump can0 | python3 can-plotter.py --id 1

Citation

If you found this project useful, please consider citing the following work:

Łukawski, B., Rodríguez-Sanz, A., Victores, J., & Balaguer, C. (2024). An open-source implementation of a force-torque sensor data acquisition device for the humanoid robot TEO. In Actas del Simposio de Robótica, Bioingeniería y Visión por Computador (pp. 79–84). Universidad de Extremadura.

@inproceedings{lukawski2024srbv,
    author={{\L}ukawski, Bartek and Rodríguez-Sanz, Alberto and Victores, Juan G. and Balaguer, Carlos},
    title={{An open-source implementation of a force-torque sensor data acquisition device for the humanoid robot TEO}},
    booktitle={Actas del Simposio de Robótica, Bioingeniería y Visión por Computador},
    year={2024},
    pages={79--84},
    publisher={Universidad de Extremadura},
    url={http://hdl.handle.net/10662/21260},
}

See also