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


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