Closed ghost closed 4 years ago
I was able to solve this issue by passing rclcpp::NodeOptions()
to the node initialization in realsense_camera_node.cpp
.
My main function:
int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);
auto node = std::make_shared<realsense_ros2_camera::RealSenseCameraNode>(rclcpp::NodeOptions());
node->onInit();
rclcpp::spin(node);
rclcpp::shutdown();
return 0;
}
Also made the corresponding changes in the class declaration for RealSenseCameraNode
:
class RealSenseCameraNode : public rclcpp::Node
{
public:
RealSenseCameraNode(const rclcpp::NodeOptions & options)
: Node("RealSenseCameraNode", options),
_serial_no(""),
_base_frame_id(""),
qos(rclcpp::QoSInitialization::from_rmw(rmw_qos_profile_default)),
_intialize_time_base(false)
{
RCLCPP_INFO(logger_, "RealSense ROS v%s", REALSENSE_ROS_VERSION_STR);
RCLCPP_INFO(logger_, "Running with LibRealSense v%s", RS2_API_VERSION_STR)
....
....
After which I could make use of the clock provided to the node (/clock in case of 'use_sim_time' being set) by calling this->now()
instead of _ros_clock.now()
I started a simulation for a robot in an empty world and wanted to test my navigation obstacle detection using
VoxelLayer
plugin with the Realsense D435i camera.However, despite passing the
use_sim_time:=True
parameter, the msgs still have epoch stamp.ros2 launch realsense_ros2_camera rs.launch.py use_sim_time:=True