Merge "Forward galactic search path messages from the pi to the roborio"
diff --git a/aos/events/event_loop.h b/aos/events/event_loop.h
index 0534242..5320e1e 100644
--- a/aos/events/event_loop.h
+++ b/aos/events/event_loop.h
@@ -484,10 +484,14 @@
// Returns true if the channel exists in the configuration.
template <typename T>
- bool HasChannel(const std::string_view channel_name) {
+ const Channel *GetChannel(const std::string_view channel_name) {
return configuration::GetChannel(configuration(), channel_name,
T::GetFullyQualifiedName(), name(), node(),
- true) != nullptr;
+ true);
+ }
+ template <typename T>
+ bool HasChannel(const std::string_view channel_name) {
+ return GetChannel<T>(channel_name) != nullptr;
}
// Note, it is supported to create:
@@ -498,9 +502,7 @@
// sent to the provided channel.
template <typename T>
Fetcher<T> MakeFetcher(const std::string_view channel_name) {
- const Channel *channel =
- configuration::GetChannel(configuration(), channel_name,
- T::GetFullyQualifiedName(), name(), node());
+ const Channel *channel = GetChannel<T>(channel_name);
CHECK(channel != nullptr)
<< ": Channel { \"name\": \"" << channel_name << "\", \"type\": \""
<< T::GetFullyQualifiedName() << "\" } not found in config.";
@@ -519,9 +521,7 @@
// the provided channel.
template <typename T>
Sender<T> MakeSender(const std::string_view channel_name) {
- const Channel *channel =
- configuration::GetChannel(configuration(), channel_name,
- T::GetFullyQualifiedName(), name(), node());
+ const Channel *channel = GetChannel<T>(channel_name);
CHECK(channel != nullptr)
<< ": Channel { \"name\": \"" << channel_name << "\", \"type\": \""
<< T::GetFullyQualifiedName() << "\" } not found in config for "
diff --git a/frc971/control_loops/python/path_edit.py b/frc971/control_loops/python/path_edit.py
index ce87aff..f198299 100755
--- a/frc971/control_loops/python/path_edit.py
+++ b/frc971/control_loops/python/path_edit.py
@@ -326,7 +326,7 @@
difs = np.array([pxToM(dif_x), pxToM(dif_y)])
if self.mode == Mode.kEditing:
- self.spline_edit = self.points.updates_for_mouse_move(
+ self.points.updates_for_mouse_move(
self.index_of_edit, self.spline_edit, self.x, self.y, difs)
def export_json(self, file_name):
@@ -406,8 +406,7 @@
self.points.setSplines(self.spline_edit, self.index_of_edit,
pxToM(self.x), pxToM(self.y))
- self.spline_edit = self.points.splineExtrapolate(
- self.spline_edit)
+ self.points.splineExtrapolate(self.spline_edit)
self.index_of_edit = -1
self.spline_edit = -1
diff --git a/frc971/control_loops/python/points.py b/frc971/control_loops/python/points.py
index 4444a72..f42410f 100644
--- a/frc971/control_loops/python/points.py
+++ b/frc971/control_loops/python/points.py
@@ -48,24 +48,20 @@
def splineExtrapolate(self, o_spline_edit):
spline_edit = o_spline_edit
if not spline_edit == len(self.splines) - 1:
- spline_edit = spline_edit + 1
f = self.splines[spline_edit][5]
e = self.splines[spline_edit][4]
d = self.splines[spline_edit][3]
- self.splines[spline_edit][0] = f
- self.splines[spline_edit][1] = f * 2 + e * -1
- self.splines[spline_edit][2] = d + f * 4 + e * -4
+ self.splines[spline_edit + 1][0] = f
+ self.splines[spline_edit + 1][1] = f * 2 + e * -1
+ self.splines[spline_edit + 1][2] = d + f * 4 + e * -4
if not spline_edit == 0:
- spline_edit = spline_edit - 1
a = self.splines[spline_edit][0]
b = self.splines[spline_edit][1]
c = self.splines[spline_edit][2]
- self.splines[spline_edit][5] = a
- self.splines[spline_edit][4] = a * 2 + b * -1
- self.splines[spline_edit][3] = c + a * 4 + b * -4
-
- return spline_edit
+ self.splines[spline_edit - 1][5] = a
+ self.splines[spline_edit - 1][4] = a * 2 + b * -1
+ self.splines[spline_edit - 1][3] = c + a * 4 + b * -4
def updates_for_mouse_move(self, index_of_edit, spline_edit, x, y, difs):
if index_of_edit > -1:
@@ -97,7 +93,7 @@
index_of_edit +
1] = self.splines[spline_edit][index_of_edit + 1] + difs
- return self.splineExtrapolate(spline_edit)
+ self.splineExtrapolate(spline_edit)
def update_lib_spline(self):
self.libsplines = []