Giter Club home page Giter Club logo

robotlib.jl's Introduction

CI codecov

Robotlib

This is a library of functions to help out in a robotics lab. At present stage, it contains functions for forward kinematics, jacobians, iterative inverse kinematics and for a few robotics related calibration problems. The library also contains a number of functions to convert from various orientation representations and other robotics related helper functions.

Install using

using Pkg; Pkg.add("Robotlib")

Usage

fkine, ikine, jacobian = get_kinematic_functions("yumi") # Replace yumi for your robot model, as long as it's supported
data = csv2dict(path) # Read data from a csv-file and store in a dict
q = getdata("robot_0.*posRawAbs", data, 1, removeNaN = false) # Extract columns from data object using regex like syntax

For ABB YuMi, joint angles q must be converted to logical order using e.g. abb2logical!(q) If you use the kinematic functions privided by get_kinematic_functions, the base transform is handled automatically. If you use the standard kinematic functions provided in Robotlib, you must also consider the base transform.

Case study, calibrate force sensor (or accelerometer)

using Robotlib
using DSP # For filtfilt

# Define robot to use, in this case YuMi
dh = DHYuMi()
fkine, ikine, jacobian = get_kinematic_functions("robotname")

q,q̇,τ = load_your_data()

# Apply gear ratio transformation
q = q*dh.GR'=*dh.GR'
τ = τ*inv(dh.GR')

# Filter velocities to get accelerations= filtfilt(ones(50),[50.],centralDiff(q̇))

# plot(abs([q̇, q̈]))

# Sort out data with low acceleration
lowAcc  = all(abs.(q̈) .< 3e-4,2)
q       = q[lowAcc,:]
q̇       = q̇[lowAcc,:]
τ       = τ[lowAcc,:]
f       = f[lowAcc,:]
N       = size(q,1)

# Apply forward kinematics to get end-effector poses
T  = cat([fkine(q[i,:]) for i = 1:N]..., dims=3)

trajplot(T) # Plots a trajectory of R4x4 transformation matrices

# Perform the force sensor calibration and plot the errors
Rf,m,offset     = calib_force(T,f,0.2205,offset=true) # See also calib_force_iterative, calib_force_eigen
err = hcat([Rf*f[i,1:3] + offset - T[1:3,1:3,i]'*[0, 0, m*-9.82] for i = 1:N]...)'
plot(f[:,1:3],lab="Force")
plot!(err,l=:dash,lab="Error")
println("Error: ", round(rms(err), digits=4))

Exported functions

See

names(Robotlib)
names(Robotlib.Frames)

The submodule Robotlib.Frames supports creation of frames, simple projections, fitting of planes, lines etc. and has a number of plotting options. It must be separately imported with using Robotlib.Frames.

Kinematics

The library has functions for calculation of forward kinematics, inverse kinematics and jacobians. Several versions of all kinematics functions are provided; calculations can be made using either the DH-convention or the (local) product of exponentials formulation. To support a new robot, create an object of the type DH, or provide a matrix with POE-style link twists, for use with the kinematic functions.

Usage

dh = DH7600() # ABB Irb 7600
xi = DH2twistsPOE(dh)
T  = fkinePOE(xi, q)

or alternatively

dh = DH7600()
Jn, J0, T, Ti, trans = jacobian(q, dh)

many other options exits, check kinematics.jl

Frames

This module is aimed at assisting with the creation of frames for tracking using optical tracking systems. It supports projection of points and lines onto planes, creating frames from features and has some plotting functionality.

Usage

This is an example of how data can be loaded from files and how different geometrical objects can be fitted to data, projected onto other objects etc.

using Frames
import MAT
function setupframes(path)
	path = Pkg.dir("Robotlib","src","applications","frames/")

	# Add frame names to the dictionary
	add_frame_name!("SEAM","Weld seam frame")
	add_frame_name!("TAB","Table frame")

	# Read matrices from file
	T_RB_Tm = MAT.matread(path*"T_RB_T.mat")["T_RB_T"]
	T_TF_TCPm = MAT.matread(path*"T_TF_TCP.mat")["T_TF_TCP"]
	T_T_TABm = MAT.matread(path*"T_T_Table.mat")["T_T_Table"]

	# Create frames from matrices
	T_RB_T = Frame(T_RB_Tm,"RB","T")
	T_S_D = Frame(T_TF_TCPm,"S","D")
	T_T_TAB = Frame(T_T_TABm,"T","TAB")

	# Read point clouds generated by nikon software from file
	cloud_seam = readcloud(path*"CloudSeam_edge.txt")
	plane_seam = readplane(path*"PlaneSeam_edge.txt")

	# Project points onto plane and fit a line
	cloud_seam_projected = project(plane_seam,cloud_seam)
	line_seam = fitline(cloud_seam_projected)

	# Create a frame from the measured features
	T_T_SEAM = framefromfeatures(("z+",line_seam),("y-",plane_seam),cloud_seam_projected[1],"SEAM")
	T_RB_SEAM = T_RB_T*T_T_SEAM
	T_RB_TAB = T_RB_T*T_T_TAB
	T_TAB_SEAM = inv(T_T_TAB)*T_T_SEAM


	cloud_seam_RB = T_RB_T*cloud_seam
	cloud_seam_projected_RB = T_RB_T*cloud_seam_projected
	plane_seam_RB = T_RB_T*plane_seam
	line_seam_RB = T_RB_T*line_seam

	# Plot results
	plot(Frame(I4,"RB","U"), 200)
	plot!(cloud_seam_RB, c=:blue)
	plot!(cloud_seam_projected_RB, c=:red)
	plot!(line_seam_RB, 500, label="Line seam")
	plot!(plane_seam_RB, 200, label="Plane seam")
	plot!(T_RB_SEAM, 200, label="T_RB_SEAM")
	plot!(T_RB_TAB, 200, label="T_RB_TAB")

	xlabel!("x")
	ylabel!("y")
	# zlabel!("z")

    # Write frames to file
    MAT.matwrite(path*"T_TAB_SEAM.mat",["T_TAB_SEAM" => T_TAB_SEAM.T])
    MAT.matwrite(path*"T_T_SEAM.mat",["T_T_SEAM" => T_T_SEAM.T])
    MAT.matwrite(path*"T_RB_TAB.mat",["T_RB_TAB" => T_RB_TAB.T])
    println("Wrote T_TAB_SEAM, T_T_SEAM, T_RB_TAB to files in $path")
end

Citing

This package was developed for the thesis Bagge Carlson, F., "Machine Learning and System Identification for Estimation in Physical Systems" (PhD Thesis 2018).

@thesis{bagge2018,
  title        = {Machine Learning and System Identification for Estimation in Physical Systems},
  author       = {Bagge Carlson, Fredrik},
  keyword      = {Machine Learning,System Identification,Robotics,Spectral estimation,Calibration,State estimation},
  month        = {12},
  type         = {PhD Thesis},
  number       = {TFRT-1122},
  institution  = {Dept. Automatic Control, Lund University, Sweden},
  year         = {2018},
  url          = {https://lup.lub.lu.se/search/publication/ffb8dc85-ce12-4f75-8f2b-0881e492f6c0},
}

The algorithm calibNAXP was presented in

@inproceedings{bagge2015calibration,
  title        = {Six {DOF} eye-to-hand calibration from {2D} measurements using planar constraints},
  author       = {Bagge Carlson, Fredrik and Johansson, Rolf and Robertsson, Anders},
  booktitle    = {International Conference on Intelligent Robots and Systems (IROS)},
  year         = {2015},
  organization = {IEEE}
}

The friction model frictionRBFN was presented in

@inproceedings{bagge2015friction,
  title        = {Modeling and identification of position and temperature dependent friction phenomena without temperature sensing},
  author       = {Bagge Carlson, Fredrik and Robertsson, Anders and Johansson, Rolf},
  booktitle    = {International Conference on Intelligent Robots and Systems (IROS)},
  year         = {2015},
  organization = {IEEE}
}

robotlib.jl's People

Contributors

andreasstolt avatar baggepinnen avatar femtocleaner[bot] avatar github-actions[bot] avatar juliatagbot avatar staticfloat avatar tkelman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

robotlib.jl's Issues

potential colon issue in abb2logical!

function abb2logical!(q::Matrix)
q[:,:] = q[:,[1, 2, 7, 3, 4, 5, 6]]
end

function logical2abb!(q::Matrix)
q[:,:] = q[:,[1, 2, 4, 5, 6, 7, 3]]
end

function abb2logical!(q::Vector)
q[:,:] = q[[1, 2, 7, 3, 4, 5, 6]]
end

function logical2abb!(q::Vector)
q[:,:] = q[[1, 2, 4, 5, 6, 7, 3]]
end

isskew should handle small numerical deviations

The following matrix is in the current implementation not considered to be skew symmetric:

S = [
    3.469446951953614e-17 0.01413101017790172 0.5555528457618361
    -0.014131010177901714 1.734723475976807e-17 0.06871266098996705
    -0.5555528457618361 -0.06871266098996702 2.7755575615628914e-17
]

Either isskew should accept small numerical deviations, or it should be possible to override the isskew check when calling skewcoords.

How to test the calibNAXP method plotting lines and planes

Hi,
I see that the calibNAXP method has a parameter doplot that can be set to true in order to plot the lines and planes during the optimization. Is it actually working? I see that if we enable this parameter the package actually crashes, with errors on not defined variables "N_RB" in the main function or "p" in the plotPlanes function.

Is there a way to set up everything and actually plot the simulated lines and planes for hand-eye calibration of laser sensors?

I would really apprechiate to use this method.

Best regards,
D.

[Suggestion] Robot type

Instead of

dh = DHYuMi()
fkine, ikine, jacobian = get_kinematic_functions("yumileft")

we could introduce an AbstractRobot type and let

struct YuMi <: AbstractRobot
    fkine::Function
    ikine::Function
    jacobian::Function
    dh::DH
    ...
end

for which an OO like syntax could be used, e.g.,

yumi = YuMi()
T = yumi.fkine(q)
J = yumi.jacobian(q)

This would make it easier to work with many robots at the same time and the user would only need to remember how to create a robot (yumi = YuMi()), as opposed to remember every individual function related to kinematics etc.
Input? @martin-kar

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

Create tests

Putting some of the already available testfunctions in the test/runtests.jl file and write intelligent checks

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.