I want to perform the operation: roll_all-theta_all
. Both of them are lists
containing two values each and the result is supposed to be listed in the column named 'roll' on my panda.DataFrame
. However when I do so, the 2nd row value of column 'roll' does not add up. Although it cannot be seen because I perform theta_all
operation in other parts of my code, I obtain the values the same way I obtain the values of roll_all
, ie, by creating an empty list
and then append the values to it. Here is my code:
pyr = pd.DataFrame(columns = ['pitch','yaw','roll'])
for para in GTparas:
Mr = np.array([[np.cos(para[2]), -np.sin(para[2]), 0],[np.sin(para[2]), np.cos(para[2]), 0],[0, 0, 1]])
My = np.array([[np.cos(para[1]), 0, np.sin(para[1])],[0, 1, 0],[-np.sin(para[1]), 0, np.cos(para[1])]])
Mp = np.array([[1, 0, 0],[0, np.cos(para[0]), -np.sin(para[0])],[0, np.sin(para[0]), np.cos(para[0])]])
M1 = np.dot(Mr,My)
M = np.dot(M1,Mp)
pitch = np.arctan(M[2,1]/M[2,2])
yaw = np.arctan(M[2,0]/((((M[0,0])**2)+((M[1,0])**2))**(1/2)))
roll = np.arctan(M[1,0]/M[0,0])
roll_all = []
roll_all.append(roll)
print(roll_all)
c = [a - b for a, b in zip(roll_all, theta_all)]
#c = np.array(roll_all) - np.array(theta_all)
pyr = pyr.append({'pitch':pitch,'yaw':yaw,'roll':c},ignore_index = True) # from Z-Y-X to X-Y-Z
print(pyr)
I am also attaching the values in my lists for theta_all
and the second image shows the values in roll_all
and what I get when I print pyr
.
Summarizing:
pyr = pd.DataFrame(columns = ['pitch','yaw','roll'])
for para,theta in zip(GTparas, theta_all):
Mr = np.array([[np.cos(para[2]), -np.sin(para[2]), 0],[np.sin(para[2]), np.cos(para[2]), 0],[0, 0, 1]])
My = np.array([[np.cos(para[1]), 0, np.sin(para[1])],[0, 1, 0],[-np.sin(para[1]), 0, np.cos(para[1])]])
Mp = np.array([[1, 0, 0],[0, np.cos(para[0]), -np.sin(para[0])],[0, np.sin(para[0]), np.cos(para[0])]])
M1 = np.dot(Mr,My)
M = np.dot(M1,Mp)
pitch = np.arctan(M[2,1]/M[2,2])
yaw = np.arctan(M[2,0]/((((M[0,0])**2)+((M[1,0])**2))**(1/2)))
roll = np.arctan(M[1,0]/M[0,0]) - theta
pyr = pyr.append({'pitch':pitch,'yaw':yaw,'roll':roll},ignore_index = True)
print(pyr)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.