Skip to content

Commit

Permalink
Changes from URC (#513)
Browse files Browse the repository at this point in the history
* Make auton forwarding catch all exceptions

* odom constants change

* reference coordinate update

* dont reset search upon recovery

* dont output perception loop stats

* Fix offline map max native zoom again

* Switch to fast mode toggle for SA

* Adjust configs

* Change servo angle

* change coordinate back to Michigan

---------

Co-authored-by: Justin Yu <[email protected]>
Co-authored-by: Rocker <[email protected]>
Co-authored-by: Ankith Udupa <[email protected]>
  • Loading branch information
4 people authored Jun 7, 2023
1 parent 0ecfa33 commit 3f2d50b
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 41 deletions.
2 changes: 1 addition & 1 deletion config/esw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ science:
- pushed: 60
start: 90
- pushed: 0
start: 50
start: 80
info:
mcu_active_timeout_s: 2
mcu_reset_period_s: 20
Expand Down
10 changes: 5 additions & 5 deletions config/navigation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ drive:
turning_p: 3.0
driving_p: 20.0
odom:
max_driving_effort: 0.5
min_driving_effort: -0.5
max_turning_effort: 0.3
min_turning_effort: -0.3
max_driving_effort: 0.7
min_driving_effort: -0.7
max_turning_effort: 0.5
min_turning_effort: -0.5
turning_p: 3.0
driving_p: 5.0
driving_p: 10.0
lookahead_distance: 1.0

gate:
Expand Down
2 changes: 1 addition & 1 deletion config/teleop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ teleop:
slow_mode_multiplier: 0.5
scoop:
multiplier: 1
slow_mode_multiplier: 0.5
slow_mode_multiplier: 1.0
microscope:
multiplier: 1
slow_mode_multiplier: 0.5
Expand Down
9 changes: 7 additions & 2 deletions src/navigation/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ def __init__(
)
self.traj: Optional[SearchTrajectory] = None
self.prev_target: Optional[np.ndarray] = None
self.is_recovering = False

def reset(self) -> None:
self.traj = None
self.prev_target = None
if not self.is_recovering:
self.traj = None
self.prev_target = None

def evaluate(self, ud):
# Check if a path has been generated, and it's associated with the same
Expand Down Expand Up @@ -143,7 +145,10 @@ def evaluate(self, ud):

if self.context.rover.stuck:
self.context.rover.previous_state = SearchStateTransitions.continue_search.name # type: ignore
self.is_recovering = True
return SearchStateTransitions.recovery_state.name # type: ignore
else:
self.is_recovering = False

self.context.search_point_publisher.publish(
GPSPointList([convert_cartesian_to_gps(pt) for pt in self.traj.coordinates])
Expand Down
2 changes: 1 addition & 1 deletion src/teleop/auton_enable_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def handle_message(self, msg: EnableAuton) -> None:
self.msg = msg

# Reconnect service client upon failure.
except rospy.ServiceException as e:
except Exception as e:
rospy.logerr(f"Could not forward enable auton message: {e}")

self.service_client.close()
Expand Down
2 changes: 1 addition & 1 deletion src/teleop/gui/src/components/AutonRoverMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const onlineTileOptions = {
subdomains: ["mt0", "mt1", "mt2", "mt3"]
};
const offlineTileOptions = {
maxNativeZoom: 14,
maxNativeZoom: 16,
maxZoom: 100
};
Expand Down
2 changes: 1 addition & 1 deletion src/teleop/gui/src/components/BasicRoverMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const onlineTileOptions = {
subdomains: ["mt0", "mt1", "mt2", "mt3"],
};
const offlineTileOptions = {
maxNativeZoom: 14,
maxNativeZoom: 16,
maxZoom: 100,
};
Expand Down
4 changes: 2 additions & 2 deletions src/teleop/jetson/jetson_teleop.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ def sa_control_callback(self, msg: Joy) -> None:
* self.filter_xbox_button(msg.buttons, "right_bumper", "left_bumper"),
]

slow_mode_activated = msg.buttons[self.xbox_mappings["a"]] or msg.buttons[self.xbox_mappings["b"]]
if slow_mode_activated:
fast_mode_activated = msg.buttons[self.xbox_mappings["a"]] or msg.buttons[self.xbox_mappings["b"]]
if not fast_mode_activated:
for i, name in enumerate(self.SA_NAMES):
# When going up (vel > 0) with SA joint 2, we DON'T want slow mode.
if not (name == "sa_joint_2" and self.sa_cmd.velocity[i] > 0):
Expand Down
54 changes: 27 additions & 27 deletions src/util/loop_profiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ class LoopProfiler {
* @brief Call this at the beginning of each loop iteration.
*/
void beginLoop() {
if (mTick % mPrintTick == 0) {
Clock::duration averageLoopDuration{};
for (auto& [_, durations]: mEventReadings) {
averageLoopDuration += std::accumulate(durations.begin(), durations.end(), Clock::duration{}) / durations.size();
}
// Print update time for the entire loop
size_t threadId = std::hash<std::thread::id>{}(std::this_thread::get_id());
auto averageLoopMs = std::chrono::duration_cast<DisplayUnits>(averageLoopDuration);
int hz = averageLoopMs.count() ? DisplayUnits::period::den / averageLoopMs.count() : -1;
ROS_INFO_STREAM("[" << mName << "] [" << threadId << "] Total: "
<< averageLoopMs.count() << "ms"
<< " (" << hz << " Hz)");
// Print update times for each loop event
for (auto& [name, durations]: mEventReadings) {
Clock::duration averageEventDuration = std::accumulate(durations.begin(), durations.end(), Clock::duration{}) / durations.size();
auto averageEventMs = std::chrono::duration_cast<DisplayUnits>(averageEventDuration);
ROS_INFO_STREAM("\t" << name << ": " << averageEventMs.count() << "ms");
durations.clear();
}
}
// if (mTick % mPrintTick == 0) {
// Clock::duration averageLoopDuration{};
// for (auto& [_, durations]: mEventReadings) {
// averageLoopDuration += std::accumulate(durations.begin(), durations.end(), Clock::duration{}) / durations.size();
// }
// // Print update time for the entire loop
// size_t threadId = std::hash<std::thread::id>{}(std::this_thread::get_id());
// auto averageLoopMs = std::chrono::duration_cast<DisplayUnits>(averageLoopDuration);
// int hz = averageLoopMs.count() ? DisplayUnits::period::den / averageLoopMs.count() : -1;
// ROS_INFO_STREAM("[" << mName << "] [" << threadId << "] Total: "
// << averageLoopMs.count() << "ms"
// << " (" << hz << " Hz)");
// // Print update times for each loop event
// for (auto& [name, durations]: mEventReadings) {
// Clock::duration averageEventDuration = std::accumulate(durations.begin(), durations.end(), Clock::duration{}) / durations.size();
// auto averageEventMs = std::chrono::duration_cast<DisplayUnits>(averageEventDuration);
// ROS_INFO_STREAM("\t" << name << ": " << averageEventMs.count() << "ms");
// durations.clear();
// }
// }

mTick++;
// mTick++;
}

/**
Expand All @@ -63,11 +63,11 @@ class LoopProfiler {
* @param name
*/
void measureEvent(std::string const& name) {
Clock::time_point now = Clock::now();
if (mLastEpochTime) {
Clock::duration duration = now - mLastEpochTime.value();
mEventReadings[name].push_back(duration);
}
mLastEpochTime = now;
// Clock::time_point now = Clock::now();
// if (mLastEpochTime) {
// Clock::duration duration = now - mLastEpochTime.value();
// mEventReadings[name].push_back(duration);
// }
// mLastEpochTime = now;
}
};

0 comments on commit 3f2d50b

Please sign in to comment.