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 
TriangleFoot::makeTriangleMarker
visualization_msgs::Marker makeTriangleMarker()
Definition: triangle_foot.cpp:8
TriangleFoot::reverse
bool reverse
Definition: triangle_foot.h:32
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
TriangleFoot::makeRFootMarker
visualization_msgs::Marker makeRFootMarker()
Definition: triangle_foot.cpp:39
TriangleFoot::moveBoxCb
void moveBoxCb(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
Definition: triangle_foot.cpp:108
TriangleFoot::makeMenuHandler
interactive_markers::MenuHandler makeMenuHandler()
Definition: triangle_foot.cpp:119
TriangleFoot::updateBoxInteractiveMarker
void updateBoxInteractiveMarker()
Definition: triangle_foot.cpp:126
tools.h
TriangleFoot
Definition: triangle_foot.h:9
TriangleFoot::TriangleFoot
TriangleFoot()
Definition: triangle_foot.cpp:135
TriangleFoot::makeInteractiveMarker
visualization_msgs::InteractiveMarker makeInteractiveMarker()
Definition: triangle_foot.cpp:87
im_helpers::add6DofControl
void add6DofControl(visualization_msgs::InteractiveMarker &msg, bool fixed=false)
Definition: interactive_marker_helpers.cpp:132
pose
pose
interactive_markers::MenuHandler
TriangleFoot::size_
double size_
Definition: triangle_foot.h:31
interactive_marker_utils.h
main
int main(int argc, char **argv)
Definition: triangle_foot.cpp:152
argv
ROS_INFO ROS_ERROR int pointer * argv
TriangleFoot::marker_name
std::string marker_name
Definition: triangle_foot.h:28
TriangleFoot::menu_handler
interactive_markers::MenuHandler menu_handler
Definition: triangle_foot.h:30
_1
boost::arg< 1 > _1
TriangleFoot::makeFootMarker
visualization_msgs::Marker makeFootMarker(geometry_msgs::Pose pose)
Definition: triangle_foot.cpp:68
TriangleFoot::reverseTriangleCb
void reverseTriangleCb(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
Definition: triangle_foot.cpp:113
triangle_foot.h
TriangleFoot::pnh_
ros::NodeHandle pnh_
Definition: triangle_foot.h:24
interactive_markers::InteractiveMarkerServer
ros::this_node::getName
const ROSCPP_DECL std::string & getName()
ros::Time
std
interactive_markers::MenuHandler::insert
EntryHandle insert(const std::string &title, const FeedbackCallback &feedback_cb)
ros::NodeHandle::param
T param(const std::string &param_name, const T &default_val) const
TriangleFoot::server_
std::shared_ptr< interactive_markers::InteractiveMarkerServer > server_
Definition: triangle_foot.h:25
TriangleFoot::makeLFootMarker
visualization_msgs::Marker makeLFootMarker()
Definition: triangle_foot.cpp:53
ros::spin
ROSCPP_DECL void spin()
TriangleFoot::server_name
std::string server_name
Definition: triangle_foot.h:27


jsk_interactive_marker
Author(s): furuta
autogenerated on Fri Aug 2 2024 08:50:24