forked from generalized-intelligence/GAAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,602 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import rospy | ||
from mavros_msgs.msg import GlobalPositionTarget, State | ||
from mavros_msgs.srv import CommandBool, CommandTOL, SetMode | ||
from geometry_msgs.msg import PoseStamped, Twist | ||
from sensor_msgs.msg import Imu, NavSatFix | ||
from std_msgs.msg import Float32, String | ||
from pyquaternion import Quaternion | ||
import time | ||
import math | ||
|
||
|
||
class Commander: | ||
def __init__(self): | ||
rospy.init_node("commander_node") | ||
rate = rospy.Rate(20) | ||
self.position_target_pub = rospy.Publisher('gi/set_pose/position', PoseStamped, queue_size=10) | ||
self.yaw_target_pub = rospy.Publisher('gi/set_pose/orientation', Float32, queue_size=10) | ||
self.custom_activity_pub = rospy.Publisher('gi/set_activity/type', String, queue_size=10) | ||
|
||
|
||
def move(self, x, y, z, BODY_OFFSET_ENU=True): | ||
self.position_target_pub.publish(self.set_pose(x, y, z, BODY_OFFSET_ENU)) | ||
|
||
|
||
def turn(self, yaw_degree): | ||
self.yaw_target_pub.publish(yaw_degree) | ||
|
||
|
||
# land at current position | ||
def land(self): | ||
self.custom_activity_pub.publish(String("LAND")) | ||
|
||
|
||
# hover at current position | ||
def hover(self): | ||
self.custom_activity_pub.publish(String("HOVER")) | ||
|
||
|
||
# return to home position with defined height | ||
def return_home(self, height): | ||
self.position_target_pub.publish(self.set_pose(0, 0, height, False)) | ||
|
||
|
||
def set_pose(self, x=0, y=0, z=2, BODY_OFFSET_ENU = True): | ||
pose = PoseStamped() | ||
pose.header.stamp = rospy.Time.now() | ||
|
||
# ROS uses ENU internally, so we will stick to this convention | ||
|
||
if BODY_OFFSET_ENU: | ||
pose.header.frame_id = 'base_link' | ||
|
||
else: | ||
pose.header.frame_id = 'map' | ||
|
||
pose.pose.position.x = x | ||
pose.pose.position.y = y | ||
pose.pose.position.z = z | ||
|
||
return pose | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
con = Commander() | ||
time.sleep(2) | ||
con.move(5, 0, 0) | ||
time.sleep(2) | ||
con.turn(90) | ||
time.sleep(2) | ||
con.land() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
K = [ | ||
[376., 0., 376.], | ||
[0., 376., 240.], | ||
[0., 0., 1.] | ||
] | ||
|
||
resolution = (752, 480) | ||
|
||
left_topic='/gi/simulation/left/image_raw' | ||
right_topic='/gi/simulation/right/image_raw' | ||
|
||
object_position_topic='/track_rect_pub' | ||
|
||
init_rect_img_topic = '/gi/simulation/left/image_raw' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from commander import Commander | ||
import time | ||
import rospy | ||
|
||
rospy.init_node('init_drone') | ||
|
||
con = Commander() | ||
|
||
time.sleep(0.5) | ||
|
||
con.move(-5,0,0) | ||
|
||
time.sleep(0.5) |
Oops, something went wrong.