Skip to content
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

Survey manager execute goals script #103

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
67f9c50
making spawn changes and adding double handed cargo
marinagmoreira Jun 22, 2023
719b744
Merge branch 'develop' of github.com:nasa/isaac into develop
marinagmoreira Jun 27, 2023
58176a9
Merge branch 'develop' of github.com:nasa/isaac into develop
marinagmoreira Jul 19, 2023
dfb9ad7
adding a proof of concept example of the executor
marinagmoreira Nov 9, 2023
796695b
running through isort
marinagmoreira Nov 9, 2023
e16eefe
Merge branch 'develop' of github.com:nasa/isaac into survey_manager_e…
marinagmoreira Nov 13, 2023
8456b90
committing before changing things around
marinagmoreira Nov 15, 2023
ad57def
Merge branch 'develop' of github.com:nasa/isaac into survey_manager_e…
marinagmoreira Nov 16, 2023
255143d
sockets working
marinagmoreira Nov 27, 2023
a7c09ca
fix lint
marinagmoreira Nov 27, 2023
e63ff36
adding example action node
marinagmoreira Dec 7, 2023
626a51f
update to scripts with new requirements
marinagmoreira Dec 11, 2023
1686c12
thread join safeguard
marinagmoreira Dec 12, 2023
30c761d
running isort
marinagmoreira Dec 12, 2023
c84eff2
Plansys2 on Astrobee Noetic (#107)
Bckempa Dec 12, 2023
4508014
bug fixes
marinagmoreira Dec 14, 2023
649ea5c
fixes
marinagmoreira Dec 14, 2023
2647bac
Update ci_pr.yml
marinagmoreira Dec 14, 2023
a881ffa
Merge branch 'survey_manager' of github.com:nasa/isaac into survey_ma…
marinagmoreira Dec 14, 2023
d7ea2f5
moving executor to different package hierarchy
marinagmoreira Dec 21, 2023
e58c7f4
Merge branch 'develop' of github.com:nasa/isaac into survey_manager_e…
marinagmoreira Jan 5, 2024
b8ae5aa
consolidating packages; action compiling
marinagmoreira Jan 5, 2024
2376fc6
tested action
marinagmoreira Jan 8, 2024
fb0c57c
submodule update
marinagmoreira Jan 9, 2024
adf0b81
move scripts into package
marinagmoreira Jan 9, 2024
d724113
changing static config to be more general
marinagmoreira Jan 9, 2024
a11b640
fixing config name + install data folder
marinagmoreira Jan 9, 2024
af52e73
restoring comms to readline
marinagmoreira Jan 10, 2024
362763b
getting details sorted
marinagmoreira Jan 10, 2024
d3d3228
making output more readable
marinagmoreira Jan 10, 2024
5e89aa4
installing script to be found in robot install
marinagmoreira Jan 12, 2024
8038c1f
adding move action starting correct process
marinagmoreira Jan 15, 2024
ab97e93
adding parameters for easy testing
marinagmoreira Jan 15, 2024
55d4402
fixes on command astrobee
marinagmoreira Jan 15, 2024
9a3e191
add remaining actions + documentation
marinagmoreira Jan 17, 2024
86b7990
running isort
marinagmoreira Jan 17, 2024
8d4f72a
Use exec and waitpid instead of reading output.
bcoltin Jan 18, 2024
6a18416
Change all action nodes to use the same class.
bcoltin Jan 18, 2024
8ef602d
install all nodes
marinagmoreira Jan 18, 2024
efd9ac7
adding remote option with no parameter adjusting, we'll do panoramas …
marinagmoreira Jan 19, 2024
903105c
reset progress after one action
marinagmoreira Jan 19, 2024
adf6eb2
adding inspection lib; fixing output
marinagmoreira Jan 20, 2024
4ad2bdd
fixing robot install
marinagmoreira Jan 20, 2024
64e8bf5
tested all 5 actions in the granite table
marinagmoreira Jan 20, 2024
12663c3
remote plansys2 submodules from doxygen
marinagmoreira Jan 20, 2024
8b61b23
splitting documentation
marinagmoreira Jan 20, 2024
49add14
addressing tons of comments on PR, lab tested
marinagmoreira Jan 20, 2024
c5c76a7
Merge branch 'develop' of github.com:nasa/isaac into survey_manager_e…
marinagmoreira Jan 20, 2024
a5ca4c8
more PR reviews
marinagmoreira Jan 20, 2024
d1522ba
more PR reviews
marinagmoreira Jan 20, 2024
29ff61b
more PR reviews
marinagmoreira Jan 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions astrobee/behaviors/inspection/tools/inspection_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ geometry_msgs::PoseArray ReadPosesFile(std::string file) {
quat_robot.setRPY(euler_roll * DEG2RAD, euler_pitch * DEG2RAD, euler_yaw * DEG2RAD);

} else {
std::cout << "Ignoring invalid line: " << line << std::endl;
// std::cout << "Ignoring invalid line: " << line << std::endl;
continue;
}
}
Expand Down Expand Up @@ -390,7 +390,7 @@ void ConnectedCallback(
if (!client->IsConnected()) return;
// Print out a status message
std::cout << "\r "
<< "\rState: CONNECTED" << std::flush;
<< "\rState: CONNECTED\n" << std::flush;
SendGoal(client);
}

Expand Down
56 changes: 56 additions & 0 deletions astrobee/survey_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright (c) 2021, United States Government, as represented by the
# Administrator of the National Aeronautics and Space Administration.
#
# All rights reserved.
#
# The "ISAAC - Integrated System for Autonomous and Adaptive Caretaking
# platform" software is licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

cmake_minimum_required(VERSION 3.0)
project(survey_manager)

## Compile as C++14, supported in ROS Kinetic and newer
add_compile_options(-std=c++14)

## Find catkin macros and libraries
SET(catkin2_DIR "${CMAKE_SOURCE_DIR}/../../../cmake")
find_package(catkin2 REQUIRED COMPONENTS
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)

###################################
## catkin specific configuration ##
###################################

catkin_package(
)

###########
## Build ##
###########

# Specify additional locations of header files
# Your package locations should be listed before other locations
include_directories(
${catkin_INCLUDE_DIRS}
)


#############
## Install ##
#############

catkin_install_python(PROGRAMS scripts/command_astrobee
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
marinagmoreira marked this conversation as resolved.
Show resolved Hide resolved
21 changes: 21 additions & 0 deletions astrobee/survey_manager/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<package format="2">
<name>survey_manager</name>
<version>0.0.0</version>
<description>The survey_manager package</description>
<license>
Apache License, Version 2.0
</license>
<author email="[email protected]">
ISAAC Flight Software
</author>
<maintainer email="[email protected]">
ISAAC Flight Software
</maintainer>

<buildtool_depend>catkin</buildtool_depend>

<export>
<nodelet plugin="${prefix}/nodelet_plugins.xml" />
</export>
</package>
152 changes: 152 additions & 0 deletions astrobee/survey_manager/scripts/command_astrobee
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/usr/bin/env python
marinagmoreira marked this conversation as resolved.
Show resolved Hide resolved
#
# Copyright (c) 2021, United States Government, as represented by the
# Administrator of the National Aeronautics and Space Administration.
#
# All rights reserved.
#
# The "ISAAC - Integrated System for Autonomous and Adaptive Caretaking
# platform" software is licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import argparse
import subprocess
import sys



# command = 'rosrun inspection inspection_tool -panorama -panorama_poses /resources/panorama_iss.txt -panorama_mode "5_mapper_and_hugin"'


def send_command_with_input(command):
print(command)

# Start the process
process = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=sys.stdout, stderr=subprocess.PIPE, text=True)

try:
while process.poll() is None:

# Get user input dynamically
user_input = input()

# Check if the user wants to exit
if user_input.lower().strip() == 'exit':
break

# Send the user input to the process
process.stdin.write(user_input + "\n")
process.stdin.flush()

# Close stdin to indicate no more input will be sent
process.stdin.close()

# Read output and error (if any)
output, error = process.communicate()

# Get the final exit code
return process.returncode

except:
return -1


def send_command(command):
print(command)
process = subprocess.Popen(command, shell=True, stdout=sys.stdout, stderr=sys.stdout, text=True)
marinagmoreira marked this conversation as resolved.
Show resolved Hide resolved

# Get the output and error (if any)
return process.wait()

def get_position(bay):

if bay == "jem_bay1":
return "'11, -4, 4.8'"
if bay == "jem_bay2":
return "'11, -5, 4.8'"
if bay == "jem_bay3":
return "'11, -6, 4.8'"
if bay == "jem_bay4":
return "'11, -7, 4.8'"
if bay == "jem_bay5":
return "'11, -8, 4.8'"
if bay == "jem_bay6":
return "'11, -9, 4.8'"
if bay == "jem_bay7":
return "'11, -9.7, 4.8'"
marinagmoreira marked this conversation as resolved.
Show resolved Hide resolved


def repeat_inspection():
while True:
user_input = input("Do you want to continue? (y/n): ").lower().strip()
if user_input == 'y':
if send_command_with_input("rosrun inspection inspection_tool -resume") != 0:
repeat_inspection() # Continue recursively
break
elif user_input == 'n':
print("Exiting.")
break
else:
print("Invalid input. Please enter 'y' or 'n'.")


def survey_manager_executer(goal, bay, run):

if goal == "dock":
send_command("rosrun executive teleop -dock")

elif goal == "dock":
send_command("rosrun executive teleop -undock")

elif goal == "move":
send_command("rosrun executive teleop -move -pos " + bay)

elif goal == "panorama":
send_command("python gds_helper_batch.py -i cmd -- bagger -start pano_" + bay + "_" + run)
if send_command_with_input("rosrun inspection inspection_tool -panorama -panorama_mode '5_mapper_and_hugin' -pos " + str(get_position(bay))) != 0:
repeat_inspection()
send_command("python gds_helper_batch.py -i cmd -- bagger -stop")

elif goal == "stereo":
send_command("python gds_helper_batch.py -i cmd -- bagger -start stereo_" + bay + "_" + run)
send_command("python gds_helper_batch.py -i cmd -- plan -load plans/ISAAC/" + bay + "_stereo_mapping.fplan")
send_command("python gds_helper_batch.py -i cmd -- plan -run")
send_command("python gds_helper_batch.py -i cmd -- bagger -stop")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a work in progress, just wanted to re-raise some issues we've discussed that need resolution;

  • Propagating errors up from these subcommands to represent action failure (may be a good place to use Python exceptions)
  • But probably good to have a default interactive retry loop around most commands (continues on success, waits for operator feedback about retry on failure, and if you choose retry the plansys2 executor is never told about the failure). For the multi-subcommand actions, it's an interesting question whether the retry should wrap around the whole sequence or the individual subcommands.
  • Some subcommands (bagger -stop) sort of want to be in a Python finally: clause so they always get run even if an earlier command fails.
  • Multi-robot will affect this somehow. Probably either wrapping other-robot commands in ssh or somehow namespacing the ROS topics.



class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter):
pass


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=CustomFormatter
)

parser.add_argument(
"command_name",
help="Prefix for bagfiles to merge. Bags should all be in the current working directory.",
)
parser.add_argument(
"bay",
default="",
help="Target bay start.",
)

parser.add_argument(
"run",
default="",
help="Run number, increases as we add attempts.",
)
args = parser.parse_args()

survey_manager_executer(args.command_name, args.bay, args.run)
Loading