Skip to content

Commit f3676ee

Browse files
committed
getting robot model
1 parent f8d4e81 commit f3676ee

File tree

7 files changed

+39
-23
lines changed

7 files changed

+39
-23
lines changed

base_placement_plugin/include/base_placement_plugin/add_robot_base.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <rviz/properties/string_property.h>
2929
#include <base_placement_plugin/widgets/base_placement_widget.h>
3030
#include <base_placement_plugin/place_base.h>
31+
#include <base_placement_plugin/create_marker.h>
3132

3233
#include <QWidget>
3334
#include <QCursor>
@@ -55,7 +56,7 @@ class AddRobotBase : public QObject
5556
{
5657
Q_OBJECT;
5758
public:
58-
AddRobotBase(QWidget* parent = 0);
59+
AddRobotBase(QWidget* parent, std::string group_name);
5960
virtual ~AddRobotBase();
6061
void init();
6162

@@ -77,10 +78,10 @@ class AddRobotBase : public QObject
7778
void getWaypoints(std::vector<geometry_msgs::Pose>& waypoints);
7879

7980

81+
8082
public Q_SLOTS:
8183
void parseWayPoints();
8284
void clearAllPointsRviz();
83-
8485
void getRobotModelFrame_slot(const tf::Transform end_effector);
8586

8687
protected:
@@ -113,6 +114,8 @@ class AddRobotBase : public QObject
113114
std::string target_frame_;
114115

115116
visualization_msgs::MarkerArray robot_markers_;
117+
CreateMarker* mark_;
118+
std::string group_name_;
116119

117120
};
118121

base_placement_plugin/include/base_placement_plugin/place_base.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ public Q_SLOTS:
121121
//! Send the output types to the GUI
122122
void sendGroupType_signal(std::vector< std::string > group_names);
123123

124+
//! Send the selected groupd
125+
void sendSelectedGroup_signal(std::string group_name);
126+
124127

125128

126129
protected:
@@ -211,7 +214,7 @@ public Q_SLOTS:
211214
//show unreachable models
212215
bool show_ureach_models_;
213216

214-
217+
//Pointer for robot marker
215218
CreateMarker* mark_;
216219
};
217220

base_placement_plugin/include/base_placement_plugin/widgets/base_placement_widget.h

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class BasePlacementWidget : public QWidget
8787
//! Bool value to show/unshow map
8888
bool show_union_map_;
8989
bool show_umodels_;
90+
std::string group_name_;
9091

9192
private:
9293
QStringList pointList;
@@ -152,6 +153,8 @@ protected Q_SLOTS:
152153
void getOutputType(std::vector< std::string > op_types);
153154
//! Set the ouput type name in the ComboBox
154155
void getRobotGroups(std::vector< std::string > groups);
156+
//! Get selected group from place_base
157+
void getSelectedGroup(std::string group_name);
155158

156159
void selectedMethod(int index);
157160
void selectedOuputType(int op_index);
@@ -193,6 +196,7 @@ protected Q_SLOTS:
193196
//!Sending baseposes selected by user
194197
void SendBasePoses(std::vector<geometry_msgs::Pose>);
195198

199+
196200
};
197201
}
198202

base_placement_plugin/src/add_robot_base.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#include<base_placement_plugin/add_robot_base.h>
22
#include <Eigen/Eigen>
33
#include <eigen_conversions/eigen_msg.h>
4-
#include <base_placement_plugin/create_marker.h>
54

65

7-
AddRobotBase::AddRobotBase(QWidget *parent)
6+
7+
AddRobotBase::AddRobotBase(QWidget *parent , std::string group_name)
88
{
9+
group_name_ = group_name;
910
init();
1011
}
1112

@@ -62,9 +63,10 @@ void AddRobotBase::init()
6263
menu_handler.setCheckState(menu_handler.insert("Fine adjustment", boost::bind(&AddRobotBase::processFeedback, this, _1)),
6364
interactive_markers::MenuHandler::UNCHECKED);
6465

65-
CreateMarker mark("arm");
66-
//visualization_msgs::MarkerArray markArr;
67-
robot_markers_ = mark.getDefaultMarkers();
66+
67+
mark_ = new CreateMarker(group_name_);
68+
robot_markers_ = mark_->getDefaultMarkers();
69+
6870

6971

7072
//tf::Vector3 vec(-1, 0, 0);
@@ -77,16 +79,12 @@ void AddRobotBase::init()
7779

7880
box_pos = trns;
7981
target_frame_.assign("base_link");
80-
ROS_INFO_STREAM("The robot model frame is_+: " << target_frame_);
82+
ROS_INFO_STREAM("The robot model frame is: " << target_frame_);
8183
makeInteractiveMarker();
8284
server->applyChanges();
8385
ROS_INFO("User base placement interactive marker started.");
8486
}
8587

86-
87-
88-
89-
9088
void AddRobotBase::processFeedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
9189
{
9290
switch (feedback->event_type)

base_placement_plugin/src/add_way_point.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ void AddWayPoint::onInitialize()
8585
SLOT(getOutputType(std::vector< std::string >)));
8686
connect(place_base, SIGNAL(sendGroupType_signal(std::vector< std::string >)), widget_,
8787
SLOT(getRobotGroups(std::vector< std::string >)));
88+
connect(place_base, SIGNAL(sendSelectedGroup_signal(std::string)), widget_,
89+
SLOT(getSelectedGroup(std::string)));
8890

8991

9092

base_placement_plugin/src/place_base.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ void PlaceBase::getSelectedRobotGroup(int group_index)
102102
ROS_ERROR_STREAM("Is your selected group is a manipulator?? ");
103103
delete mark_;
104104
}
105+
Q_EMIT sendSelectedGroup_signal(selected_group_);
105106
}
106107

107108
void PlaceBase::getSelectedMethod(int index)

base_placement_plugin/src/widgets/base_placement_widget.cpp

+15-10
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ void BasePlacementWidget::showUreachModels()
9696
Q_EMIT SendShowUmodel(show_umodels_);
9797
}
9898

99+
void BasePlacementWidget::getSelectedGroup(std::string group_name)
100+
{
101+
group_name_ = group_name;
102+
}
103+
99104

100105
void BasePlacementWidget::showUnionMapFromUI()
101106
{
@@ -134,25 +139,25 @@ void BasePlacementWidget::getBasePlacePlanMethod(std::vector< std::string > meth
134139

135140
void BasePlacementWidget::selectedMethod(int index)
136141
{
142+
Q_EMIT SendSelectedMethod(index);
137143
if(index ==4)
138144
{
139-
ROS_INFO("AHA.The user intuition method is selected. Let's Play");
140-
add_robot = new AddRobotBase();
141-
142-
//add_robot to widget
143-
connect(this, SIGNAL(parseWayPointBtn_signal()), add_robot, SLOT(parseWayPoints()));
144-
connect(add_robot, SIGNAL(baseWayPoints_signal(std::vector<geometry_msgs::Pose>)), this, SLOT(getWaypoints(std::vector<geometry_msgs::Pose>)));
145-
connect(this, SIGNAL(clearAllPoints_signal()), add_robot, SLOT(clearAllPointsRviz()));
145+
if(group_name_.size()>0)
146+
{
147+
add_robot = new AddRobotBase(0 , group_name_);
148+
ROS_INFO("AHA.The user intuition method is selected. Let's Play");
149+
//add_robot to widget
150+
connect(this, SIGNAL(parseWayPointBtn_signal()), add_robot, SLOT(parseWayPoints()));
151+
connect(add_robot, SIGNAL(baseWayPoints_signal(std::vector<geometry_msgs::Pose>)), this, SLOT(getWaypoints(std::vector<geometry_msgs::Pose>)));
152+
connect(this, SIGNAL(clearAllPoints_signal()), add_robot, SLOT(clearAllPointsRviz()));
153+
}
146154
}
147155
else
148156
{
149157
if(!add_robot == 0)
150158
delete add_robot;
151159
add_robot = 0;
152160
}
153-
154-
155-
Q_EMIT SendSelectedMethod(index);
156161
}
157162

158163
void BasePlacementWidget::getWaypoints(std::vector<geometry_msgs::Pose> base_poses)

0 commit comments

Comments
 (0)