triangle_foot.cpp
Go to the documentation of this file.
1 #include <iostream>
5 
6 using namespace std;
7 
8 visualization_msgs::Marker TriangleFoot::makeTriangleMarker(){
9  visualization_msgs::Marker marker;
10  marker.type = visualization_msgs::Marker::LINE_STRIP;
11  marker.scale.x = 0.03;//line width;
12 
13  marker.color.r = 1.0;
14  marker.color.g = 1.0;
15  marker.color.b = 0.0;
16  marker.color.a = 1.0;
17 
18 
19  geometry_msgs::Point point1;
20 
21  geometry_msgs::Point point2;
22  point2.z = 0.3048; //12in
23 
24  geometry_msgs::Point point3;
25 
26  point3.y = -0.6096; //24in
27  if(reverse){
28  point3.y = - point3.y;
29  }
30  point3.z = 0.0;
31 
32  marker.points.push_back(point1);
33  marker.points.push_back(point2);
34  marker.points.push_back(point3);
35  marker.points.push_back(point1);
36  return marker;
37 }
38 
39 visualization_msgs::Marker TriangleFoot::makeRFootMarker(){
40  geometry_msgs::Pose pose;
41  if(reverse){
42  pose.position.x = -0.65;
43  pose.position.y = 0.65;
44  pose.position.z = -0.910;
45  }else{
46  pose.position.x = -0.8;
47  pose.position.y = 0.0;
48  pose.position.z = -0.910;
49  }
50  pose.orientation.w = 1.0;
51  return makeFootMarker(pose);
52 }
53 visualization_msgs::Marker TriangleFoot::makeLFootMarker(){
54  geometry_msgs::Pose pose;
55  if(reverse){
56  pose.position.x = -0.65;
57  pose.position.y = 0.35;
58  pose.position.z = -0.910;
59  }else{
60  pose.position.x = -0.8;
61  pose.position.y = -0.3;
62  pose.position.z = -0.910;
63  }
64  pose.orientation.w = 1.0;
65  return makeFootMarker(pose);
66 
67 }
68 visualization_msgs::Marker TriangleFoot::makeFootMarker(geometry_msgs::Pose pose){
69  visualization_msgs::Marker marker;
70  marker.type = visualization_msgs::Marker::CUBE;
71  double PADDING_PARAM = 0.01;
72  marker.scale.x = 0.27 + PADDING_PARAM;
73  marker.scale.y = 0.14 + PADDING_PARAM;
74  marker.scale.z = 0.05;
75 
76  marker.pose = pose;
77 
78  marker.color.r = 1.0;
79  marker.color.g = 1.0;
80  marker.color.b = 0.0;
81  marker.color.a = 0.8;
82 
83  return marker;
84 
85 }
86 
87 visualization_msgs::InteractiveMarker TriangleFoot::makeInteractiveMarker(){
88  visualization_msgs::InteractiveMarker mk;
89  mk.header.frame_id = "/map";
90  mk.header.stamp = ros::Time(0);
91  mk.name = marker_name;
92 
93  mk.scale = 0.4;
94 
95  mk.pose.position.z = 0.910;
96 
97  visualization_msgs::InteractiveMarkerControl triangleMarker;
98  triangleMarker.always_visible = true;
99  triangleMarker.markers.push_back( makeTriangleMarker());
100  triangleMarker.markers.push_back( makeRFootMarker());
101  triangleMarker.markers.push_back( makeLFootMarker());
102  mk.controls.push_back( triangleMarker );
103 
104  im_helpers::add6DofControl(mk, true);
105  return mk;
106 }
107 
108 void TriangleFoot::moveBoxCb( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
109 {
110  // std::cout << "moved" << std::endl;
111 }
112 
113 void TriangleFoot::reverseTriangleCb( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback){
114  reverse ^= true;
115  updateBoxInteractiveMarker();
116 }
117 
118 
121  mh.insert("Reverse Triangle", boost::bind( &TriangleFoot::reverseTriangleCb, this, _1));
122  return mh;
123 }
124 
125 
127  visualization_msgs::InteractiveMarker boxIM = makeInteractiveMarker();
128 
129  server_->insert(boxIM,
130  boost::bind( &TriangleFoot::moveBoxCb, this, _1 ));
131  menu_handler.apply(*server_, marker_name);
132  server_->applyChanges();
133 }
134 
135 TriangleFoot::TriangleFoot () : nh_(), pnh_("~") {
136  pnh_.param("server_name", server_name, std::string ("") );
137  pnh_.param("size", size_, 1.0 );
138  pnh_.param("marker_name", marker_name, std::string ("triangle_marker") );
139  pnh_.param("reverse", reverse, false);
140 
141  if ( server_name == "" ) {
143  }
145 
148  return;
149 }
150 
151 
152 int main(int argc, char** argv)
153 {
154  ros::init(argc, argv, "triangle_foot_marker");
155  TriangleFoot triFoot;
156  ros::spin();
157  return 0;
158 }
159 
160 
std::string server_name
Definition: triangle_foot.h:27
visualization_msgs::Marker makeFootMarker(geometry_msgs::Pose pose)
void reverseTriangleCb(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
void updateBoxInteractiveMarker()
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL const std::string & getName()
ros::NodeHandle pnh_
Definition: triangle_foot.h:24
std::shared_ptr< interactive_markers::InteractiveMarkerServer > server_
Definition: triangle_foot.h:25
pose
visualization_msgs::Marker makeLFootMarker()
std::string marker_name
Definition: triangle_foot.h:28
visualization_msgs::Marker makeTriangleMarker()
ROSCPP_DECL void spin(Spinner &spinner)
interactive_markers::MenuHandler menu_handler
Definition: triangle_foot.h:30
bool param(const std::string &param_name, T &param_val, const T &default_val) const
interactive_markers::MenuHandler makeMenuHandler()
EntryHandle insert(const std::string &title, const FeedbackCallback &feedback_cb)
void add6DofControl(visualization_msgs::InteractiveMarker &msg, bool fixed=false)
visualization_msgs::InteractiveMarker makeInteractiveMarker()
void moveBoxCb(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
visualization_msgs::Marker makeRFootMarker()


jsk_interactive_marker
Author(s): furuta
autogenerated on Sat Mar 20 2021 03:03:33