Giter VIP home page Giter VIP logo

niryo_one_matlab's Introduction

Niryo One - MATLAB interface

This repository has MATLAB code and functions to execute Niryo One - MATLAB interface.

This interface connects Niryo-one to MATLAB to analyze differences between planned trajectory and executed trajectory.

In this application, we can compare between the 2 differnet trajectories by ploting them as shown below.

Matlab graph

this project connect to niryo one ros

list of Niryo One -MATLAB inetface functionality :

  • Activate/ Disactivate learning Mode.
  • Calibrate Motors .
  • Request New Calibration.
  • Send command to Niryo one.
  • Plot planned and executed trajectory.
  • Plot differences between planned trajectory and executed trajectory.
  • Export/import Data.
  • Get Hardware Status parameters.
  • Display logs applications.

1.Install and Configure MATLAB-Ros Environment

1.1 Install MATLAB

MATLAB has several versions, If you dont have MATLAB installation file, try to get the newer version.The installer can be downloaded from here: MatlabDownload. N.B. MathWorks provides the licensed product, a trial version and a student version.

Matlab logo

Install MATLAB in your PC and make sure to select robotic toolbox while installation.

Matlab logo

After finishing the installation , launch MATLAB Command windowand make sure that the Robotic toolbox is installed by running :

rosinit

1.2 Set up MATLAB environment
1.2.1 Install robotics System Toolbox

To install Robotics System Toolbox, Run this command in MATLAB command window:

roboticsAddons

Addons screenshot

Then Choose Robotics System Toolbox Interface for ROS Custom Messages and click install.

N.B. If you have MATLAB R2017a and earlier versions, you have to follow this Bug Reports

1.2.1 Create Custom Messages from ROS Package

You can follow this tutorial.

In windows , clone niryo one ros and note the folderpath

In Ubnutu, If you already install Niryo One ROS packages on your computer, you just have to note the folder path. In MATLAB command window run:

folderpath = your_folder_path

rosgenmsg(folderpath)

Follow steps 1 to 3 from the output of rosgenmsg:

  • Edit javaclasspath.txt, add the following file locations as new lines, and save the file:
<your_folder_path>\jar\dynamixel_sdk-3.4.7.jar
<your_folder_path>\matlab_gen\jar\mcp_can_rpi-1.0.0.jar
<your_folder_path>\jar\niryo_one-1.1.0.jar
[...]
<your_folder_path>\matlab_gen\jar\niryo_one_rpi-1.1.0.jar
<your_folder_path>\matlab_gen\jar\niryo_one_tools-1.1.0.jar
<your_folder_path>\matlab_gen\jar\niryo_one_user_interface-1.1.0.jar
  • Add the custom message folder to the MATLAB path by executing:

addpath('your_folder_path')

savepath

  • Restart MATLAB and verify that you can use the custom messages. Type

rosmsg list

Ensure that the output contains the generated custom message types.

niryo_one_msgs/CloseGripperRequest
niryo_one_msgs/CloseGripperResponse
niryo_one_msgs/DigitalIOState
niryo_one_msgs/GetDigitalIORequest
niryo_one_msgs/GetDigitalIOResponse
niryo_one_msgs/GetIntRequest
niryo_one_msgs/GetIntResponse
niryo_one_msgs/GetSequenceListRequest
niryo_one_msgs/GetSequenceListResponse
niryo_one_msgs/HardwareStatus
niryo_one_msgs/JoystickJointsAction
...........................
1.2.3 Connect ROS-MATLAB to ROS robot as a master
  • Find the name of your hostname In windows, open cmd window and type hostname e.g. WINDOWSPC) In Raspberry Pi, type hostname -I (e.g. ROBOTPC)

-Look for IP_ address of robot and matlab computer, they should had the same mask 255.255.255.0 e.g.

192.168.65.82 %  <ROBOTIP>
192.168.65.80 % <WINDOWSPCIP>
  • Edit file C:\Windows\system32\drivers\etc\hosts in windows and /etc/hosts ** in Raspberry Pi** by adding those two lines :
192.168.65.82	 <ROBOTPC>
192.168.65.80	<WINDOWSPC>

Restart your computer

  • Turn off all the firewalls on Mtalab PC and Ubuntu PC

  • Set environment variables on your robot

  export ROS_MASTER_URI=http://<ROBOTIP>:11311
  export ROS_IP=  <ROBOTIP>

Restart your robot

!ping ROBOTIP

Pinging <ROBOTIP> with 32 bytes of data: 
Reply from <ROBOTIP>: bytes=32 time=6ms TTL=64 
Reply from <ROBOTIP>: bytes=32 time=4ms TTL=64 
Reply from <ROBOTIP>: bytes=32 time=4ms TTL=64 
Reply from<ROBOTIP>: bytes=32 time=4ms TTL=64 
  • On MATLAB command window , set the environment variables for ROS:

setenv('ROS_MASTER_URI','ROBOTIP:11311')

setenv('ROS_IP','WINDOWSPCIP')

rosinit

N.B. the last step is not necessary , cause it s already in matlab code

2.Download the application

First download or clone the application file form [here] ( )

3.Getting started with the application

  • For your first connection : open niryo One Studio and follow the steps to connect Niryo one to the wifi network in order to connect your computer and your robot to the same network.
  • Open Matlab_Gui file
  • Click run

run

This will bring up the start screen

connexion window

  • Put your in the first text box( its the same ip address you used to configure connection between robot and matlab-ros).

  • Put your in the first text box( its the same ip address you used to configure connection between robot and matlab-ros). Put your in the second text file ( the same you used in section 2.1.3) Click connect to Niryo one button to connect Matlab to your robot . wait few seconds until the connection is established. When the button turned to connected you can start commanding your robot.

  • Go to arm Command button

command window

You can use Learning Mode button to activate /disactivate learning mode You can use calibrate Motors button to start calibrating motors.

  • You can send command to your robot: Enter joints value and click Move joints ,you must see you robot move to the following command.

command window

  • In order to compare the planned and the executed trajectory ,enter joints value, press listen to trajectory button first, and then press Move joints button. The application will work for a few second before presenting you the results of trajectories on plot trajectory window. Choose the joint ( form joint 1 to joint 6) you want to plot and you will see a curve graph of the planned ,the real trajectory and the difference between them.

![plot trajectory] (./screenshot/plot.JPG)

  • If you want to export result, click export button , choose a location and a name of your text file. the trajectory will be saved in both a text and an excel file.

![export] (./screenshot/export.JPG)

  • You can import a saved trajectory data by clicking on import button and choosing an excel file.
  • Click Hardware Status button to get updated hardware status.

hw status

  • Click application logs button to see your history activities.

application logs

If you find problems and need any help, please do not hesitate to contact us at [email protected] .

Thank you !

niryo_one_matlab's People

Contributors

sarraelghali avatar renarded avatar

Watchers

James Cloos avatar

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.