Skip to content

Commit

Permalink
scripts: mavsetp: Enable OFFBOARD mode.
Browse files Browse the repository at this point in the history
Issue #126.
  • Loading branch information
vooon committed Aug 25, 2014
1 parent 170c2ae commit e791807
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mavros/scripts/mavsetp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import argparse
import rospy
from std_msgs.msg import Header
from geometry_msgs.msg import TwistStamped, PoseStamped, Vector3, Point
from mavros.srv import CommandBool

_ONCE_DELAY = 3

Expand All @@ -51,6 +52,14 @@ def publish_once(args, pub, msg):
rospy.sleep(0.2)


def enable_offboard(args):
try:
guided_enable_cl = rospy.ServiceProxy(args.mavros_ns + "/cmd/guided_enable", CommandBool)
ret = guided_enable_cl(value=True)
except rospy.ServiceException as ex:
fault(ex)


def do_local_pos(args):
pub = rospy.Publisher(args.mavros_ns + "/setpoint/local_position", PoseStamped,
queue_size=10, latch=True)
Expand All @@ -60,6 +69,7 @@ def do_local_pos(args):
pos.pose.position = Point(x=args.position[0], y=args.position[1], z=args.position[2])

publish_once(args, pub, pos)
enable_offboard(args)


def do_local_vel(args):
Expand All @@ -71,6 +81,7 @@ def do_local_vel(args):
vel.twist.linear = Vector3(x=args.velocity[0], y=args.velocity[1], z=args.velocity[2])

publish_once(args, pub, vel)
enable_offboard(args)


def do_local_selector(args):
Expand Down

0 comments on commit e791807

Please sign in to comment.