-
Notifications
You must be signed in to change notification settings - Fork 29
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
Hydrothermal vent #1187
Draft
tjcanro
wants to merge
11
commits into
master
Choose a base branch
from
Hydrothermal_vent
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Hydrothermal vent #1187
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0e1401e
Added hydrothermal vent file with basic functionality
tjcanro 9b6f18c
Added functionality for pose editing and setting up circumvention
tjcanro 486cdb3
fixed comments
tjcanro 9f3144c
Finalized hydrothermal vent mission functionality
tjcanro f2b211d
added the 3D model to gazebo and adapted the mission so it works once…
tjcanro f444f93
Merge in master
cbrxyz c696eba
pre-commit changes
tjcanro 70e8a7e
center function
tjcanro d6ec6f0
Added the option to circumnavigate in either CW or CCW orientation, a…
tjcanro 2df9224
Added parameters file and included it in the hydrothermal vent mission
tjcanro 259ecf0
added the strategy file to the ros parameters, in the sub8.launch file
tjcanro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 31 additions & 0 deletions
31
SubjuGator/command/subjugator_missions/config/strategy.yaml
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,31 @@ | ||
--- | ||
#################################### | ||
# Overall variables | ||
#################################### | ||
|
||
# Which team the sub is playing for. | ||
# - Two possible values: red, blue. | ||
team: red | ||
|
||
#################################### | ||
# Start Gate task | ||
#################################### | ||
start_gate: | ||
with_style: true | ||
|
||
#################################### | ||
# Hydrothermal Vent (red buoy) task | ||
# - CCW or CW rotation | ||
#################################### | ||
orientation: | ||
CCW: true | ||
#################################### | ||
# Ocean Temperatures (bins) task | ||
#################################### | ||
# This task is based off the overall | ||
# team the sub is playing for | ||
#################################### | ||
# Mapping (torpedoes) task | ||
#################################### | ||
torpedoes: | ||
color: red |
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
114 changes: 114 additions & 0 deletions
114
SubjuGator/command/subjugator_missions/subjugator_missions/hydrothermal_vent.py
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,114 @@ | ||
#!/usr/bin/env python3 | ||
import math | ||
|
||
import numpy as np | ||
from mil_misc_tools import text_effects | ||
from sensor_msgs.msg import CameraInfo | ||
|
||
from .sub_singleton import SubjuGatorMission | ||
|
||
# This mission will direct the sub towards a red buoy, and circumnavigate it on a given orientation | ||
|
||
fprint = text_effects.FprintFactory(title="HYDROTHERMAL VENT", msg_color="green").fprint | ||
|
||
|
||
# Computer vision aspect still required to detect the red buoy. For now, random position used | ||
class HydrothermalVent(SubjuGatorMission): | ||
|
||
async def center_bouy(self, buoy_pos_c): | ||
"""This function is supposed to center the buoy based on position given in terms of xy position of the center of the | ||
red buoy, with respect to the center of the camera, as well as the distance from the buoy | ||
|
||
Args: | ||
buoy_pos_c (float array): buoy position with respect to the center of the sub camera | ||
""" | ||
|
||
fprint("Enabling cam_ray publisher") | ||
|
||
await self.nh.sleep(1) | ||
|
||
fprint("Connecting camera") | ||
|
||
cam_info_sub_r = self.nh.subscribe( | ||
"/camera/front/right/camera_info", | ||
CameraInfo, | ||
) | ||
await cam_info_sub_r.setup() | ||
|
||
fprint("Obtaining cam info message") | ||
cam_info_r = await cam_info_sub_r.get_next_message() | ||
cam_center = np.array([cam_info_r.width / 2, cam_info_r.height / 2]) | ||
# fprint(f"Cam center: {cam_center}") | ||
while ((abs(buoy_pos_c[0] - cam_center[0])) > 0.01) and ( | ||
(abs(buoy_pos_c[1]) - cam_center[1]) > 0.01 | ||
): | ||
await self.go(self.move().depth(buoy_pos_c[1])) | ||
yaw_angle = np.arctan(buoy_pos_c[0] / buoy_pos_c[2]) | ||
await self.go(self.move().set_roll_pitch_yaw(0, 0, yaw_angle)) | ||
|
||
buoy_pos_c = buoy_pos_c # this will be replaced with the computer vision call to check the position of the buoy | ||
|
||
async def run(self, args): | ||
|
||
self.buoy_pos = np.array([3, 4, -2]) # Convert buoy position to numpy array | ||
|
||
# First, move down the necessary depth to reach the buoy | ||
|
||
self.send_feedback("Submerging to buoy depth") | ||
if self.buoy_pos[2] < 0: | ||
await self.go(self.move().down(abs(self.buoy_pos[2] + 0.3))) | ||
else: | ||
await self.go(self.move().up(self.buoy_pos[2] - 0.3)) | ||
yaw_angle = np.arctan(self.buoy_pos[1] / self.buoy_pos[0]) | ||
self.send_feedback(f"Rotating towards Buoy with yaw {math.degrees(yaw_angle)}") | ||
rotate = self.move().set_roll_pitch_yaw(0, 0, yaw_angle + 0.1) | ||
await self.go(rotate) | ||
|
||
self.send_feedback("Traveling forward to buoy") | ||
await self.go( | ||
self.move().forward( | ||
np.sqrt(np.square(self.buoy_pos[0]) + np.square(self.buoy_pos[1])) | ||
- 0.7, | ||
), # don't reach the buoy, remain 0.5 meter away | ||
) | ||
|
||
yaw_angle2 = np.deg2rad(90) | ||
|
||
CCW = await self.nh.get_param("/strategy/orientation/CCW") | ||
|
||
if CCW: | ||
self.send_feedback("Circumnaviganting the buoy on a CCW orientation") | ||
|
||
rotate = self.move().yaw_right(yaw_angle2) | ||
await self.go(rotate) | ||
await self.go(self.move().forward(0.7)) | ||
for i in range(0, 3): | ||
rotate = self.move().yaw_left(yaw_angle2) | ||
await self.go(rotate) | ||
await self.go(self.move().forward(1.4)) | ||
rotate = self.move().yaw_left(yaw_angle2) | ||
await self.go(rotate) | ||
await self.go(self.move().forward(0.7)) | ||
|
||
else: | ||
self.send_feedback("Circumnaviganting the buoy on a CW orientation") | ||
|
||
rotate = self.move().yaw_left(yaw_angle2) | ||
await self.go(rotate) | ||
await self.go(self.move().forward(0.7)) | ||
for i in range(0, 3): | ||
rotate = self.move().yaw_right(yaw_angle2) | ||
await self.go(rotate) | ||
await self.go(self.move().forward(1.4)) | ||
rotate = self.move().yaw_right(yaw_angle2) | ||
await self.go(rotate) | ||
await self.go(self.move().forward(0.7)) | ||
|
||
# async def run(self, args): | ||
|
||
# buoy_rad_and_center = [20, 2, 3] # arbitrary numbers to test functionality | ||
# # center buoy | ||
# self.center_bouy(np.array(buoy_rad_and_center[1], buoy_rad_and_center[2])) | ||
# # go forward until desired distance is reached | ||
# while (buoy_rad_and_center[0] < 40): | ||
# await self.go(self.move().forward) |
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
Submodule axros
updated
11 files
+0 −2 | README.md | |
+26 −0 | axros/README.md | |
+2 −2 | axros/src/axros/action.py | |
+1 −1 | axros/src/axros/axros_tf.py | |
+1 −1 | axros/src/axros/exceptions.py | |
+0 −17 | axros/src/axros/nodehandle.py | |
+1 −1 | axros/src/axros/publisher.py | |
+1 −1 | axros/src/axros/rosxmlrpc.py | |
+1 −1 | axros/src/axros/service.py | |
+2 −2 | axros/src/axros/serviceclient.py | |
+1 −1 | axros/src/axros/subscriber.py |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What is this array?
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.
The array represents the position of the buoy in x, y, z coordinates relative to the sub. I spoke to Daniel about how the sub would actually view the buoy and I will now work on modifying the functionality so it uses position in x,y relative to the center of the camera and radius/