Skip to content

Commit 331d2e0

Browse files
authored
Merge pull request #3167 from randaz81/returnValue_nav
New class for return values of interface methods PART2
2 parents 43ba030 + a32551f commit 331d2e0

File tree

119 files changed

+2290
-2171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+2290
-2171
lines changed

doc/release/master.md

+28-3
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,33 @@ New Features
3939
#### `libYARP_dev`
4040

4141
* added new class `yarp::dev::ReturnValue`
42-
* modified interfaces `yarp::dev::ISpeechSynthesizer`,`yarp::dev::ISpeechTranscription` to use the new class ReturnValue.
43-
42+
* The following interfaces have been modified to the new class ReturnValue:
43+
ISpeechSynthesizer
44+
ISpeechTranscription
45+
ILocalization2D
46+
IMap2D
47+
INavigation2D
48+
IOdometry2D
49+
4450
#### `devices`
4551

46-
* modified devices implementing `yarp::dev::ISpeechSynthesizer`,`yarp::dev::ISpeechTranscription` to use the new class ReturnValue.
52+
* Updated all devices which use the interfaces employing the new class `ReturnValue`:
53+
FakeSpeechSynthesizer
54+
FakeSpeechTranscription
55+
FakeNavigation
56+
FakeLocalizer
57+
FakeOdometry2D
58+
Map2DStorage
59+
SpeechTranscription_nws_yarp
60+
SpeechTranscription_nwc_yarp
61+
SpeechSynthesizer_nws_yarp
62+
SpeechSynthesizer_nwc_yarp
63+
Localization2D_nws_yarp
64+
Localization2D_nwc_yarp
65+
Map2D_nws_yarp
66+
Map2D_nwc_yarp
67+
MobileBaseVelocityControl_nws_yarp
68+
MobileBaseVelocityControl_nwc_yarp
69+
Navigation2D_nwc_yarp
70+
Navigation2D_nws_yarp
71+
Odometry2D_nws_yarp

src/devices/fake/fakeLocalizerDevice/FakeLocalizer.cpp

+27-27
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ namespace {
3737
YARP_LOG_COMPONENT(FAKELOCALIZER, "yarp.device.fakeLocalizer")
3838
}
3939

40-
bool FakeLocalizer::getLocalizationStatus(yarp::dev::Nav2D::LocalizationStatusEnum& status)
40+
yarp::dev::ReturnValue FakeLocalizer::getLocalizationStatus(yarp::dev::Nav2D::LocalizationStatusEnum& status)
4141
{
4242
std::lock_guard<std::mutex> lock(m_mutex);
43-
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return false; }
43+
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return yarp::dev::ReturnValue::return_code::return_value_error_method_failed;; }
4444

4545
status = yarp::dev::Nav2D::LocalizationStatusEnum::localization_status_localized_ok;
46-
return true;
46+
return yarp::dev::ReturnValue_ok;
4747
}
4848

49-
bool FakeLocalizer::getEstimatedPoses(std::vector<Map2DLocation>& poses)
49+
yarp::dev::ReturnValue FakeLocalizer::getEstimatedPoses(std::vector<Map2DLocation>& poses)
5050
{
5151
std::lock_guard<std::mutex> lock(m_mutex);
52-
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return false; }
52+
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return yarp::dev::ReturnValue::return_code::return_value_error_method_failed;; }
5353

5454
poses.clear();
5555
Map2DLocation loc;
@@ -74,56 +74,56 @@ bool FakeLocalizer::getEstimatedPoses(std::vector<Map2DLocation>& poses)
7474
poses.push_back(newloc);
7575
}
7676
#endif
77-
return true;
77+
return yarp::dev::ReturnValue_ok;
7878
}
7979

80-
bool FakeLocalizer::getCurrentPosition(Map2DLocation& loc)
80+
yarp::dev::ReturnValue FakeLocalizer::getCurrentPosition(Map2DLocation& loc)
8181
{
8282
std::lock_guard<std::mutex> lock(m_mutex);
83-
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return false; }
83+
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return yarp::dev::ReturnValue::return_code::return_value_error_method_failed; }
8484

8585
locThread->getCurrentLoc(loc);
86-
return true;
86+
return yarp::dev::ReturnValue_ok;
8787
}
8888

89-
bool FakeLocalizer::setInitialPose(const Map2DLocation& loc)
89+
yarp::dev::ReturnValue FakeLocalizer::setInitialPose(const Map2DLocation& loc)
9090
{
9191
std::lock_guard<std::mutex> lock(m_mutex);
92-
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return false; }
92+
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return yarp::dev::ReturnValue::return_code::return_value_error_method_failed; }
9393

9494
locThread->initializeLocalization(loc);
95-
return true;
95+
return yarp::dev::ReturnValue_ok;
9696
}
9797

98-
bool FakeLocalizer::getCurrentPosition(Map2DLocation& loc, yarp::sig::Matrix& cov)
98+
yarp::dev::ReturnValue FakeLocalizer::getCurrentPosition(Map2DLocation& loc, yarp::sig::Matrix& cov)
9999
{
100100
std::lock_guard<std::mutex> lock(m_mutex);
101-
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return false; }
101+
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return yarp::dev::ReturnValue::return_code::return_value_error_method_failed;; }
102102

103103
locThread->getCurrentLoc(loc,cov);
104-
return true;
104+
return yarp::dev::ReturnValue_ok;
105105
}
106106

107-
bool FakeLocalizer::setInitialPose(const Map2DLocation& loc, const yarp::sig::Matrix& cov)
107+
yarp::dev::ReturnValue FakeLocalizer::setInitialPose(const Map2DLocation& loc, const yarp::sig::Matrix& cov)
108108
{
109109
std::lock_guard<std::mutex> lock(m_mutex);
110-
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return false; }
110+
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return yarp::dev::ReturnValue::return_code::return_value_error_method_failed;; }
111111

112112
locThread->initializeLocalization(loc);
113-
return true;
113+
return yarp::dev::ReturnValue_ok;
114114
}
115115

116-
bool FakeLocalizer::getEstimatedOdometry(yarp::dev::OdometryData& odom)
116+
yarp::dev::ReturnValue FakeLocalizer::getEstimatedOdometry(yarp::dev::OdometryData& odom)
117117
{
118118
std::lock_guard<std::mutex> lock(m_mutex);
119-
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status" ; return false; }
119+
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status" ; return yarp::dev::ReturnValue::return_code::return_value_error_method_failed;; }
120120

121121
Map2DLocation loc;
122122
locThread->getCurrentLoc(loc);
123123
odom.odom_x = loc.x;
124124
odom.odom_y = loc.y;
125125
odom.odom_theta = loc.theta;
126-
return true;
126+
return yarp::dev::ReturnValue_ok;
127127
}
128128

129129
bool FakeLocalizer::open(yarp::os::Searchable& config)
@@ -151,20 +151,20 @@ FakeLocalizer::~FakeLocalizer()
151151
{
152152
}
153153

154-
bool FakeLocalizer::startLocalizationService()
154+
yarp::dev::ReturnValue FakeLocalizer::startLocalizationService()
155155
{
156156
std::lock_guard<std::mutex> lock(m_mutex);
157-
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return false; }
157+
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return yarp::dev::ReturnValue::return_code::return_value_error_method_failed;; }
158158

159-
return true;
159+
return yarp::dev::ReturnValue_ok;
160160
}
161161

162-
bool FakeLocalizer::stopLocalizationService()
162+
yarp::dev::ReturnValue FakeLocalizer::stopLocalizationService()
163163
{
164164
std::lock_guard<std::mutex> lock(m_mutex);
165-
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return false; }
165+
if (!locThread) { yCError(FAKELOCALIZER) << "Invalid status"; return yarp::dev::ReturnValue::return_code::return_value_error_method_failed;; }
166166

167-
return true;
167+
return yarp::dev::ReturnValue_ok;
168168
}
169169

170170
bool FakeLocalizer::close()

src/devices/fake/fakeLocalizerDevice/FakeLocalizer.h

+10-60
Original file line numberDiff line numberDiff line change
@@ -72,64 +72,14 @@ class FakeLocalizer :
7272
virtual bool close() override;
7373

7474
public:
75-
/**
76-
* Gets the current status of the localization task.
77-
* @return true/false
78-
*/
79-
bool getLocalizationStatus(yarp::dev::Nav2D::LocalizationStatusEnum& status) override;
80-
81-
/**
82-
* Gets a set of pose estimates computed by the localization algorithm.
83-
* @return true/false
84-
*/
85-
bool getEstimatedPoses(std::vector<yarp::dev::Nav2D::Map2DLocation>& poses) override;
86-
87-
/**
88-
* Gets the current position of the robot w.r.t world reference frame
89-
* @param loc the location of the robot
90-
* @return true/false
91-
*/
92-
bool getCurrentPosition(yarp::dev::Nav2D::Map2DLocation& loc) override;
93-
94-
/**
95-
* Sets the initial pose for the localization algorithm which estimates the current position of the robot w.r.t world reference frame.
96-
* @param loc the location of the robot
97-
* @return true/false
98-
*/
99-
bool setInitialPose(const yarp::dev::Nav2D::Map2DLocation& loc) override;
100-
101-
/**
102-
* Sets the initial pose for the localization algorithm which estimates the current position of the robot w.r.t world reference frame.
103-
* @param loc the location of the robot
104-
* @param cov the 3x3 covariance matrix
105-
* @return true/false
106-
*/
107-
virtual bool setInitialPose(const yarp::dev::Nav2D::Map2DLocation& loc, const yarp::sig::Matrix& cov) override;
108-
109-
/**
110-
* Gets the current position of the robot w.r.t world reference frame, plus the covariance
111-
* @param loc the location of the robot
112-
* @param cov the 3x3 covariance matrix
113-
* @return true/false
114-
*/
115-
virtual bool getCurrentPosition(yarp::dev::Nav2D::Map2DLocation& loc, yarp::sig::Matrix& cov) override;
116-
117-
/**
118-
* Gets the estimated odometry the robot, including its velocity expressed in the world and in the local reference frame.
119-
* @param loc the estimated odometry.
120-
* @return true/false
121-
*/
122-
virtual bool getEstimatedOdometry(yarp::dev::OdometryData& odom) override;
123-
124-
/**
125-
* Starts the localization service
126-
* @return true/false
127-
*/
128-
virtual bool startLocalizationService() override;
129-
130-
/**
131-
* Stops the localization service
132-
* @return true/false
133-
*/
134-
virtual bool stopLocalizationService() override;
75+
//methods inherited from yarp::dev::Nav2D::ILocalization2D
76+
yarp::dev::ReturnValue getLocalizationStatus(yarp::dev::Nav2D::LocalizationStatusEnum& status) override;
77+
yarp::dev::ReturnValue getEstimatedPoses(std::vector<yarp::dev::Nav2D::Map2DLocation>& poses) override;
78+
yarp::dev::ReturnValue getCurrentPosition(yarp::dev::Nav2D::Map2DLocation& loc) override;
79+
yarp::dev::ReturnValue setInitialPose(const yarp::dev::Nav2D::Map2DLocation& loc) override;
80+
yarp::dev::ReturnValue setInitialPose(const yarp::dev::Nav2D::Map2DLocation& loc, const yarp::sig::Matrix& cov) override;
81+
yarp::dev::ReturnValue getCurrentPosition(yarp::dev::Nav2D::Map2DLocation& loc, yarp::sig::Matrix& cov) override;
82+
yarp::dev::ReturnValue getEstimatedOdometry(yarp::dev::OdometryData& odom) override;
83+
yarp::dev::ReturnValue startLocalizationService() override;
84+
yarp::dev::ReturnValue stopLocalizationService() override;
13585
};

src/devices/fake/fakeNavigationDevice/FakeNavigation.cpp

+33-33
Original file line numberDiff line numberDiff line change
@@ -43,122 +43,122 @@ bool FakeNavigation:: close()
4343
return true;
4444
}
4545

46-
bool FakeNavigation::gotoTargetByAbsoluteLocation(Map2DLocation loc)
46+
ReturnValue FakeNavigation::gotoTargetByAbsoluteLocation(Map2DLocation loc)
4747
{
4848
if (m_status == NavigationStatusEnum::navigation_status_idle)
4949
{
5050
m_status = NavigationStatusEnum::navigation_status_moving;
5151
m_absgoal_loc = loc;
5252
m_time_counter= this->m_navigation_time;
5353
}
54-
return true;
54+
return ReturnValue_ok;
5555
}
5656

57-
bool FakeNavigation::gotoTargetByRelativeLocation(double x, double y, double theta)
57+
ReturnValue FakeNavigation::gotoTargetByRelativeLocation(double x, double y, double theta)
5858
{
5959
yCInfo(FAKENAVIGATION) << "gotoTargetByRelativeLocation not yet implemented";
60-
return true;
60+
return ReturnValue_ok;
6161
}
6262

63-
bool FakeNavigation::gotoTargetByRelativeLocation(double x, double y)
63+
ReturnValue FakeNavigation::gotoTargetByRelativeLocation(double x, double y)
6464
{
6565
yCInfo(FAKENAVIGATION) << "gotoTargetByRelativeLocation not yet implemented";
66-
return true;
66+
return ReturnValue_ok;
6767
}
6868

69-
bool FakeNavigation::followPath(const yarp::dev::Nav2D::Map2DPath& path)
69+
ReturnValue FakeNavigation::followPath(const yarp::dev::Nav2D::Map2DPath& path)
7070
{
7171
yCInfo(FAKENAVIGATION) << "followPath not yet implemented";
72-
return true;
72+
return ReturnValue_ok;
7373
}
7474

75-
bool FakeNavigation::applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout)
75+
ReturnValue FakeNavigation::applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout)
7676
{
7777
m_control_out.linear_xvel = x_vel;
7878
m_control_out.linear_yvel = y_vel;
7979
m_control_out.angular_vel = theta_vel;
8080
m_control_out.timeout = timeout;
8181
m_control_out.reception_time = yarp::os::Time::now();
82-
return true;
82+
return ReturnValue_ok;
8383
}
8484

85-
bool FakeNavigation::getLastVelocityCommand(double& x_vel, double& y_vel, double& theta_vel)
85+
ReturnValue FakeNavigation::getLastVelocityCommand(double& x_vel, double& y_vel, double& theta_vel)
8686
{
8787
double current_time = yarp::os::Time::now();
8888
x_vel = m_control_out.linear_xvel;
8989
y_vel = m_control_out.linear_yvel;
9090
theta_vel = m_control_out.angular_vel;
91-
return true;
91+
return ReturnValue_ok;
9292
}
9393

94-
bool FakeNavigation::stopNavigation()
94+
ReturnValue FakeNavigation::stopNavigation()
9595
{
9696
m_status=NavigationStatusEnum::navigation_status_idle;
9797
m_absgoal_loc=Map2DLocation();
98-
return true;
98+
return ReturnValue_ok;
9999
}
100100

101-
bool FakeNavigation::suspendNavigation(double time)
101+
ReturnValue FakeNavigation::suspendNavigation(double time)
102102
{
103103
if (m_status == NavigationStatusEnum::navigation_status_moving)
104104
{
105105
m_status=NavigationStatusEnum::navigation_status_paused;
106106
}
107-
return true;
107+
return ReturnValue_ok;
108108
}
109109

110-
bool FakeNavigation::resumeNavigation()
110+
ReturnValue FakeNavigation::resumeNavigation()
111111
{
112112
if (m_status == NavigationStatusEnum::navigation_status_paused)
113113
{
114114
m_status = NavigationStatusEnum::navigation_status_moving;
115115
}
116-
return true;
116+
return ReturnValue_ok;
117117
}
118118

119-
bool FakeNavigation::getAllNavigationWaypoints(yarp::dev::Nav2D::TrajectoryTypeEnum trajectory_type, yarp::dev::Nav2D::Map2DPath& waypoints)
119+
ReturnValue FakeNavigation::getAllNavigationWaypoints(yarp::dev::Nav2D::TrajectoryTypeEnum trajectory_type, yarp::dev::Nav2D::Map2DPath& waypoints)
120120
{
121121
yCInfo(FAKENAVIGATION) << "getAllNavigationWaypoints not yet implemented";
122-
return true;
122+
return ReturnValue_ok;
123123
}
124124

125-
bool FakeNavigation::getCurrentNavigationWaypoint(Map2DLocation& curr_waypoint)
125+
ReturnValue FakeNavigation::getCurrentNavigationWaypoint(Map2DLocation& curr_waypoint)
126126
{
127127
yCInfo(FAKENAVIGATION) << "getCurrentNavigationWaypoint not yet implemented";
128-
return true;
128+
return ReturnValue_ok;
129129
}
130130

131-
bool FakeNavigation::getCurrentNavigationMap(yarp::dev::Nav2D::NavigationMapTypeEnum map_type, MapGrid2D& map)
131+
ReturnValue FakeNavigation::getCurrentNavigationMap(yarp::dev::Nav2D::NavigationMapTypeEnum map_type, MapGrid2D& map)
132132
{
133133
yCInfo(FAKENAVIGATION) << "getCurrentNavigationMap not yet implemented";
134-
return true;
134+
return ReturnValue_ok;
135135
}
136136

137-
bool FakeNavigation::getNavigationStatus(yarp::dev::Nav2D::NavigationStatusEnum& status)
137+
ReturnValue FakeNavigation::getNavigationStatus(yarp::dev::Nav2D::NavigationStatusEnum& status)
138138
{
139139
status = m_status;
140-
return true;
140+
return ReturnValue_ok;
141141
}
142142

143-
bool FakeNavigation::getAbsoluteLocationOfCurrentTarget(Map2DLocation& target)
143+
ReturnValue FakeNavigation::getAbsoluteLocationOfCurrentTarget(Map2DLocation& target)
144144
{
145-
target=m_absgoal_loc;
146-
return true;
145+
target = m_absgoal_loc;
146+
return ReturnValue_ok;
147147
}
148148

149-
bool FakeNavigation::recomputeCurrentNavigationPath()
149+
ReturnValue FakeNavigation::recomputeCurrentNavigationPath()
150150
{
151151
if (m_status == NavigationStatusEnum::navigation_status_moving)
152152
{
153153
//do something
154154
}
155-
return true;
155+
return ReturnValue_ok;
156156
}
157157

158-
bool FakeNavigation::getRelativeLocationOfCurrentTarget(double& x, double& y, double& theta)
158+
ReturnValue FakeNavigation::getRelativeLocationOfCurrentTarget(double& x, double& y, double& theta)
159159
{
160160
yCInfo(FAKENAVIGATION) << "getRelativeLocationOfCurrentTarget not yet implemented";
161-
return true;
161+
return ReturnValue_ok;
162162
}
163163

164164
bool FakeNavigation::threadInit()

0 commit comments

Comments
 (0)