Update
This commit is contained in:
parent
c8d7e36aee
commit
680b83851e
@ -33,6 +33,7 @@ class DroneKitComms:
|
||||
self.steering_endpoint = '/set_steering'
|
||||
self.speed_steering_endpoint = '/set_speed_steering'
|
||||
self.gps_navigation_endpoint = '/go_to_gps'
|
||||
self.goto_heading_endpoint = '/go_to_heading'
|
||||
self.set_state_endpoint = '/set_state'
|
||||
self.get_state_endpoint = '/get_state'
|
||||
self.arm_endpoint = '/arm'
|
||||
@ -100,6 +101,10 @@ class DroneKitComms:
|
||||
data = {'lat': lat, 'lon': lon}
|
||||
_ = self.make_request(self.gps_navigation_endpoint, data)
|
||||
|
||||
def go_to_heading(self, heading):
|
||||
data = {'pickup_heading': heading}
|
||||
_ = self.make_request(self.goto_heading_endpoint, data)
|
||||
|
||||
def set_arm(self):
|
||||
_ = self.make_request(self.arm_endpoint)
|
||||
# print(rsp)
|
||||
|
||||
@ -25,6 +25,7 @@ from pallet_hole_alignment_c import HoleAligner
|
||||
|
||||
DO_ZERO = True
|
||||
DO_GPS_THERE = False
|
||||
DO_GOTO_TARGET_HEADING = False
|
||||
DO_VISION_APPROACH = True
|
||||
DO_FORK_ALIGN = True
|
||||
DO_PICKUP_CARGO = True
|
||||
@ -165,6 +166,16 @@ def queue_executor_thread():
|
||||
else:
|
||||
executor_logger.warning("DO_GPS_THERE flag is false, skipping gps navigation to cargo")
|
||||
|
||||
if DO_GOTO_TARGET_HEADING:
|
||||
FORKLIFT.set_state("NAVIGATING_TO_POINT_GPS")
|
||||
heading_set_success = FORKLIFT.go_to_heading(current_job['pickup_heading'])
|
||||
if not heading_set_success:
|
||||
executor_logger.critical("Go to GPS HEADING was not successful, check logs !")
|
||||
FORKLIFT.set_state("OTHER_ERROR")
|
||||
return False
|
||||
else:
|
||||
executor_logger.warning("DO_GOTO_TARGET_HEADING flag is false, skipping GOTO target heading")
|
||||
|
||||
if DO_VISION_APPROACH:
|
||||
FORKLIFT.set_state("NAVIGATING_TO_POINT_VISION")
|
||||
vision_to_cargo_succcess = __go_to_cargo_vision(VISION_CARGO_APPROACH)
|
||||
|
||||
@ -239,6 +239,18 @@ def go_to_gps():
|
||||
else:
|
||||
return jsonify({'Error': 'Not JSON'})
|
||||
|
||||
@app.route('/go_to_heading', methods=['POST'])
|
||||
def go_to_heading():
|
||||
if request.is_json:
|
||||
content = request.get_json()
|
||||
target_heading = content.get('pickup_heading', -1)
|
||||
assert target_heading >= 0, "Heading missing!"
|
||||
logger.info(f"Navigating to heading: {target_heading}")
|
||||
FORKLIFT.go_to_heading(target_heading)
|
||||
return jsonify({'Success': True})
|
||||
else:
|
||||
return jsonify({'Error': 'Not JSON'})
|
||||
|
||||
@app.route('/get_state', methods=['POST', 'GET'])
|
||||
def get_state():
|
||||
_, state = STATE_MACHINE.get_state()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user