Question

Please help. I need to write a Python program that can display which axis is aligned...

Please help. I need to write a Python program that can display which axis is aligned with
gravity based on Accelerometer readings. This is for a quadcopter drone if that helps.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CONCEPT:

CODE:

import math

class DroneAxis:

    def __init__(self,base_x,base_y,base_z):

        # set the baseline reading from the

        # accelerometer to respective variables

        self.base_x=base_x

        self.base_y=base_y

        self.base_z=base_z

    # def to return the calcualated tilt in x and y directions

    def find_tilt_axis(self,acc_x,acc_y,acc_z):

        result=dict()

        # first we will find the deviation from the baseline readings

        x_val=acc_x-self.base_x

        y_val=acc_y-self.base_y

        z_val=acc_z-self.base_z

        # find the squares of the deviation calculated above

        x_sqr=x_val*x_val

        y_sqr=y_val*y_val

        z_sqr=z_val*z_val

        # calculation of x axis angle

        acc_angle_x=math.atan(x_val/(math.sqrt(y_sqr+z_sqr)))

        result['angle_x']=acc_angle_x

        # calculation of y axis angle

        acc_angle_y=math.atan(y_val/(math.sqrt(x_sqr+z_sqr)))

        result['angle_y']=acc_angle_y

        return result

# Create the object of the DroneAxis class

# Provide basline value for x,y and z axis of the accelerometer

# baseline values from the measurement when accelerometer is stationary and level

objDrone=DroneAxis(0,0,0)

print(objDrone.find_tilt_axis(12.50,21.45,35.00))

RESULT:

SNIPPET:








Add a comment
Know the answer?
Add Answer to:
Please help. I need to write a Python program that can display which axis is aligned...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • python Hi guys, I really need help with that please Can I get help with this...

    python Hi guys, I really need help with that please Can I get help with this python program? Please write clear Show all the steps please, the outcome and follow the directions. Volume # Purpose: This program computes the volume (in liters) of a six-pack of soda cans and the total volume of a six-pack and a two-liter bottle. Complete the following: # Liters in a 12-ounce can and a two-liter bottle. # Number of cans per pack. # Calculate...

  • i need to write a python program that does this. would anyone be able to write...

    i need to write a python program that does this. would anyone be able to write it and show me how it would look? The first program that will display a prompt asking users to put in their names After users put in their names, the program displays greet the users by their names

  • Please help me I need someone to help me with this program in C# please Write...

    Please help me I need someone to help me with this program in C# please Write a program named Admission for a college’s admissions office. The user enters a numeric high school grade point average (for example, 3.2) and an admission test score. Display the message Accept if the student meets either of the following requirements: A grade point average of 3.0 or higher, and an admission test score of at least 60 A grade point average of less than...

  • In python language please! -Include your Python codes and outputs (a) Write a python program which...

    In python language please! -Include your Python codes and outputs (a) Write a python program which first gets two integers a and b from the user, and then by using an if-elif-else structure, display either ("b is greater than a"), ("a is greater than b"), or ("b is equal to a") (b) use a while loop to determine and print the squares of all integers from 1 to 10

  • Write a Python program which prompts the user for a file name then a sentence. Display...

    Write a Python program which prompts the user for a file name then a sentence. Display the number of characters in the sentence and save the sentence to the file name. If the file already exists, ask the user if the file should be overwritten.

  • I need this in Net beans and not Python. Part 1 - Pseudo-code Design and write...

    I need this in Net beans and not Python. Part 1 - Pseudo-code Design and write the pseudo-code for the following Problem Statement. Problem Statement A company gives its employees an that will provide one of 3 results based on the following ranges of scores: Score Message on Report 90-100 Special Commendation 70-89 Pass Below 70 Fail Design a single If-Then-Else structure using pseudo-code which displays one of these messages based a score input by a user. Be sure your...

  • Please help with this python assignment. Thank you. question 1 Write a Python program to read...

    Please help with this python assignment. Thank you. question 1 Write a Python program to read a file line by line store it into a variable. question 2 Write a Python program to read a file line by line store it into an array. question 3 Write a python program to find the longest words. question 4 Write a Python program to count the number of lines in a text file. question 5 Write a Python program to count the...

  • IN PYTHON Write a program that uses a method to display a random text-based emoji out...

    IN PYTHON Write a program that uses a method to display a random text-based emoji out of 5 choices (you decide which 5 emojis make up that choice). Sample output 1: @w@ Sample output 2: T_T

  • Please help with this python turtle problem using the functions provided. Python Turtle Write a program...

    Please help with this python turtle problem using the functions provided. Python Turtle Write a program using the turtle module to draw the face of a clock that looks like the image below. You will need to use the turtle module for this exercise as well as the bgcolor), shape(), color), penup), right(), forward(), pendown(), and stamp() functions. The code below can be removed or changed as needed. import turtle t turtle.Turtle0 t.forward(75)

  • Can you help me write a Python 3.7 code for this question? Write a program using...

    Can you help me write a Python 3.7 code for this question? Write a program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a list. It should then display the following data to back to the user: The list of integers The lowest number in the list The highest number in the list The total sum of all the numbers in the list The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT