Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
PoseToTF2Node.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019-2022 LEIDOS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
18#include <tf2_ros/transform_broadcaster.h>
19
20namespace pose_to_tf
21{
22 namespace std_ph = std::placeholders;
23
24 PoseToTfNode::PoseToTfNode(const rclcpp::NodeOptions &options)
25 : carma_ros2_utils::CarmaLifecycleNode(options)
26 {
27 // Create initial config
29
30 // Declare parameters
31 config_.child_frame = declare_parameter<std::string>("message_type", config_.child_frame);
32 config_.default_parent_frame = declare_parameter<std::string>("target_frame", config_.default_parent_frame);
33 }
34
35 carma_ros2_utils::CallbackReturn PoseToTfNode::handle_on_configure(const rclcpp_lifecycle::State &)
36 {
37 tf2_ros::TransformBroadcaster tf_broadcaster(shared_from_this());
38 pose_to_tf::PoseToTF2 worker(config_, [&tf_broadcaster](auto msg){tf_broadcaster.sendTransform(msg);}, shared_from_this());
39 pose_to_tf_worker_= std::make_shared<PoseToTF2>(worker);
40
41 // Setup subscribers
42 pose_sub = create_subscription<geometry_msgs::msg::Pose>("pose_to_tf", 50,
43 std::bind(&pose_to_tf::PoseToTF2::poseCallback, pose_to_tf_worker_.get(), std_ph::_1));
44 pose_stamped_sub = create_subscription<geometry_msgs::msg::PoseStamped>("pose_stamped_to_tf", 50,
46 pose_with_cov_sub = create_subscription<geometry_msgs::msg::PoseWithCovariance>("pose_with_cov_to_tf", 50,
48 pose_with_cov_stamped_sub = create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>("pose_with_cov_stamped_to_tf", 50,
50
51 // Return success if everthing initialized successfully
52 return CallbackReturn::SUCCESS;
53 }
54
55} // pose_to_tf
56
57#include "rclcpp_components/register_node_macro.hpp"
58
59// Register the component with class_loader
60RCLCPP_COMPONENTS_REGISTER_NODE(pose_to_tf::PoseToTfNode)
Primary logic class for the PoseToTF2 node.
Definition: PoseToTF2.hpp:34
void poseStampedCallback(geometry_msgs::msg::PoseStamped::UniquePtr msg)
Callback for new pose stamped messages.
Definition: PoseToTF2.cpp:65
void poseWithCovarianceStampedCallback(geometry_msgs::msg::PoseWithCovarianceStamped::UniquePtr msg)
Callback for new pose stamped messages.
Definition: PoseToTF2.cpp:73
void poseWithCovarianceCallback(geometry_msgs::msg::PoseWithCovariance::UniquePtr msg)
Callback for new pose with covariance messages.
Definition: PoseToTF2.cpp:91
void poseCallback(geometry_msgs::msg::Pose::UniquePtr msg)
Callback for new pose stamped messages.
Definition: PoseToTF2.cpp:81
The class is responsible for processing pose to tf conversion.
std::shared_ptr< PoseToTF2 > pose_to_tf_worker_
carma_ros2_utils::SubPtr< geometry_msgs::msg::PoseWithCovarianceStamped > pose_with_cov_stamped_sub
carma_ros2_utils::SubPtr< geometry_msgs::msg::PoseWithCovariance > pose_with_cov_sub
PoseToTfNode(const rclcpp::NodeOptions &)
PoseToTfNode constructor.
carma_ros2_utils::SubPtr< geometry_msgs::msg::PoseStamped > pose_stamped_sub
carma_ros2_utils::SubPtr< geometry_msgs::msg::Pose > pose_sub
carma_ros2_utils::CallbackReturn handle_on_configure(const rclcpp_lifecycle::State &)
Stuct containing the frame configuration values for pose_to_tf.