Skip to content

Commit

Permalink
change from using separate IDs to using just whether to include or ex…
Browse files Browse the repository at this point in the history
…clude it from the mask, as we only have one mask, and don't need separate colors for everything
  • Loading branch information
danielbrownmsm committed Jun 3, 2024
1 parent ed8c712 commit a8799d3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion autonav_ws/src/autonav_display/src/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ async def consumer(self, websocket):
if obj["op"] == "calibrate":
msg = CameraCalibration()
# there's calibrate ramp, calibrate ground, and maybe a calibrate barrel and/or calibrate line and maybe a calibrate white balance or something (calibrat paper?)
msg.id = int(obj["id"]) # and I guess each will have it's own id or something
msg.include_in_mask = int(obj["include"]) # and I guess each will have it's own id or something
self.calibration_p.publish(msg)

if obj["op"] == "get_presets":
Expand Down
4 changes: 2 additions & 2 deletions autonav_ws/src/autonav_msgs/msg/CameraCalibration.msg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#TODO include a list of which ids mean which thing
int id
# whether to include the colors in the mask or not
bool include_in_mask
27 changes: 17 additions & 10 deletions autonav_ws/src/autonav_vision/src/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,27 @@ def system_state_transition(self, old: SystemState, updated: SystemState):

def onCalibrate(self, msg: CameraCalibration):
# only allow calibration if it's safe to do so, don't want to accidentally ruin a run or kill a person
if self.system_state is not AUTONOMOUS and self.system_state.mobility is False:
if self.system_state.state is not AUTONOMOUS and self.system_state.mobility is False:
# remember that the mask is reversed though, we filter OUT the ground
# so ground needs to be in the threshold range, but not obstacles
# include in the mask, so it gets filtered out
if msg.id is RAMP or msg.id is GROUND:
pass #TODO ensure it's part of the mask
# to exclude from the mask, so it shows up for expandification
elif msg.id == BARREL or msg.id is LINE or msg.id is PAPER:
pass
if msg.include_in_mask:
pixels = [] #TODO
avgHue, avgSat, avgVal = getAverageVal(pixels) #TODO

# take the lower of the current and calibrated values, so that as much as possible is included in the mask
self.config.lower_hue = min(self.config.lower_hue, avgHue)
self.config.lower_sat = min(self.config.lower_sat, avgSat)
self.config.lower_val = min(self.config.lower_val, avgVal)

# take the upper of the current and calibrated values, so that as much as possible is included in the mask
self.config.upper_hue = max(self.config.upper_hue, avgHue)
self.config.upper_sat = max(self.config.upper_sat, avgSat)
self.config.upper_val = max(self.config.upper_val, avgVal)

# exclude from the mask, so it shows up for expandification
else:
#TODO probably throw an error here or something, we should never reach this spot of code
pass
else:
return
pass #TODO

def config_updated(self, jsonObject):
self.config = json.loads(self.jdump(jsonObject), object_hook=lambda d: SimpleNamespace(**d))
Expand Down
4 changes: 2 additions & 2 deletions display/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,14 +558,14 @@ $(document).ready(function () {
$("#calibrate_include").on("click", function () {
send({
op: "calibrate",
id: 0
include: true
});
});

$("#calibrate_exclude").on("click", function () {
send({
op: "calibrate",
id: 1
include: false
});
});

Expand Down

0 comments on commit a8799d3

Please sign in to comment.