# Falcon - a grasshopper plugin

back
A grasshopper plugin for matrix, quaternion and marker detection.
Chen, 2016-10-19

This plugin was developed initially for receiving Quaternion message from ROS and convert into Matrix, in order to visualize our drone in Rhino, which is controlled offboard by ROS through a SLAM algorithm.

Due to higher and higher need of Quaternion and Matrix calculation, I covered almost all necessary operations and put them into a plugin.

Additionally, I added a marker detection part that may be useful to some of you who wants interaction with grasshopper. Further more, augmented reality can also be added upon, but I didn't since I felt it's superfluous to have it in Rhino. To use marker detection I added load image, show image, webcam, and conversion between bitmap and firefly image in case you feel more comfortable using firefly components.

Besides that, I have another component which is pathfinding, just looking for shortest path between two points, with given obstacles. It works in both 2D and 3D. It was one of my assignment in a seminar. It's worth sharing to you although it would be useful in very limited situation...

## functionalities

### Matrix 4x4

• CreateMatrixFromAxisAngle: Creates a matrix that rotates around an arbitrary vector.
• CreateMatrixFromQuaternion: Creates a rotation matrix from the specified Quaternion rotation value.
• CreateMatrixFromYawPitchRoll: Creates a rotation matrix from the specified yaw, pitch, and roll.
• CreateNUScaleMatrix: Creates a non-uniform scaling matrix that is offset by a given center point.
• CreateScaleMatrix: Creates a uniform scaling matrix that scales equally on each axis with a center point.
• CreateTranslationMatrix: Creates a translation matrix from the specified 3-dimensional vector.
• MatrixAdd: Adds each element in one matrix with its corresponding element in a second matrix.
• MatrixDecompose: Attempts to extract the scale, translation, and rotation components from the given scale, rotation, or translation matrix.
• MatrixDeterminant: Calculates the determinant of the current 4x4 matrix.
• MatrixEqual: Returns a value that indicates whether two matrices are equal.
• MatrixIdentity: The multiplicative identity matrix.
• MatrixInvert: Inverts the specified matrix.
• MatrixLerp: Performs a linear interpolation from one matrix to a second matrix based on a value that specifies the weighting of the second matrix.
• MatrixMultiply: Returns the matrix that results from multiplying two matrices together.
• MatrixNegate: Negates the specified matrix by multiplying all its values by -1.
• MatrixScale: Returns the matrix that resßults from scaling all the elements of a specified matrix by a scalar factor.
• MatrixSubtract: Subtracts each element in a second matrix from its corresponding element in a first matrix.
• MatrixTransform: Transforms the specified matrix by applying the specified Quaternion rotation.
• MatrixTranslation: Gets the translation component of this matrix.
• MatrixTranspose: Transposes the rows and columns of a matrix.

### Quaternion

• CreateQuaternionFromAxisAngle: Creates a quaternion from a vector and an angle to rotate about the vector.
• CreateQuaternionFromMatrix: Creates a quaternion from the specified rotation matrix.
• CreateQuaternionFromXYZW: Creat a quaternion by it's x,y,z,w value.
• CreateQuaternionFromYawPitchRoll: Creates a new quaternion from the given yaw, pitch, and roll.
• DeconstructQuaternion: Deconstruct Quaternion into X,Y,Z,W
• QuaternionAdd: Adds each element in one quaternion with its corresponding element in a second quaternion.
• QuaternionConcatenate: Concatenates two quaternions.
• QuaternionConjugate: Returns the conjugate of a specified quaternion.
• QuaternionDivide: Divides one quaternion by a second quaternion.
• QuaternionDot: Calculates the dot product of two quaternions.
• QuaternionEqual: Returns a value that indicates whether this instance and another quaternion are equal.
• QuaternionInverse: Returns the inverse of a quaternion.
• QuaternionLength: Calculates the length of the quaternion.
• QuaternionLerp: Performs a linear interpolation between two quaternions based on a value that specifies the weighting of the second quaternion.
• QuaternionMultiply: Returns the quaternion that results from multiplying two quaternions together.
• QuaternionNegate: Reverses the sign of each component of the quaternion.
• QuaternionNormalize: Divides each component of a specified Quaternion by its length.
• QuaternionScale: Returns the quaternion that results from scaling all the components of a specified quaternion by a scalar factor.
• QuaternionSlerp: Interpolates between two quaternions, using spherical linear interpolation.
• QuaternionSubtract: Subtracts each element in a second quaternion from its corresponding element in a first quaternion.

### Vision

• FalconEye: FalconEye, the marker detector detects Apriltags and NyID markers.
• BitmapToFly: Convert System Bitmap to Firefly image.
• FlytoBitmap: Convert Firefly image into standard system bitmap.
• ShowImage: Show bitmap image.

To use marker detection, you need to print out your markers or use it on your pad or phone(not recommended due to strong reflection of screen). Current supported markers are AprilTags and NyID Model2. Remember, a white boarder around marker is necessary for detection.

### Motion

• PathFinder: A solver to instantly find out shortest pass between two points, avoiding given obstacles.

To use marker detection, you need to print out your markers or use it on your pad or phone(not recommended due to strong reflection of screen). Current supported markers are AprilTags and NyID Model2. Remember, a white boarder around marker is necessary for detection.

## Showcases

Here is a showcase of Falcon plugin for marker detection.

You can find some videos below showing possible applications using this plugin.

Robot Localization and Navigation Through Grasshopper:

Robot Pathfinding Through Grasshopper:

## Acknowledgement

This plugin is developed based on .NET Framework 4.6 and Aforge.NET framework. Also thanks to Long Nguyen, researcher from ICD, University of Stuttgart, who helped debug my plugin.