utilities.cpp
Go to the documentation of this file.
1 
4 /*****************************************************************************
5 ** Includes
6 *****************************************************************************/
7 
8 #include "../../include/cost_map_demos/utilities.hpp"
9 
10 /*****************************************************************************
11 ** Namespaces
12 *****************************************************************************/
13 
14 namespace cost_map_demos {
15 
16 /*****************************************************************************
17 ** Implementation
18 *****************************************************************************/
19 
21  for ( unsigned int i = 0; i < ros_costmap.getCostmap()->getSizeInCellsX(); ++i ) {
22  for ( unsigned int j = 0; j < ros_costmap.getCostmap()->getSizeInCellsY(); ++j ) {
23  std::cout << static_cast<int>(ros_costmap.getCostmap()->getCost(i,j)) << " ";
24  }
25  std::cout << std::endl;
26  }
27 }
28 
29 std::ostream& operator <<(std::ostream& stream, costmap_2d::Costmap2DROS& ros_costmap) {
30  for ( unsigned int i = 0; i < ros_costmap.getCostmap()->getSizeInCellsX(); ++i ) {
31  for ( unsigned int j = 0; j < ros_costmap.getCostmap()->getSizeInCellsY(); ++j ) {
32  stream << static_cast<int>(ros_costmap.getCostmap()->getCost(i,j)) << " ";
33  }
34  stream << std::endl;
35  }
36  return stream;
37 }
38 
39 /*****************************************************************************
40 ** TransformBroadcaster
41 *****************************************************************************/
42 
44  broadcasting_thread.join();
45 }
46 
48  shutdown_flag = true;
49 }
50 
51 void TransformBroadcaster::add(const std::string& name, tf::Vector3 origin, const tf::Quaternion& orientation) {
52  tf::Transform transform;
53  transform.setOrigin(origin);
54  transform.setRotation(orientation);
55  transforms.insert(std::pair<std::string, tf::Transform>(name, transform));
56 }
57 
60 }
61 
63  tf::TransformBroadcaster tf_broadcaster;
64  while(ros::ok() && !shutdown_flag )
65  {
66  for (std::pair<std::string, tf::Transform> p: transforms) {
67  tf::StampedTransform stamped_transform(p.second, ros::Time::now(), "map", p.first);
68  tf_broadcaster.sendTransform(stamped_transform);
69  }
70  ros::Duration(0.1).sleep();
71  }
72 }
73 
74 /*****************************************************************************
75  ** Trailers
76  *****************************************************************************/
77 
78 } // namespace cost_map_demos
TFSIMD_FORCE_INLINE void setRotation(const Quaternion &q)
std::ostream & operator<<(std::ostream &stream, costmap_2d::Costmap2DROS &ros_costmap)
Pretty print a ros cost map in ascii format to stdout.
Definition: utilities.cpp:29
bool sleep() const
unsigned char getCost(unsigned int mx, unsigned int my) const
std::map< std::string, tf::Transform > transforms
Definition: utilities.hpp:46
ROSCPP_DECL bool ok()
void add(const std::string &name, tf::Vector3 origin, const tf::Quaternion &orientation)
Definition: utilities.cpp:51
void sendTransform(const StampedTransform &transform)
unsigned int getSizeInCellsY() const
std::atomic< bool > shutdown_flag
Definition: utilities.hpp:48
unsigned int getSizeInCellsX() const
static Time now()
Costmap2D * getCostmap()
TFSIMD_FORCE_INLINE void setOrigin(const Vector3 &origin)
void pretty_print(costmap_2d::Costmap2DROS &ros_costmap)
Pretty print a ros cost map in ascii format to stdout.
Definition: utilities.cpp:20


cost_map_demos
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:04:00