Giter Club home page Giter Club logo

dual_quaternion's Introduction

Dual Quaternion Numpy and CasADi

This is a brief explanation of how to install and run this package on another machine.

Create a new conda environment using Python 3.8 (for example, named "dual_quat") and activate it with the following commands:

conda create -n dual_quat python=3.8
conda activate dual_quat

This project includes an installation file that contains all the necessary dependencies for Python and ROS. Inside the conda environment, execute the following commands:

chmod +x install_python.sh
./install_python.sh

ROS Workspace

Create a ros workspace using the following commands:

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/

Inside the ROS workspace /src must be included: dual_quaternion.

Since the creation of the conda virtual environment, it should be activated before compiling the packages; therefore, execute the following command:

catkin_make -DPYTHON_EXECUTABLE=~/miniconda3/envs/dual_quat/bin/python
source devel/setup.bash

Tutorial: DualQuaternion Operations

Conjugate

Norm

Addition

Retrieving Elements of the DualQuaternion (Real, Dual, Quaternion, and Translation)

Tutorial Rigid Body

Defining Different Rigid Body Frames

This section explains how to use the library to define the pose of a rigid body as a DualQuaternion object and how to display its information within rviz

The proper way to define the pose of a rigid body is described below:

#Defining the Orientation Using Quaternions
theta1 = ca.SX([np.pi/2])
n1 = ca.SX([0.0, 0.0, 1.0])
q1 = ca.vertcat(ca.cos(theta1/2), ca.sin(theta1/2)@n1)

# Defining the translation
t1 = ca.SX([0.0, 1.0, 1.0, 0.0])

#Defining the Orientation Using Quaternions
theta2 = ca.SX([ca.pi/4])
n2 = ca.SX([1.0, 0.0, 0.0])
q2 = ca.vertcat(ca.cos(theta2/2), ca.sin(theta2/2)@n2)

# Defining the translation
t2 = ca.SX([0.0, 0.0, 2.0, 0.0])

# Init Dualquaternion
Q1 = DualQuaternion.from_pose(quat = q1, trans = t1)
Q2 = DualQuaternion.from_pose(quat = q2, trans = t2)

The proper representations of these body frames are presented below:

It is also possible to verify the norm of the DualQuaternion elements; the user can obtain the norm using the following commands:

#Obtaining the norm of the DualQuaternion elements
Q1_norm = Q1.norm
Q2_norm = Q2.norm

The norm property of the elements returns the is a dual number whose real part and dual part are both positive

Sequential Pose Transformations

In order to perform sequential pose transformations, it is only necessary to multiply the DualQuaternions. For instance, the user can define the following transformation:"

# Computing a sequential transformation
Q3 = Q1 * Q2

The result of this operation can be visualized in the following image:

It is posible to replicate theese results by executing the following commad:

python Tutorial_1.py

Differential Kinematics Quaternions Control

It is possible to execute quaternion-based kinematic control, where the purpose is to converge to a desired orientation.

To run the controller taking the shortest path based on numpy, execute the following command:

roslaunch dual_quaternion quat_numpy.launch

To run the controller taking the shortest path based on Casadi, execute the following command:

roslaunch dual_quaternion quat_casadi.launch

The results of this formulation are presented in the following images.

Differential Kinematics DualQuaternions Control

To run the controller taking the shortest path based on numpy, execute the following command:

roslaunch dual_quaternion dualquaternion.launch

To run the controller taking the shortest path based on Casadi, execute the following command:

roslaunch dual_quaternion dualquaternion_casadi.launch

dual_quaternion's People

Contributors

lfrecalde1 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.