Study Muddy
Study Muddy

Upload, organize, preview, and share study documents from one clean workspace.

Explore

BrowseAbout UsContact Us

Workspace

UploadDashboard

Legal

Privacy PolicyTerms & ConditionsDisclaimerReport Copyright & Abuse
Study Muddy
PDF·0% (0)·0 views·4 pages

Rust Path Planning Project: Linear and Rotational Motion

Project overview for a Rust program that parses command files and calculates linear and rotational motion paths, with tests and example usage.

Category: Technology

Uploaded by Megan Turner on May 4, 2026

Copyright

© All Rights Reserved

We take content rights seriously. If you suspect this is your content, claim it here.

Available Formats

Download as PDF or TXT.

Download PDF
/ 4
100%
4

Document text

AI Detector - Trusted AI Checker for ChatGPT, GPT4 & Gemini

https://www.zerogpt.com/

ZeroGPT

Trusted GPT-4, ChatGPT and AI Detector tool by ZeroGPT

ZeroGPT the most Advanced and Reliable Chat GPT, GPT4 & AI Content Detector

AI/GPT Detector

ZeroCHAT-4 & 5

AI Summarizer

AI Paraphraser

AI Grammar & Spell Checker

AI Translator

Word Counter

Citation Generator

Overview

This project is made in rust, to let us experience path planning in robotics. To experience path planning we are doing two operations, linear motion and rotational motion. In linear motion, we will be give start point and end point we need to print path to which we can get there in one-unit increment. Similarly, in rotational motion we will be given a position of circle, it radius and a direction (clockwise or counterclockwise), and a end point, we need to print the path to reach end point at 5 degree interval. In this project we will implement these following things:

o File reading: Read the give "*.cmd" file

o Text parsing: Take the text and parse it appropriately

o Linear Motion Calculation

o Rotational Motion Calculation

Modules and Imports

Detect Text

Upload File

7,533/15,000 Characters (Get up to 100,000 here)

Your Text is Human written

0%

AI GPT*

Overview

AI Detector - Trusted AI Checker for ChatGPT, GPT4 & Gemini

https://www.zerogpt.com/

o File reading: Read the give "*.cmdd" file.

o Text parsing: Take the text and parse it appropriately

o Linear Motion Calculation

o Rotational Motion Calculation

Modules and Imports

First import all the necessary modules for the program to run.

These imports will help the program to take the necessary library for calculation, testing, reading and parsing the file.

Function: parse_file

The function is responsible for parsing the given file to text so that we can do operation on that obtained text(string).

• Input: File path, where the file is located.

• Output: Return vector of vector of string, where each string will be a single word from the file which is given a input.

This function takes the file path as input and gives us the string written in that file. It does this by first making a string to hold file content then using fs library to read the contents of that file into that string. Then break this string by whitespaces and stores in the vector then returns it.

Function: linear_motion

The function basically calculate the linear motion between two points namely start and end point by incrementing by 1 step.

Input: Takes start point coordinates in 3-D world (x,y,z) in float value, same for end point.

Output: Return vector filled with the path, which to follow to reach from start to end.

The function does this by creating an empty vector to first to store the result, then do some basic checking like if start and end are same, the just add start point, else it calculate the number of steps needed to motion by calculating increment for each axis and finding which one is the largest.

Function: rotational_motion

The function like linear motion, finds a path from start to end point but in circular motion either clockwise or anticlockwise, so basically from start angle to end angle.

Input: Location of centre of circle for which we need to rotate in float (as x, y, z), radius of that circle in float, start angle, end angle, clockwise or anticlockwise boolean value.

Output: Return the coordinates which to follow to reach the path, that is from start angle to end angle.

The function works by taking the input and checking first whether to do clockwise or anti clockwise motion. If clockwise motion we do angle increment of 5, otherwise decrement of 5. We start rotating the angle until it exceeded end angle, and calculate new position based of current angle for each angle in that loop. We push those position into the vector. And return those vector coordinates.

Function: process_commands

The function has been made to process command from the file, or basically parse those commands which we got from the "*.cmdd" file.

2 of 9

05/05/2024, 5:29 pm

AI Detector - Trusted AI Checker for ChatGPT, GPT4 & Gemini

https://www.zerogpt.com/

• Input: Takes input as vector of vector of string which is basically and output of parse file function.

• Output: Not return anything.

The function takes the string and iterate over all those words of a given command. Print the command which is getting processed. We initialized start to 0,0 and end is given in the command file. In the command line then we see, if first word is “LIN” then it is linear motion, if first word is “CW or CCW” then it is rotational motion, we then call their function linear motion in the case of “LIN” and rotational motion in the case of “CW or CCW”. Afterwards, we print the path which we get from either of the functions.

Function: main

This function is made to call the other function and run the code.

• Output: Return OK to indicate success.

This function calls the other function one by one so that our code can work. First, we define the path of command file. Then we call parse file function on that file, then we call process command function on the give commands which we got form parse file function. Then we return OK to indicate success of the code running.

Testing Module: tests

We use this command to define the test module, with conditional compilation, that is it will not compile everytime, it will only compile when we want it to.

In this test module, different types of test are there which will test the robustness of our main.rs code and verify that our code handles all the errors and does not break if it catches some anomalies.

Test Function: test_lm_zero

This test call linear motion function and test if the start and end point are same then what will happen, whether the code will break or throw error or will successfully execute.

For this we put start position as 0, 0, 0 and end as the same and called linear motion function.

Test Function: test_lm_negative

This test is to ensure whether our linear motion function can handle negative coordinates or not, if it doesn’t we need to handle that edge case in our main code.

This test work by taking start and -5, -5, -5 and end as -10, -10, -10 and then calls linear motion function.

Test Function: test_rm_full

This test check the rotational motion with full circle, whether when we go full circle the code will break or not.

For this we take start angle as 0 and end angle as 360 and radius as 5 and center as 0,0,0 and run the rotational function using these parameters.

Test Function: test_rm_zero

This test is done to show that when start angle and end angle are same and no movement takes place in the circle.

This test will show whether rotational motion function will show some abnormal behaviour or not.

3 of 9

05/05/2024, 5:29 pm

AI Detector - Trusted AI Checker for ChatGPT, GPT4 & Gemini

https://www.zerogpt.com/

For this we took start angle as 0 and end angle as 0 and radius as 5 and centre as 0, 0, 0 and called rotational motion function.

Test Function: test_rm_negative

This test is done to check whether rotational motion function can handle negative angle or not, whether it will show correct result when we give negative angle as a parameter.

For this test we took start angle as -180 and end angle as 180 center as 0, 0, 0 and radius as 5, and then called rotational motion function.

Test Function: test_rm_large

This test if the angle is more than 360 can it handle the angle and gives us correct path for the same.

For this we took one angle as 720 and other as 0 and ran rotational motion on the same.

Example Usage

To use the program, you will need a commands file, if you don’t have that then create some commands and save as "data.cmmd", then you can put the correct path of that file in the main function.

To run that command file call cargo run in the terminal and press enter.

You will see the output, of all the commands that you have typed.

This is output of linear motion from 5, 5, 5 to 0, 0, 0.

To run all the test call cargo test in the terminal and press enter.

You will see results of all the test.

Conclusion

The code is important to understand robotics file path and how they move it is the basic foundation function for that.

By writing the functions we got the grasp of how motion works particularly linear and rotational motion. Usage of rust is also very essential as it showed usage to rust gives us better tooling and gave us more exposure to the rust programming which has its own significant advantages.

Highlighted text is suspected to be most likely generated by AI*

7,533 Characters

1,341 Words

4 of 9

PDF

Export to PDF

Upgrade to Pren

Related documents

DOCX
Reflective Report on Risk Plan for Rent Management System in Java
Reflective Report on Risk Plan for Rent Management System in Java

3 pages

0% (0)
DOCX
Library Management System Software Requirement Specification
Library Management System Software Requirement Specification

6 pages

0% (0)
PDF
CS725 Machine Learning Lecture Notes
CS725 Machine Learning Lecture Notes

116 pages

0% (0)
DOCX
The Role of Information Systems in the Data Mining Process
The Role of Information Systems in the Data Mining Process

6 pages

0% (0)
DOCX
Server Types and Selection for Cost and Performance Optimization
Server Types and Selection for Cost and Performance Optimization

2 pages

0% (0)
DOCX
SQL Database Query and Update Exercises
SQL Database Query and Update Exercises

6 pages

0% (0)
DOCX
Library Management System Software Requirements Specification
Library Management System Software Requirements Specification

6 pages

0% (0)
DOCX
Application of Data Science Management in Public Transport
Application of Data Science Management in Public Transport

1 pages

0% (0)
DOCX
Argument and Claim on ChatGPT Ethics and AI Policy
Argument and Claim on ChatGPT Ethics and AI Policy

4 pages

0% (0)
DOCX
The Dream Weaver: A Tapestry of Artificial Imagination
The Dream Weaver: A Tapestry of Artificial Imagination

2 pages

0% (0)