30 #ifndef TEST_SAFETY_LIMITER_BASE_H 31 #define TEST_SAFETY_LIMITER_BASE_H 37 #include <diagnostic_msgs/DiagnosticArray.h> 38 #include <geometry_msgs/Twist.h> 39 #include <sensor_msgs/PointCloud2.h> 41 #include <std_msgs/Empty.h> 42 #include <safety_limiter_msgs/SafetyLimiterStatus.h> 43 #include <tf2_geometry_msgs/tf2_geometry_msgs.h> 46 #include <gtest/gtest.h> 50 inline void GenerateEmptyPointcloud2(sensor_msgs::PointCloud2& cloud)
54 cloud.is_bigendian =
false;
55 cloud.is_dense =
false;
57 modifier.setPointCloud2FieldsByString(1,
"xyz");
59 inline void GenerateSinglePointPointcloud2(
60 sensor_msgs::PointCloud2& cloud,
67 cloud.is_bigendian =
false;
68 cloud.is_dense =
false;
70 modifier.setPointCloud2FieldsByString(1,
"xyz");
94 inline void cbDiag(
const diagnostic_msgs::DiagnosticArray::ConstPtr& msg)
99 inline void cbStatus(
const safety_limiter_msgs::SafetyLimiterStatus::ConstPtr& msg)
104 inline void cbCmdVel(
const geometry_msgs::Twist::ConstPtr& msg)
110 diagnostic_msgs::DiagnosticArray::ConstPtr
diag_;
111 safety_limiter_msgs::SafetyLimiterStatus::ConstPtr
status_;
117 pub_cmd_vel_ = nh_.
advertise<geometry_msgs::Twist>(
"cmd_vel_in", 1);
118 pub_cloud_ = nh_.
advertise<sensor_msgs::PointCloud2>(
"cloud", 1);
119 pub_watchdog_ = nh_.
advertise<std_msgs::Empty>(
"watchdog_reset", 1);
126 for (
int i = 0; i < 10 &&
ros::ok(); ++i)
141 std_msgs::Empty watchdog_reset;
142 pub_watchdog_.
publish(watchdog_reset);
145 const std::string frame_id,
148 sensor_msgs::PointCloud2 cloud;
149 cloud.header.frame_id = frame_id;
150 cloud.header.stamp = stamp;
151 GenerateEmptyPointcloud2(cloud);
158 const std::string frame_id,
161 sensor_msgs::PointCloud2 cloud;
162 cloud.header.frame_id = frame_id;
163 cloud.header.stamp = stamp;
164 GenerateSinglePointPointcloud2(cloud, x, y, z);
171 geometry_msgs::Twist cmd_vel_out;
172 cmd_vel_out.linear.x = lin;
173 cmd_vel_out.angular.z = ang;
174 pub_cmd_vel_.
publish(cmd_vel_out);
177 const std::string parent_frame_id,
178 const std::string child_frame_id,
182 geometry_msgs::TransformStamped trans;
186 trans.header.frame_id = parent_frame_id;
187 trans.child_frame_id = child_frame_id;
194 if (diag_->status.size() == 0)
200 return static_cast<bool>(
status_);
204 #endif // TEST_SAFETY_LIMITER_BASE_H ros::Subscriber sub_status_
ros::Publisher pub_watchdog_
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void cbDiag(const diagnostic_msgs::DiagnosticArray::ConstPtr &msg)
void cbStatus(const safety_limiter_msgs::SafetyLimiterStatus::ConstPtr &msg)
geometry_msgs::Twist::ConstPtr cmd_vel_
void publishTwist(const float lin, const float ang)
void cbCmdVel(const geometry_msgs::Twist::ConstPtr &msg)
safety_limiter_msgs::SafetyLimiterStatus::ConstPtr status_
ros::Subscriber sub_diag_
ros::Publisher pub_cloud_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void broadcastTF(const std::string parent_frame_id, const std::string child_frame_id, const float lin, const float ang)
ros::Subscriber sub_cmd_vel_
diagnostic_msgs::DiagnosticArray::ConstPtr diag_
ros::Publisher pub_cmd_vel_
void publishWatchdogReset()
ROSCPP_DECL void spinOnce()
void publishSinglePointPointcloud2(const float x, const float y, const float z, const std::string frame_id, const ros::Time stamp)
tf2_ros::TransformBroadcaster tfb_
void publishEmptyPointPointcloud2(const std::string frame_id, const ros::Time stamp)