forked from jstnhuang/robot_markers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainpage.dox
72 lines (58 loc) · 1.99 KB
/
mainpage.dox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
\mainpage
\htmlinclude manifest.html
\b robot_markers creates visualizations of robot models given URDFs and joint angles.
robot_markers::Builder is the main API. To use it:
- Construct the Builder with a URDF.
- Call Init().
- Set marker properties.
- Call Build().
At a minimum, you should set the namespace and frame ID of the robot.
The robot will be at the origin of the frame ID, with all joint angles set to 0 (or however the URDF is defined).
This uses the mesh color by default, if a mesh is available.
If the URDF does not specify meshes for the visual components, then you must supply a color, as well.
\code
#include <map>
#include <string>
#include "geometry_msgs/Pose.h"
#include "robot_markers/builder.h"
#include "ros/ros.h"
#include "urdf/model.h"
#include "visualization_msgs/MarkerArray.h"
int main(int argc, char** argv) {
ros::init(argc, argv, "robot_markers_demo");
ros::NodeHandle nh;
ros::Publisher marker_arr_pub =
nh.advertise<visualization_msgs::MarkerArray>("robot", 100);
ros::Duration(0.5).sleep();
urdf::Model model;
model.initParam("robot_description");
robot_markers::Builder builder(model);
builder.Init();
// Robot 1: Default configuration, purple.
visualization_msgs::MarkerArray robot1;
builder.SetNamespace("robot");
builder.SetFrameId("base_link");
builder.SetColor(0.33, 0.17, 0.45, 1);
builder.Build(&robot1);
marker_arr_pub.publish(robot1);
// Robot 2: Different pose, joints changed.
visualization_msgs::MarkerArray robot2;
builder.SetNamespace("robot2");
builder.SetColor(0, 0, 0, 0);
std::map<std::string, double> joint_positions;
joint_positions["torso_lift_joint"] = 0.1;
joint_positions["head_tilt_joint"] = 0.5;
builder.SetJointPositions(joint_positions);
geometry_msgs::Pose pose;
pose.position.y = 1;
pose.orientation.w = 0.92387953;
pose.orientation.z = -0.38268343;
builder.SetPose(pose);
builder.Build(&robot2);
marker_arr_pub.publish(robot2);
ros::Duration(0.5).sleep();
return 0;
}
\endcode
*/