environment.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
2 #include <visualization_msgs/Marker.h>
3 #include <geometry_msgs/Pose.h>
4 #include <geometry_msgs/PoseStamped.h>
5 
6 using namespace std;
7 
9 visualization_msgs::Marker marker;
10 void goalCB(const geometry_msgs::PoseStamped msg)
11 {
12  marker.pose = msg.pose;
13  marker.pose.position.z = -0.2;
14  cout<<msg.pose<<endl;
15  cout<<"=============================================================================="<<endl;
16 
17  while (marker_pub.getNumSubscribers() < 1)
18  {
19  if (!ros::ok())
20  {
21  return ;
22  }
23  ROS_WARN_ONCE("Please create a subscriber to the marker");
24  sleep(1);
25  }
26  marker_pub.publish(marker);
27 
28 }
29 
30 int main( int argc, char** argv )
31 {
32  ros::init(argc, argv, "basic_shapes");
34  ros::Rate r(1);
35 
36  marker_pub = n.advertise<visualization_msgs::Marker>("visualization_marker", 1);
37 
38  ros::Subscriber goal_sub = n.subscribe("/goal",100, &goalCB);
39  // Set the frame ID and timestamp. See the TF tutorials for information on these.
40  marker.header.frame_id = "/map";
41  marker.header.stamp = ros::Time::now();
42 
43  // Set the namespace and id for this marker. This serves to create a unique ID
44  // Any marker sent with the same namespace and id will overwrite the old one
45  marker.ns = "basic_shapes";
46  marker.id = 0;
47 
48  // Set the marker type. Initially this is CUBE, and cycles between that and SPHERE, ARROW, and CYLINDER
49  marker.type = 10;
50  marker.mesh_resource = "package://xbot_s/model/sdzn_full/saidi.DAE";
51  marker.mesh_use_embedded_materials = true;
52 
53  // Set the marker action. Options are ADD, DELETE, and new in ROS Indigo: 3 (DELETEALL)
54  marker.action = visualization_msgs::Marker::ADD;
55 
56  // Set the pose of the marker. This is a full 6DOF pose relative to the frame/time specified in the header
57 
58  // Set the scale of the marker -- 1x1x1 here means 1m on a side
59  marker.scale.x = 4.5/3.2;
60  marker.scale.y = 4.5/3.2;
61  marker.scale.z = 4.5/3.2;
62 
63  // Set the color -- be sure to set alpha to something non-zero!
64 // marker.color.r = 0.0f;
65 // marker.color.g = 1.0f;
66  marker.color.b = .5f;
67  marker.color.a = 0.5;
68 
69  marker.lifetime = ros::Duration();
70 
71  // Publish the marker
72  ros::spin();
73 
74 // while (ros::ok())
75 // {
76 
77 // r.sleep();
78 // }
79 }
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())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
visualization_msgs::Marker marker
Definition: environment.cpp:9
int main(int argc, char **argv)
Definition: environment.cpp:30
ros::Publisher marker_pub
Definition: environment.cpp:8
ROSCPP_DECL void spin(Spinner &spinner)
void goalCB(const geometry_msgs::PoseStamped msg)
Definition: environment.cpp:10
#define ROS_WARN_ONCE(...)
ROSCPP_DECL bool ok()
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
uint32_t getNumSubscribers() const
static Time now()
#define n
r


xbot_navi
Author(s):
autogenerated on Sat Oct 10 2020 03:27:50