GithubHelp home page GithubHelp logo

paulotto / canfnet Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 3.0 41.2 MB

CANFnet for estimation of the contact area and normal force and its distribution from visuotactile images.

CMake 4.91% Python 95.07% Makefile 0.03%

canfnet's Introduction

CANFnet

Visuotactile sensors are gaining momentum in robotics because they provide high-resolution contact measurements at a fraction of the price of conventional force/torque sensors. It is, however, not straightforward to extract useful signals from their raw camera stream, which captures the deformation of an elastic surface upon contact. To utilize visuotactile sensors more effectively, powerful approaches are required, capable of extracting meaningful contact-related representations. This work proposes a neural network architecture called CANFnet (Contact Area and Normal Force) that provides a high-resolution pixel-wise estimation of the contact area and normal force given the raw sensor images. The CANFnet is trained on a labeled experimental dataset collected using a conventional force/torque sensor, thereby circumventing material identification and complex modeling for label generation. We test CANFnet using commercially available DIGIT and GelSight Mini sensors and showcase its performance on real-time force control and marble rolling tasks. We are also able to report generalization of the CANFnets across different sensors of the same type. Thus, the trained CANFnet provides a plug-and-play solution for pixel-wise contact area and normal force estimation for visuotactile sensors. Additional information and videos can be seen at https://sites.google.com/view/canfnet.

Table Of Contents

Prerequisites

  • ROS Noetic: installation instructions
  • Needed Python packages can be installed with:
    pip3 install -r requirements.txt
  • For Windows users, PyTorch (CUDA 11.7) can be installed as follows:
    pip3 install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu117

Installation

  1. Clone the repository:

    git clone https://github.com/paulotto/canfnet.git /destination-directory/
  2. Install ROS package dependencies:

    sudo apt-get install python3-rosdep
    cd /destination-directory/canfnet
    source /opt/ros/noetic/setup.bash && apt-get update && rosdep install -y \
      --from-paths ./src --ignore-src -r -y
  3. Build the ROS workspace:

    cd /destination-directory/canfnet
    source /opt/ros/noetic/setup.bash
    catkin build
  4. (Optional) ROS environment setup:

    Source the setup files automatically so that you don't have to source them every time a new shell is launched.

    echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
    echo "source /destination-directory/canfnet/devel/setup.bash" >> ~/.bashrc

Usage

Two nodes for publishing images from visuotactile sensors and for publishing the normal force and its distribution estimated by the CANFnet can be launched as follows:

roslaunch canfnet.launch rqt_gui:=true tactile_device:=GelSightMini tactile_device_path:=/dev/GelSightMini \
                         digit_serial:=D20025 tactile_cam_undistort:=true torch_device:=cuda canfnet_force_filt:=true \
                         model:="$(find canfnet)/models/model.pth"
Argument Description
rqt_gui True if an rqt_gui window should be opened for displaying the data
tactile_device The used visuotactile sensor (DIGIT or GelSightMini)
tactile_device_path The path to the visuotactile sensor (e.g. /dev/video0)
digit_serial If a DIGIT sensor is used, the serial number of the sensor ('tactile_device_path' isn't needed then)
tactile_cam_undistort True if the visuotactile image is to be undistorted
torch_device Either 'cpu' (CPU) or 'cuda' (GPU)
canfnet_force_filt True if the estimated normal force is to be (median) filtered
model The PyTorch model including the file path

Models

Our trained models are placed inside src/canfnet/models/.

Dataset

The data that has been used to train our model can be found here. The file dataset.py contains a class VistacDataSet inheriting from PyTorch Dataset to access the visuotactile images and corresponding normal force distributions of the provided dataset. The class can be used as follows:

from torch.utils.data import DataLoader
from canfnet.utils.dataset import VistacDataSet

dataset = VistacDataSet("/path/to/dataset/directory", norm_img=None, norm_lbl=None, augment=False, mmap_mode='r')
dataloader = DataLoader(dataset, batch_size=32, shuffle=False)

for batch in dataloader:
    # visuotactile image, force distribution, object surface area [mm²], force
    img, f_dis, area, f = batch.values()

Udev Rules

Optionally, you can give the visuotactile sensors more expressive names by writing the following in a /etc/udev/rules.d/50-vistac.rules file and adjusting the attributes:

SUBSYSTEM=="video4linux", SUBSYSTEMS=="usb", ATTR{name}=="DIGIT: DIGIT", ATTR{index}=="0", ATTRS{serial}=="D20025", SYMLINK+="DIGIT"
SUBSYSTEM=="video4linux", SUBSYSTEMS=="usb", ATTR{name}=="GelSight Mini R0B 28J3-CWXU: Ge", SYMLINK+="GelSightMini"

The corresponding device attributes can be found with the command:

udevadm info --name=/dev/video0 --attribute-walk

After adding the file, Udev can be reloaded with:

sudo udevadm control --reload
sudo udevadm trigger

Project Structure

canfnet
├── README.md
├── requirements.txt
└── src
    ├── canfnet
    │   ├── CMakeLists.txt
    │   ├── config
    │   │   └── canfnet.perspective
    │   ├── include
    │   │   └── canfnet
    │   ├── launch
    │   │   └── canfnet.launch
    │   ├── models
    │   │   ├── DIGIT
    │   │   │   └── model_24-02-2023_14-49-02_256_digit.pth
    │   │   └── GelSightMini
    │   │       └── model_23-02-2023_16-49-19_256_gelsight_mini.pth
    │   ├── msg
    │   │   └── UNetEstimation.msg
    │   ├── nodes
    │   │   ├── canfnet_node.py
    │   │   └── visuotactile_sensor_node.py
    │   ├── package.xml
    │   ├── scripts
    │   │   └── train
    │   │       ├── evaluate.py
    │   │       ├── ...
    │   │       ├── train.py 
    │   │       └── ...
    │   ├── setup.py
    │   └── src
    │       └── canfnet
    │           ├── __init__.py
    │           ├── unet
    │           │   ├── __init__.py
    │           │   ├── predict.py
    │           │   └── unet.py
    │           ├── utils
    │           │   ├── dataset.py
    │           │   ├── __init__.py
    │           │   ├── params
    │           │   │   └── indenter_list_with_areas_in_mm.yaml
    │           │   └── utils.py
    │           └── visuotactile_sensor
    │               ├── __init__.py
    │               ├── params
    │               │   ├── cam_params_digit.yaml
    │               │   └── cam_params_gelsightmini.yaml
    │               └── visuotactile_interface.py
    └── CMakeLists.txt

Citation

If you use code or ideas from this work for your projects or research, please cite it.

@article{funk_canfnet,
title = {CANFnet: High-Resolution Pixelwise Contact Area and Normal Force Estimation for Visuotactile Sensors Using Neural Networks},
year = {2023},
url = {https://sites.google.com/view/canfnet},
author = {Niklas Funk and Paul-Otto Müller and Boris Belousov and Anton Savchenko and Rolf Findeisen and Jan Peters}
}

canfnet's People

Contributors

paulotto avatar

Stargazers

Satoshi Otsubo avatar Irina Rath avatar  avatar João Pardal avatar Tatsuya Kamijo avatar Shaoxiong Yao avatar Sudharshan Suresh avatar Kei Ohta avatar Sandalots avatar Silvio Traversaro avatar

Watchers

Silvio Traversaro avatar  avatar

canfnet's Issues

PluginManager._load_plugin() could not load plugin "rqt_image_view/ImageView": plugin not available

hi

Thank you for your excellent work!
I want to implement your work on my digit sensor, but I have encountered some problems:
When I use command:
roslaunch canfnet.launch rqt_gui:=true tactile_device:=DIGIT tactile_device_path:=/dev/GelSightMini
digit_serial:=D20266 tactile_cam_undistort:=true torch_device:=cuda canfnet_force_filt:=true
model:="$(find canfnet)/models/DIGIT/model.pth"
the terminal shows:
2023-11-10_21-04

  1. Can you help me with this problem?
  2. Can you tell me which PyQt5 verison you use?
  3. What python version do you use?

Thanks, looking forward to your reply

Can't reproduce paper results

Hi!

First of all, congratulations on this excellent work!

I am trying to reproduce the results of your paper but, for the moment, I cannot do it. I am trying to train CanfNet with your training data but the training loss gets stuck around 0.6 value, the IFL loss is around 12, and when I evaluate the trained model on the test set, I get an MAE of 3N.

I also encountered some problems executing the evaluate.py script, I got an error because NORM_DIS variable is not defined.

I don't know if the train and evaluate scripts are updated to the final version, could you help me or give me some tips to train your network? I would appreciate it.

Thanks in advance, regards,
Julio.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.