demo_main.cpp
Go to the documentation of this file.
00001 #include <map>
00002 #include <string>
00003 
00004 #include "geometry_msgs/Pose.h"
00005 #include "robot_markers/builder.h"
00006 #include "ros/ros.h"
00007 #include "urdf/model.h"
00008 #include "visualization_msgs/MarkerArray.h"
00009 
00010 int main(int argc, char** argv) {
00011   ros::init(argc, argv, "robot_markers_demo");
00012   ros::NodeHandle nh;
00013   ros::Publisher marker_arr_pub =
00014       nh.advertise<visualization_msgs::MarkerArray>("robot", 100);
00015   ros::Duration(0.5).sleep();
00016 
00017   urdf::Model model;
00018   model.initParam("robot_description");
00019 
00020   robot_markers::Builder builder(model);
00021   builder.Init();
00022 
00023   // Robot 1: Default configuration, purple.
00024   visualization_msgs::MarkerArray robot1;
00025   builder.SetNamespace("robot");
00026   builder.SetFrameId("base_link");
00027   builder.SetColor(0.33, 0.17, 0.45, 1);
00028   builder.Build(&robot1);
00029   marker_arr_pub.publish(robot1);
00030 
00031   // Robot 2: Different pose, joints changed.
00032   visualization_msgs::MarkerArray robot2;
00033   builder.SetNamespace("robot2");
00034   builder.SetColor(0, 0, 0, 0);
00035 
00036   std::map<std::string, double> joint_positions;
00037   joint_positions["torso_lift_joint"] = 0.1;
00038   joint_positions["head_tilt_joint"] = 0.5;
00039   builder.SetJointPositions(joint_positions);
00040 
00041   geometry_msgs::Pose pose;
00042   pose.position.y = 1;
00043   pose.orientation.w = 0.92387953;
00044   pose.orientation.z = -0.38268343;
00045   builder.SetPose(pose);
00046   builder.Build(&robot2);
00047   marker_arr_pub.publish(robot2);
00048 
00049   ros::Duration(0.5).sleep();
00050 
00051   return 0;
00052 }


robot_markers
Author(s):
autogenerated on Sat Jun 8 2019 20:39:25