-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please review my PR and suggest the required changes #1
base: main
Are you sure you want to change the base?
Changes from 17 commits
9d70697
32ca7b1
df1afc0
e5549c0
0d0f57d
636b0df
cb22cd1
1f95c36
e416f62
e06870c
2478424
eab64e2
f1a12bc
43abf5d
1f8cb67
89b51b1
1d6e205
62d226b
bef7373
f48880a
3844493
4a1ed59
e6984fd
3ff054e
1eb379d
8915fb9
596fb58
6099d30
9431889
86f4d18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,77 @@ | ||
# Drone-Simulation | ||
# Drone-Simulation | ||
## Abstract | ||
|
||
A simulation of a basic drone model take-off up to a given altitude in a gazebo environment; with a PX4 autopilot supported by Mavros in Ubuntu. | ||
|
||
![Final Product](https://github.com/abyasingh/Drone-Simulation/blob/main/Images%20and%20Videos/Images/Simultion%20of%20drone.png) | ||
|
||
## Motivation | ||
|
||
<p align="justify">As the technology is advancing every single day, we come across new tools which are aimed towards making our lives simpler and more comfortable. Drone is one such device enhances the quality of human life.<br><br>Creating a simulation provides the required insight into working of an actual drone. Having a simulation before construction of an actual model is an integral step as it provides a chance to eliminate any error which might disastrous for the model. Creating an outline is always a good beginning of a project of any sort.<br><br>During the covid times, people were instructed to refrain from going outside and to avoid public gatherings. It was when the usefulness of drones came into limelight. The cameras installed in drones provided a much-needed assistance in keeping a check over a locality without actually going over to that place. They were also utilized in transportation of small objects, ones within their capacity. Apart from the usual activities carried out by drones, they can be modified and enhanced to carry out complex tasks as well.</p> | ||
|
||
## Software Aspects | ||
|
||
### MavROS | ||
|
||
<p align="justify">The Robot Operating System (ROS) is basically an open-source framework that helps in building and reusing codes between robotics applications. Basically, it acts as an interface for robots.<br><br>We needed an operating system which would help run our model. For that, we installed the noetic version of ROS. Mavros is a ROS package that enables MAVLink extendable communication between computers running ROS for any MAVLink enabled structure like an autopilot.</p> | ||
|
||
### PX4 | ||
|
||
<p align="justify">An autopilot was required to transmit our commands to the system. PX4 is a suitable source for that. It is an open source flight control software for drones and other unmanned vehicles. It provides the required set of tools for drone developers to share technologies and create proper solutions for drone applications. We used the most basic inbuilt iris model for our project. | ||
|
||
> roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557" | ||
Nageshbansal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</p> | ||
|
||
### Gazebo | ||
|
||
<p align="justify">Next, we installed Gazebo9-3D dynamic simulator. It is a high-class simulator that allows simulation of real-life environment, providing efficient simulation of varieties of robots in complex indoor and outdoor environments. It allows us to include practical forces such as gravity and friction. | ||
|
||
> make px4_sitl gazebo | ||
</p> | ||
|
||
### Take-off script | ||
|
||
<p align="justify">Finally, we needed a script for takeoff of our drone. A launch file was also needed. We create a python script in VS Code for this execution. | ||
|
||
![Takeoff_P1](https://github.com/abyasingh/Drone-Simulation/blob/main/Images%20and%20Videos/Images/Take-off%20Scrpit%20P1.png) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of adding screenshots of the code, you can add snippets or just add the URL to the script. |
||
![Takeoff_P2](https://github.com/abyasingh/Drone-Simulation/blob/main/Images%20and%20Videos/Images/Take-off%20Scrpit%20P2.png) | ||
![Takeoff_P3](https://github.com/abyasingh/Drone-Simulation/blob/main/Images%20and%20Videos/Images/Take-off%20Scrpit%20P3.png) | ||
![Takeoff_P4](https://github.com/abyasingh/Drone-Simulation/blob/main/Images%20and%20Videos/Images/Take-off%20Scrpit%20P4.png) | ||
|
||
Some of the commands being executed: | ||
|
||
> 1. modes.setTakeoff() | ||
> 2. rate.sleep() | ||
> 3. modes.setOffboardMode() | ||
|
||
</p> | ||
|
||
## Applications | ||
|
||
<p align="justify">There are numerous significant applications of drone in our everyday lives. Some of the prominent ones include Aerial photography & videography, mapping & surveying, delivering goods, in search and rescue operations after a natural disaster, in security and military purposes.</p> | ||
|
||
## Limitations | ||
|
||
<p align="justify">Since this is just a simulation, original device must be constructed with utmost precision. Drones as of yet haven’t been designed to transport large objects, the ones beyond their limitation. The other properties such as photographing and flying capacity depend on the mechanical aspects and hence are limited too.</p> | ||
|
||
## Improvements | ||
|
||
<p align="justify">In this project, we used auto mode of noetic version which is not compatible with take-off command. Exploration of the different modes in noetic version of ROS such as guided and machine modes would be a prime aim. </p> | ||
|
||
Nageshbansal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Team Members | ||
|
||
1. [Abya Singh](https://github.com/abyasingh) | ||
2. [Gorle Apurva](https://github.com/apurvaa_2507) | ||
|
||
## Mentors | ||
|
||
1. [Nagesh Bansal](https://github.com/Nageshbansal) | ||
2. [Harshini S.](https://github.com/Harshini-festus) | ||
Nageshbansal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## References | ||
|
||
1. [For installation of noetic version of Ubuntu](http://wiki.ros.org/noetic/Installation/Ubuntu) | ||
Nageshbansal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
2. [For installation of Mavros](https://github.com/immersive-command-system/drone-mavros) | ||
3. [For installation of PX4](https://github.com/PX4/PX4-SITL_gazebo>) | ||
4. [For installation of Gazebo](https://dev.px4.io/v1.10_noredirect/en/simulation/gazebo.html) | ||
5. [For launch file and iris model](https://docs.google.com/document/d/1re3MQy0Hwsjt1Ko96EiTB5wvbq_4QYZSZKgVmZGWsmg/edit) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
#!/usr/bin/env python3 | ||
import rospy | ||
from geometry_msgs.msg import Point, PoseStamped | ||
from mavros_msgs.msg import * | ||
from mavros_msgs.srv import * | ||
rospy.init_node('setpoint_node') | ||
|
||
class fcuModes: | ||
def __init__(self): | ||
pass | ||
|
||
def setTakeoff(self): | ||
print('waiting for service') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add comments in code for each of the method/functions and classes |
||
# rospy.wait_for_service('mavros/cmd/takeoff') | ||
takeoffService = rospy.ServiceProxy('mavros/cmd/takeoff', mavros_msgs.srv.CommandTOL) | ||
print('got') | ||
try: | ||
takeoffService = rospy.ServiceProxy('mavros/cmd/takeoff', mavros_msgs.srv.CommandTOL) | ||
takeoffService(altitude = 10) | ||
except rospy.ServiceException as e: | ||
print ("Service takeoff call failed: %s"%e) | ||
|
||
def setArm(self): | ||
rospy.wait_for_service('mavros/cmd/arming') | ||
try: | ||
armService = rospy.ServiceProxy('mavros/cmd/arming', mavros_msgs.srv.CommandBool) | ||
armService(True) | ||
except rospy.ServiceException as e: | ||
print ("Service arming call failed: %s"%e) | ||
|
||
def setDisarm(self): | ||
rospy.wait_for_service('mavros/cmd/arming') | ||
try: | ||
armService = rospy.ServiceProxy('mavros/cmd/arming', mavros_msgs.srv.CommandBool) | ||
armService(False) | ||
except rospy.ServiceException as e: | ||
print ("Service disarming call failed: %s"%e) | ||
|
||
def setStabilizedMode(self): | ||
rospy.wait_for_service('mavros/set_mode') | ||
try: | ||
flightModeService = rospy.ServiceProxy('mavros/set_mode', mavros_msgs.srv.SetMode) | ||
flightModeService(custom_mode='STABILIZED') | ||
except rospy.ServiceException as e: | ||
print ("service set_mode call failed: %s. Stabilized Mode could not be set."%e) | ||
|
||
def setOffboardMode(self): | ||
rospy.wait_for_service('mavros/set_mode') | ||
try: | ||
flightModeService = rospy.ServiceProxy('mavros/set_mode', mavros_msgs.srv.SetMode) | ||
flightModeService(custom_mode='OFFBOARD') | ||
except rospy.ServiceException as e: | ||
print ("service set_mode call failed: %s. Offboard Mode could not be set."%e) | ||
|
||
def setAltitudeMode(self): | ||
rospy.wait_for_service('mavros/set_mode') | ||
try: | ||
flightModeService = rospy.ServiceProxy('mavros/set_mode', mavros_msgs.srv.SetMode) | ||
flightModeService(custom_mode='ALTCTL') | ||
except rospy.ServiceException as e: | ||
print ("service set_mode call failed: %s. Altitude Mode could not be set."%e) | ||
|
||
def setPositionMode(self): | ||
rospy.wait_for_service('mavros/set_mode') | ||
try: | ||
flightModeService = rospy.ServiceProxy('mavros/set_mode', mavros_msgs.srv.SetMode) | ||
flightModeService(custom_mode='POSCTL') | ||
except rospy.ServiceException as e: | ||
print ("service set_mode call failed: %s. Position Mode could not be set."%e) | ||
|
||
def setAutoLandMode(self): | ||
rospy.wait_for_service('mavros/set_mode') | ||
try: | ||
flightModeService = rospy.ServiceProxy('mavros/set_mode', mavros_msgs.srv.SetMode) | ||
flightModeService(custom_mode='AUTO.LAND') | ||
except rospy.ServiceException as e: | ||
print ("service set_mode call failed: %s. Autoland Mode could not be set."%e) | ||
|
||
class Controller: | ||
def __init__(self): | ||
self.state = State() | ||
self.sp = PositionTarget() | ||
self.sp.type_mask = int('010111111000', 2) | ||
self.sp.coordinate_frame = 1 | ||
|
||
self.ALT_SP = 3.0 | ||
self.sp.position.z = self.ALT_SP | ||
self.STEP_SIZE = 2.0 | ||
self.FENCE_LIMIT = 5.0 | ||
|
||
self.local_pos = Point(0.0, 0.0, 3.0) | ||
|
||
0 self.sp.position.x = 0.0 | ||
self.sp.position.y = 0.0 | ||
|
||
def posCb(self, msg): | ||
self.local_pos.x = msg.pose.position.x | ||
self.local_pos.y = msg.pose.position.y | ||
self.local_pos.z = msg.pose.position.z | ||
|
||
def stateCb(self, msg): | ||
self.state = msg | ||
|
||
def updateSp(self): | ||
self.sp.position.x = self.local_pos.x | ||
self.sp.position.y = self.local_pos.y | ||
|
||
def x_dir(self): | ||
self.sp.position.x = self.local_pos.x + 5 | ||
self.sp.position.y = self.local_pos.y | ||
|
||
def neg_x_dir(self): | ||
self.sp.position.x = self.local_pos.x - 5 | ||
self.sp.position.y = self.local_pos.y | ||
|
||
def y_dir(self): | ||
self.sp.position.x = self.local_pos.x | ||
self.sp.position.y = self.local_pos.y + 5 | ||
|
||
def neg_y_dir(self): | ||
self.sp.position.x = self.local_pos.x | ||
self.sp.position.y = self.local_pos.y - 5 | ||
|
||
|
||
while not rospy.is_shutdown(): | ||
modes = fcuModes() | ||
cnt = Controller() | ||
rate = rospy.Rate(100.0) | ||
|
||
rospy.Subscriber('mavros/state', State, cnt.stateCb) | ||
|
||
rospy.Subscriber('mavros/local_position/pose', PoseStamped, cnt.posCb) | ||
|
||
sp_pub = rospy.Publisher('mavros/setpoint_raw/local', PositionTarget, queue_size=1) | ||
|
||
modes.setTakeoff() | ||
rate.sleep() | ||
|
||
while not cnt.state.armed: | ||
modes.setArm() | ||
|
||
k=0 | ||
while k<10: | ||
sp_pub.publish(cnt.sp) | ||
rate.sleep() | ||
k = k + 1 | ||
|
||
modes.setOffboardMode() | ||
|
||
|
||
cnt.updateSp() | ||
sp_pub.publish(cnt.sp) | ||
rate.sleep() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
images should be enclosed in the
<p>
tags, so that they can be aligned in the center