zoneset_configuration_ros_conversion.h
Go to the documentation of this file.
1 // Copyright (c) 2021 Pilz GmbH & Co. KG
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU Lesser General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
15 
16 #ifndef PSEN_SCAN_V2_ZONESET_CONFIGURATION_ROS_CONVERSION_H
17 #define PSEN_SCAN_V2_ZONESET_CONFIGURATION_ROS_CONVERSION_H
18 
19 #include <ros/console.h>
20 
21 #include <geometry_msgs/Polygon.h>
22 
24 #include "psen_scan_v2/ZoneSet.h"
25 #include "psen_scan_v2/ZoneSetConfiguration.h"
30 
34 
35 static inline double deg_to_rad(double deg)
36 {
37  return deg * M_PI / 180.0;
38 }
39 
40 geometry_msgs::Polygon fromPolar(const std::vector<unsigned long>& radii_in_mm,
41  const TenthOfDegree& phi_step,
42  const double& x_axis_rotation)
43 {
44  geometry_msgs::Polygon polygon;
45  size_t i = 0;
46  for (const auto& r : radii_in_mm)
47  {
48  geometry_msgs::Point32 point;
49 
50  const auto angle = phi_step.toRad() * i - x_axis_rotation;
51  point.x = (r / 1000.) * std::cos(angle);
52  point.y = (r / 1000.) * std::sin(angle);
53  point.z = 0;
54 
55  polygon.points.push_back(point);
56 
57  ++i;
58  }
59 
60  return polygon;
61 }
62 
63 psen_scan_v2::ZoneSet toRosMsg(const ZoneSetStandalone& zoneset,
64  const std::string& frame_id,
65  const ros::Time& stamp = ros::Time::now())
66 {
67  psen_scan_v2::ZoneSetMsgBuilder zoneset_msg_builder;
68  zoneset_msg_builder.headerStamp(stamp)
69  .headerFrameId(frame_id)
98 
99  if (zoneset.speed_range_)
100  {
101  zoneset_msg_builder.speedLower(zoneset.speed_range_->min_).speedUpper(zoneset.speed_range_->max_);
102  }
103 
104  return zoneset_msg_builder.build();
105 }
106 
107 psen_scan_v2::ZoneSetConfiguration toRosMsg(const ZoneSetConfigurationStandalone& zoneset_configuration,
108  const std::string& frame_id,
109  const ros::Time& stamp = ros::Time::now())
110 {
111  psen_scan_v2::ZoneSetConfiguration zoneset_config_msg;
112 
113  for (const auto& z : zoneset_configuration.zonesets_)
114  {
115  zoneset_config_msg.zonesets.push_back(toRosMsg(z, frame_id, stamp));
116  }
117  return zoneset_config_msg;
118 }
119 
120 #endif // PSEN_SCAN_V2_ZONESET_CONFIGURATION_ROS_CONVERSION_H
psen_scan_v2::ZoneSetMsgBuilder::muting1Sub2
ZoneSetMsgBuilder & muting1Sub2(const geometry_msgs::Polygon &muting1_Sub2)
Definition: zoneset_msg_builder.h:233
psen_scan_v2::ZoneSetMsgBuilder::muting2
ZoneSetMsgBuilder & muting2(const geometry_msgs::Polygon &muting2)
Definition: zoneset_msg_builder.h:127
TenthOfDegree
psen_scan_v2_standalone::util::TenthOfDegree TenthOfDegree
Definition: zoneset_configuration_ros_conversion.h:33
psen_scan_v2_standalone::configuration::ZoneSet::muting2_Sub1_
std::vector< unsigned long > muting2_Sub1_
Definition: zoneset.h:94
psen_scan_v2::ZoneSetMsgBuilder::safety1Sub0
ZoneSetMsgBuilder & safety1Sub0(const geometry_msgs::Polygon &safety1_Sub0)
Definition: zoneset_msg_builder.h:134
psen_scan_v2_standalone::configuration::ZoneSet::warn1_Sub2_
std::vector< unsigned long > warn1_Sub2_
Definition: zoneset.h:98
psen_scan_v2::ZoneSetMsgBuilder::build
ZoneSet build() const
Definition: zoneset_msg_builder.h:73
psen_scan_v2::ZoneSetMsgBuilder::warn1Sub1
ZoneSetMsgBuilder & warn1Sub1(const geometry_msgs::Polygon &warn1_Sub1)
Definition: zoneset_msg_builder.h:186
psen_scan_v2::ZoneSetMsgBuilder::warn1Sub0
ZoneSetMsgBuilder & warn1Sub0(const geometry_msgs::Polygon &warn1_Sub0)
Definition: zoneset_msg_builder.h:149
psen_scan_v2::ZoneSetMsgBuilder::headerStamp
ZoneSetMsgBuilder & headerStamp(const ros::Time &header_stamp)
Definition: zoneset_msg_builder.h:84
angle
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
psen_scan_v2_standalone::configuration::ZoneSet::warn2_Sub1_
std::vector< unsigned long > warn2_Sub1_
Definition: zoneset.h:92
psen_scan_v2::ZoneSetMsgBuilder::safety1
ZoneSetMsgBuilder & safety1(const geometry_msgs::Polygon &safety1)
Definition: zoneset_msg_builder.h:97
psen_scan_v2::ZoneSetMsgBuilder::muting2Sub2
ZoneSetMsgBuilder & muting2Sub2(const geometry_msgs::Polygon &muting2_Sub2)
Definition: zoneset_msg_builder.h:238
psen_scan_v2_standalone::configuration::ZoneSetConfiguration::zonesets_
std::vector< ZoneSet > zonesets_
Definition: zoneset_configuration.h:29
psen_scan_v2_standalone::configuration::ZoneSet::warn2_Sub0_
std::vector< unsigned long > warn2_Sub0_
Definition: zoneset.h:85
psen_scan_v2::ZoneSetMsgBuilder::safety3Sub1
ZoneSetMsgBuilder & safety3Sub1(const geometry_msgs::Polygon &safety3_Sub1)
Definition: zoneset_msg_builder.h:181
psen_scan_v2::ZoneSetMsgBuilder::safety3Sub0
ZoneSetMsgBuilder & safety3Sub0(const geometry_msgs::Polygon &safety3_Sub0)
Definition: zoneset_msg_builder.h:144
psen_scan_v2_standalone::configuration::ZoneSet::muting2_Sub0_
std::vector< unsigned long > muting2_Sub0_
Definition: zoneset.h:87
psen_scan_v2_standalone::configuration::ZoneSet::muting1_Sub1_
std::vector< unsigned long > muting1_Sub1_
Definition: zoneset.h:93
psen_scan_v2::ZoneSetMsgBuilder::warn2Sub2
ZoneSetMsgBuilder & warn2Sub2(const geometry_msgs::Polygon &warn2_Sub2)
Definition: zoneset_msg_builder.h:228
psen_scan_v2_standalone::configuration::ZoneSet::warn1_Sub0_
std::vector< unsigned long > warn1_Sub0_
Definition: zoneset.h:84
psen_scan_v2_standalone::configuration::ZoneSet::muting1_Sub0_
std::vector< unsigned long > muting1_Sub0_
Definition: zoneset.h:86
psen_scan_v2::ZoneSetMsgBuilder::safety2
ZoneSetMsgBuilder & safety2(const geometry_msgs::Polygon &safety2)
Definition: zoneset_msg_builder.h:102
psen_scan_v2_standalone::configuration::ZoneSet::safety3_Sub0_
std::vector< unsigned long > safety3_Sub0_
Definition: zoneset.h:83
psen_scan_v2_standalone::configuration::ZoneSet::safety2_Sub0_
std::vector< unsigned long > safety2_Sub0_
Definition: zoneset.h:82
psen_scan_v2::ZoneSetMsgBuilder::safety2Sub0
ZoneSetMsgBuilder & safety2Sub0(const geometry_msgs::Polygon &safety2_Sub0)
Definition: zoneset_msg_builder.h:139
deg_to_rad
static double deg_to_rad(double deg)
Definition: zoneset_configuration_ros_conversion.h:35
psen_scan_v2_standalone::configuration::ZoneSet::safety2_
std::vector< unsigned long > safety2_
Definition: zoneset.h:75
psen_scan_v2::ZoneSetMsgBuilder::speedUpper
ZoneSetMsgBuilder & speedUpper(const float &speed_upper)
Definition: zoneset_msg_builder.h:250
psen_scan_v2_standalone::configuration::ZoneSet::safety1_
std::vector< unsigned long > safety1_
Definition: zoneset.h:74
psen_scan_v2_standalone::configuration::ZoneSet::speed_range_
boost::optional< ZoneSetSpeedRange > speed_range_
Definition: zoneset.h:107
psen_scan_v2_standalone::configuration::ZoneSetConfiguration
Definition: zoneset_configuration.h:26
psen_scan_v2_standalone::configuration::ZoneSet::safety1_Sub2_
std::vector< unsigned long > safety1_Sub2_
Definition: zoneset.h:95
tenth_of_degree.h
psen_scan_v2::ZoneSetMsgBuilder::speedLower
ZoneSetMsgBuilder & speedLower(const float &speed_lower)
Definition: zoneset_msg_builder.h:244
psen_scan_v2::ZoneSetMsgBuilder::muting1Sub1
ZoneSetMsgBuilder & muting1Sub1(const geometry_msgs::Polygon &muting1_Sub1)
Definition: zoneset_msg_builder.h:196
psen_scan_v2::ZoneSetMsgBuilder::warn2
ZoneSetMsgBuilder & warn2(const geometry_msgs::Polygon &warn2)
Definition: zoneset_msg_builder.h:117
psen_scan_v2_standalone::configuration::ZoneSet::muting1_
std::vector< unsigned long > muting1_
Definition: zoneset.h:79
console.h
zoneset_configuration.h
psen_scan_v2::ZoneSetMsgBuilder::safety3Sub2
ZoneSetMsgBuilder & safety3Sub2(const geometry_msgs::Polygon &safety3_Sub2)
Definition: zoneset_msg_builder.h:218
psen_scan_v2::ZoneSetMsgBuilder::muting1Sub0
ZoneSetMsgBuilder & muting1Sub0(const geometry_msgs::Polygon &muting1_Sub0)
Definition: zoneset_msg_builder.h:159
psen_scan_v2::ZoneSetMsgBuilder::muting2Sub1
ZoneSetMsgBuilder & muting2Sub1(const geometry_msgs::Polygon &muting2_Sub1)
Definition: zoneset_msg_builder.h:201
default_ros_parameters.h
psen_scan_v2_standalone::configuration::ZoneSet::muting2_Sub2_
std::vector< unsigned long > muting2_Sub2_
Definition: zoneset.h:101
psen_scan_v2_standalone::configuration::ZoneSet::muting1_Sub2_
std::vector< unsigned long > muting1_Sub2_
Definition: zoneset.h:100
psen_scan_v2::ZoneSetMsgBuilder::warn1Sub2
ZoneSetMsgBuilder & warn1Sub2(const geometry_msgs::Polygon &warn1_Sub2)
Definition: zoneset_msg_builder.h:223
psen_scan_v2_standalone::configuration::ZoneSet::warn1_
std::vector< unsigned long > warn1_
Definition: zoneset.h:77
psen_scan_v2_standalone::configuration::ZoneSet::safety1_Sub0_
std::vector< unsigned long > safety1_Sub0_
Definition: zoneset.h:81
psen_scan_v2::ZoneSetMsgBuilder::muting1
ZoneSetMsgBuilder & muting1(const geometry_msgs::Polygon &muting1)
Definition: zoneset_msg_builder.h:122
psen_scan_v2_standalone::configuration::ZoneSet::muting2_
std::vector< unsigned long > muting2_
Definition: zoneset.h:80
psen_scan_v2::ZoneSetMsgBuilder::safety2Sub1
ZoneSetMsgBuilder & safety2Sub1(const geometry_msgs::Polygon &safety2_Sub1)
Definition: zoneset_msg_builder.h:176
psen_scan_v2_standalone::configuration::ZoneSet::warn2_Sub2_
std::vector< unsigned long > warn2_Sub2_
Definition: zoneset.h:99
psen_scan_v2_standalone::configuration::ZoneSet::safety2_Sub2_
std::vector< unsigned long > safety2_Sub2_
Definition: zoneset.h:96
zoneset_msg_builder.h
psen_scan_v2::ZoneSetMsgBuilder::muting2Sub0
ZoneSetMsgBuilder & muting2Sub0(const geometry_msgs::Polygon &muting2_Sub0)
Definition: zoneset_msg_builder.h:164
ros::Time
default_parameters.h
psen_scan_v2_standalone::util::TenthOfDegree::toRad
constexpr double toRad() const
Definition: tenth_of_degree.h:54
psen_scan_v2_standalone::configuration::ZoneSet::resolution_
util::TenthOfDegree resolution_
Definition: zoneset.h:105
psen_scan_v2::ZoneSetMsgBuilder::warn2Sub1
ZoneSetMsgBuilder & warn2Sub1(const geometry_msgs::Polygon &warn2_Sub1)
Definition: zoneset_msg_builder.h:191
psen_scan_v2::DEFAULT_X_AXIS_ROTATION
static constexpr double DEFAULT_X_AXIS_ROTATION
The 2D scan will be rotated around the z-axis.
Definition: default_ros_parameters.h:24
fromPolar
geometry_msgs::Polygon fromPolar(const std::vector< unsigned long > &radii_in_mm, const TenthOfDegree &phi_step, const double &x_axis_rotation)
Definition: zoneset_configuration_ros_conversion.h:40
psen_scan_v2_standalone::configuration::ZoneSet::warn2_
std::vector< unsigned long > warn2_
Definition: zoneset.h:78
psen_scan_v2::ZoneSetMsgBuilder::safety3
ZoneSetMsgBuilder & safety3(const geometry_msgs::Polygon &safety3)
Definition: zoneset_msg_builder.h:107
toRosMsg
psen_scan_v2::ZoneSet toRosMsg(const ZoneSetStandalone &zoneset, const std::string &frame_id, const ros::Time &stamp=ros::Time::now())
Definition: zoneset_configuration_ros_conversion.h:63
psen_scan_v2::ZoneSetMsgBuilder::warn1
ZoneSetMsgBuilder & warn1(const geometry_msgs::Polygon &warn1)
Definition: zoneset_msg_builder.h:112
psen_scan_v2_standalone::configuration::ZoneSet
A set of simultanously active zones.
Definition: zoneset.h:71
psen_scan_v2::ZoneSetMsgBuilder::safety2Sub2
ZoneSetMsgBuilder & safety2Sub2(const geometry_msgs::Polygon &safety2_Sub2)
Definition: zoneset_msg_builder.h:213
psen_scan_v2_standalone::configuration::ZoneSet::warn1_Sub1_
std::vector< unsigned long > warn1_Sub1_
Definition: zoneset.h:91
psen_scan_v2::ZoneSetMsgBuilder::warn2Sub0
ZoneSetMsgBuilder & warn2Sub0(const geometry_msgs::Polygon &warn2_Sub0)
Definition: zoneset_msg_builder.h:154
psen_scan_v2_standalone::configuration::ZoneSet::safety3_Sub2_
std::vector< unsigned long > safety3_Sub2_
Definition: zoneset.h:97
psen_scan_v2::ZoneSetMsgBuilder::headerFrameId
ZoneSetMsgBuilder & headerFrameId(const std::string &header_frame_id)
Definition: zoneset_msg_builder.h:90
psen_scan_v2_standalone::configuration::ZoneSet::safety2_Sub1_
std::vector< unsigned long > safety2_Sub1_
Definition: zoneset.h:89
psen_scan_v2::ZoneSetMsgBuilder::safety1Sub1
ZoneSetMsgBuilder & safety1Sub1(const geometry_msgs::Polygon &safety1_Sub1)
Definition: zoneset_msg_builder.h:171
psen_scan_v2_standalone::configuration::ZoneSet::safety3_Sub1_
std::vector< unsigned long > safety3_Sub1_
Definition: zoneset.h:90
psen_scan_v2_standalone::util::TenthOfDegree
Helper class representing angles in tenth of degree.
Definition: tenth_of_degree.h:34
psen_scan_v2_standalone::configuration::ZoneSet::safety3_
std::vector< unsigned long > safety3_
Definition: zoneset.h:76
psen_scan_v2::ZoneSetMsgBuilder::safety1Sub2
ZoneSetMsgBuilder & safety1Sub2(const geometry_msgs::Polygon &safety1_Sub2)
Definition: zoneset_msg_builder.h:208
ros::Time::now
static Time now()
psen_scan_v2::ZoneSetMsgBuilder
Definition: zoneset_msg_builder.h:29
psen_scan_v2_standalone::configuration::ZoneSet::safety1_Sub1_
std::vector< unsigned long > safety1_Sub1_
Definition: zoneset.h:88


psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Jun 22 2024 02:46:12