Preserve installed operator workspace before consolidation
Local preservation snapshot, not a new deployment or simulation acceptance.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""Add acknowledged direction admission to the pinned CMU ROS nodes."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def patch(source, follower=False):
|
||||
anchor = ' nh->get_parameter("twoWayDrive", twoWayDrive);'
|
||||
if source.count(anchor) != 1:
|
||||
raise ValueError("Unexpected pinned CMU direction parameter")
|
||||
reset = (
|
||||
"navFwd = true; vehicleSpeed = 0; vehicleYawRate = 0; pathInit = false;" if follower else ""
|
||||
)
|
||||
callback = """
|
||||
auto directionPolicy = nh->add_on_set_parameters_callback(
|
||||
[](const std::vector<rclcpp::Parameter>& parameters) {
|
||||
rcl_interfaces::msg::SetParametersResult result;
|
||||
result.successful = true;
|
||||
for (const auto& parameter : parameters) {
|
||||
if (parameter.get_name() == "twoWayDrive") {
|
||||
if (parameter.get_type() != rclcpp::ParameterType::PARAMETER_BOOL) {
|
||||
result.successful = false;
|
||||
result.reason = "Direction permission must be boolean";
|
||||
return result;
|
||||
}
|
||||
twoWayDrive = parameter.as_bool();
|
||||
RESET
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
""".replace("RESET", reset)
|
||||
return source.replace(anchor, anchor + callback)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
root = Path("/opt/cmu/src/local_planner/src")
|
||||
for name in ("localPlanner", "pathFollower"):
|
||||
path = root / f"{name}.cpp"
|
||||
path.write_text(patch(path.read_text(), name == "pathFollower"))
|
||||
Reference in New Issue
Block a user