banner



How To Calculate Displacement From Acceleration Data In "Python"

robotic-arm

Now that we know how to derive displacement vectors for different types of robotic artillery, permit's take a look at how to write displacement vectors in lawmaking.

Two Degree of Freedom Robotic Arm

13-add-y-axesJPG

Hither are the two displacement vectors we institute earlier:

1-displacement-vectors-we-found-earlier-1

We've already found the rotation matrices for the two degrees of freedom robotic arm in a previous tutorial. I'll offset by copying and pasting that code into the program.

I volition then write out the 2 displacement vectors.

Make certain that:

  • servo_0_angle = 15   # Joint 1 (Theta 1)
  • servo_1_angle = 60   # Articulation 2 (Theta 2)

Hither is the total code:

import numpy as np # Scientific computing library  # Project: Deportation Vectors for a two DOF Robotic Arm # Writer: Addison Sears-Collins # Appointment created: August 10, 2020  # Servo (joint) angles in degrees servo_0_angle = 15 # Joint 1 (Theta ane) servo_1_angle = 60 # Joint 2 (Theta 2)  # Link lengths in centimeters a1 = 1 # Length of link one a2 = ane # Length of link 2 a3 = 1 # Length of link three a4 = i # Length of link 4  # Convert servo angles from degrees to radians servo_0_angle = np.deg2rad(servo_0_angle) servo_1_angle = np.deg2rad(servo_1_angle)  # Ascertain the start rotation matrix. # This matrix helps catechumen servo_1 frame to the servo_0 frame. # There is simply rotation effectually the z centrality of servo_0. rot_mat_0_1 = np.array([[np.cos(servo_0_angle), -np.sin(servo_0_angle), 0],                         [np.sin(servo_0_angle), np.cos(servo_0_angle), 0],                         [0, 0, 1]])   # Define the second rotation matrix. # This matrix helps catechumen the  # terminate-effector frame to the servo_1 frame. # There is merely rotation around the z axis of servo_1. rot_mat_1_2 = np.array([[np.cos(servo_1_angle), -np.sin(servo_1_angle), 0],                         [np.sin(servo_1_angle), np.cos(servo_1_angle), 0],                         [0, 0, 1]])   # Calculate the rotation matrix that converts the  # end-effector frame to the servo_0 frame. rot_mat_0_2 = rot_mat_0_1 @ rot_mat_1_2  # Brandish the rotation matrix impress(rot_mat_0_2)  # Deportation vector from frame 0 to frame 1. This vector describes # how frame 1 is displaced relative to frame 0. disp_vec_0_1 = np.array([[a2 * np.cos(servo_0_angle)],                          [a2 * np.sin(servo_0_angle)],                          [a1]])  # Displacement vector from frame ane to frame two. This vector describes # how frame ii is displaced relative to frame ane. disp_vec_1_2 = np.array([[a4 * np.cos(servo_1_angle)],                          [a4 * np.sin(servo_1_angle)],                          [a3]])   # Display the displacement vectors print() # Add a infinite print(disp_vec_0_1)  print() # Add together a infinite print(disp_vec_1_2)                

Now run the lawmaking. Here is the output for both the rotation matrix and the displacement vectors:

2-output-displacement-vector-2dof

References

Credit to Professor Angela Sodemann from whom I learned these important robotics fundamentals. Dr. Sodemann teaches robotics over at her website, RoboGrok.com. While she uses the PSoC in her piece of work, I use Arduino and Raspberry Pi since I'm more comfy with these computing platforms. Angela is an splendid teacher and does a fantastic chore explaining various robotics topics over on her YouTube channel.

How To Calculate Displacement From Acceleration Data In "Python",

Source: https://automaticaddison.com/how-to-write-displacement-vectors-in-code-using-python/

Posted by: smithequilad.blogspot.com

0 Response to "How To Calculate Displacement From Acceleration Data In "Python""

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel