Skip to content

Commit

Permalink
Enable auto start on replay node (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samahu authored Jan 23, 2025
1 parent e4dd8bf commit 65a1657
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
9 changes: 0 additions & 9 deletions ouster-ros/launch/replay.composite.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,6 @@
</node_container>
</group>

<!-- HACK: configure and activate the replay node via a process execute since state
transition is currently not availabe through launch.xml format -->
<executable if="$(var _use_metadata_file)"
cmd="$(find-exec ros2) lifecycle set /$(var ouster_ns)/os_replay configure"
launch-prefix="bash -c 'sleep 0; $0 $@'" output="screen"/>
<executable if="$(var _use_metadata_file)"
cmd="$(find-exec ros2) lifecycle set /$(var ouster_ns)/os_replay activate"
launch-prefix="bash -c 'sleep 1; $0 $@'" output="screen"/>

<include if="$(var viz)" file="$(find-pkg-share ouster_ros)/launch/rviz.launch.xml">
<arg name="ouster_ns" value="$(var ouster_ns)"/>
<arg name="rviz_config" value="$(var rviz_config)"/>
Expand Down
15 changes: 14 additions & 1 deletion ouster-ros/src/os_replay_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ class OusterReplay : public OusterSensorNodeBase {
explicit OusterReplay(const rclcpp::NodeOptions& options)
: OusterSensorNodeBase("os_replay", options) {
declare_parameters();
bool auto_start = get_parameter("auto_start").as_bool();

if (auto_start) {
RCLCPP_WARN(get_logger(), "auto start requested");
auto request_transitions = std::vector<uint8_t>{
lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE,
lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE};
execute_transitions_sequence(request_transitions, 0);
RCLCPP_WARN(get_logger(), "auto start initiated");
}
}

LifecycleNodeInterface::CallbackReturn on_configure(
Expand Down Expand Up @@ -96,7 +106,10 @@ class OusterReplay : public OusterSensorNodeBase {
}

private:
void declare_parameters() { declare_parameter<std::string>("metadata"); }
void declare_parameters() {
declare_parameter("auto_start", true);
declare_parameter<std::string>("metadata");
}

std::string parse_parameters() {
auto meta_file = get_parameter("metadata").as_string();
Expand Down

0 comments on commit 65a1657

Please sign in to comment.