Closed dudekw closed 8 years ago
Hi,
This is the only API call I haven't implemented yet, I need some kind of wrapper since the documentation was using ROS parameters.
Look at our branch, wut_devel, where all the necessary objects (pose, pose_stamped, point, path etc.) are created: https://github.com/rapp-project/rapp-api/tree/wut_devel/cpp/includes/objects
@alexge233 If you require any further information, let me know.
@alexge233 any updates?
@dudekw earliest I can work on this is during this weekend, apologies.
Ok, thank you @alexge233
Sorry @alexge233 for being so impatient, but @klpanagi would like to test Hazard detection RApp and it depends on this service.
Hi,
I'm afraid that I am on vacation and away until the 7th of July.
I've updated the code but haven't tested it; I don't have the latest platform, and I could really use an example (under /examples
) to go with navigation.
Also, I've raised some issues regarding the JSON format with @klpanagi, especially concerning the keys used for start_pose
and end_pose
.
The C++ code should work, but the example may require careful linking. Also there is no response processing yet.
@dudekw @klpanagi
Please note that this issue cannot be closed or solved for the following reasons:
start
and goal
pose_stamped.
It makes no sense to know beforehand future pose_stamped
and especially the time
or timestamp, or the quaternion. I would suggest that it is changed to accept a starting pose_stamped
and a goal coordinate
or cartesian
or pose
(see issue #43) without the use of time
or header
(also see issue #42 and issue #41).Finally, I suggest that some kind of factory class is written which will create automatically, either pose
or pose_stamped
. This most likely will be in the robot-api.
Please use std::chrono and not platform-specific time functions!
Please try to coordinate in order to close this issue as soon as possible. Thanks!
I agree with @etsardou that it is over-engineered to use the pose_stamped structure for this service.
Web service input arguments depends on the relevant ROS Service request message structure. Maybe @dudekw can modify the ROS Service request message structure, as proposed by @etsardou, in the future, and i will apply the changes to the web service and rapp-platform-api respectively.
Keep in mind that we are currently working on the Final RApp implementations and we do not have the time to make those changes, as we will have to patch both the RAPP Platform and the APIs.
the JSON used has no keys for "start" and "goal". While this may be acceptable in JS or Python, in C++/Boost it isn't, as it will most certainly be a source of problems. Thus it requires that a key "start" and a key "end" are given, so that I may deserialise it properly with member checks.
I do not understand what you mean. The JSON used has the start
and goal
keys... Do you mean that those objects do not have static members? Current used start and goal messages have the structure of a pose_stamped message.
Hi,
Maybe I wasn't clear enough:
start
and goal
with named keys, ok?I'll provide an example later this week.
About 1:
You were clear about the future timestamp, thats why I talked about overengineering on using the ROS structs. Nevertheless I cannot see how this affects you since its the user (app) that provides the timestamp variable whereas you must just implement the value passing to the ROS service.
Input = {
"map_name": 'THE_PRESTORED_MAP_NAME',
"robot_type": 'NAO',
"algorithm": "dijkstra",
"start": {header: {seq: 0, stamp: {sec: 0, nsec: 0}, frameid: '/map'},
pose: {position: {x: 1, y: 0, z: 0}, orientation: {x: 0, y: 0, z: 0, w: 1}}},
"goal": {header: {seq: 0, stamp: {sec: 0, nsec: 0}, frameid: '/map'},
pose: {position: {x: 2, y: 2, z: 0}, orientation: {x: 0, y: 0, z: 0, w: 1}}}
}
,where THE_PRESTORED_MAP_NAME
is name of an exemplary map. The map files must exist in the following paths:
~/rapp_platform_files/maps/"+'user_name'+"/"+'THE_PRESTORED_MAP_NAME'+".yaml
~/rapp_platform_files/maps/"+'user_name'+"/"+'THE_PRESTORED_MAP_NAME'+".png
exemplary map files can be found here: (https://github.com/rapp-project/rapp-platform/tree/master/rapp_path_planning/rapp_map_server/maps)
Yes, you can pass zeros to the goal time stamp.
@etsardou it doesn't affect me, other than I will ignore empty or incorrect timestamps (in fact I will do no checks), just asking and making it clear to all parties.
@dudekw thanks for the reply. I will finalise the api, and write a functional example using what you've provided. I will notify you (and close the issue) once I do so, and then ask you to test it.
I am also guessing that I need to do the JSON deserialisation of the planned path? I don't see anything doing that in the robot-api code.
Closing this, I've implemented the class but it is untested - somebody with the platform running please test it, and re-open if you find any issues.
Once verified its working, I will migrate the code from handle_reply
into individual handlers of all struct
involved, in a load_from_json
function.
@alexge233 the RAPP Platform is launched in 155.207.19.229, so you can test the call's validity as well.
@etsardou this ip is either blocking me, or is down, I only get time-outs.
I have just tested it and its working. To be sure you can test it by executing this. If this does not execure correctly please post the output.
Of course, make sure that you have declared the correct IP/port in the config file.
Still can't access it ping 155.207.19.229
returns timeouts, as does ssh
.
Do I need to be whitelisted or something?
Did you try it with the Python API as well? ssh wont work, its disabled.
If both C++ and Python APIs wont work then something is wrong with the server. @maciek-slon can you try calling a service in this IP as well?
No I haven't tried with python, the host seems unreachable from here, are you accessing it from outside your LAN/WAN ?
EDIT: from c++ I get error: broken pipe
.
I have just tested it from home (out of the university) using the Python API (I just executed the rapp_run_test.py
and I can access it. When you say time-out what do you mean? Can you post the output? Also the credentials in the .config/rapp_platform
are correct?
@etsardou time-out as in the server does not respond to me (simple pings).
EDIT I was wrong, its simply taking too long to respond, and I am guessing the connections are assumed dropped!
Starting Nmap 6.49BETA5 ( https://nmap.org ) at 2016-07-25 17:06 BST
Nmap scan report for rapp.ee.auth.gr (155.207.19.229)
Host is up (0.12s latency).
Not shown: 999 filtered ports
PORT STATE SERVICE
9001/tcp open tor-orport
Nmap done: 1 IP address (1 host up) scanned in 92.66 seconds
I did a traceroute as well, it seems that on average its more than 120sec to access the platform :-(
I think ping is disabled as well. Can you run the python script?
no because it requires the platform.
I'm trying to solve the broken pipe
error I get, which I think it has to do with the header.
You mean you have not cloned the platform in your PC? It does not require the platform to be running.
ok, I'll give it a try then! Does the token need to be valid at this point?
Of course. You can execute this to setup the token https://github.com/rapp-project/rapp-platform-scripts/blob/master/setup/13_authentication_setup.sh
ok, this explains the 401
(invalid http header) which in reality translates to "Unauthorized access".
it does not however solve the broken pipe
issue.
@alexge233 Is this issue resolved? I tried to compile the path_planning service example and I got some errors in rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp
file.
@dudekw can you post the errors please?
after including:
#include "objects/pose_stamped/pose_stamped.hpp"
#include "objects/planned_path/planned_path.hpp"
#include "objects/yaml/yaml.hpp"
#include "objects/picture/picture.hpp"
#include <chrono>
#include <boost/property_tree/json_parser.hpp>
#include "objects/pose_metadata/pose_metadata.hpp"
and changing:
tree.add_child("", end.treefy());
to:
tree.add_child("", goal.treefy());
after above changes, got following erorrs:
In file included from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp:2:0:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp: In member function ‘void rapp::cloud::plan_path_2d::handle_reply(std::string)’:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:94:58: error: expected primary-expression before ‘(’ token
meta = std::unique_ptr<rapp::object::pose_metadata>(new meta(iter));
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:94:63: error: expected type-specifier before ‘meta’
meta = std::unique_ptr<rapp::object::pose_metadata>(new meta(iter));
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:97:22: error: ‘pose’ was not declared in this scope
std::unique_ptr<pose> pose;
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:97:22: note: suggested alternative:
In file included from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_stamped/includes.ihh:1:0,
from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_stamped/pose_stamped.hpp:3,
from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:5,
from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp:2:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose/pose.hpp:13:8: note: ‘rapp::object::pose’
struct pose
^
In file included from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp:2:0:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:97:26: error: template argument 1 is invalid
std::unique_ptr<pose> pose;
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:97:26: error: template argument 2 is invalid
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:97:32: error: invalid type in declaration before ‘;’ token
std::unique_ptr<pose> pose;
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:98:21: error: ‘else’ without a previous ‘if’
else if (iter->first == "pose") {
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:99:30: error: the value of ‘pose’ is not usable in a constant expression
pose = std::unique_ptr<pose>(new pose(iter));
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:97:22: note: ‘pose’ was not declared ‘constexpr’
std::unique_ptr<pose> pose;
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:99:34: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Dp> class std::unique_ptr’
pose = std::unique_ptr<pose>(new pose(iter));
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:99:34: error: expected a type, got ‘pose’
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:99:34: error: template argument 2 is invalid
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:99:40: error: expected type-specifier before ‘pose’
pose = std::unique_ptr<pose>(new pose(iter));
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:102:39: error: expected primary-expression before ‘:’ token
path.push_back(std:move(ps));
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:111:84: error: no matching function for call to ‘rapp::object::planned_path::planned_path(std::string&, std::string&, std::vector<rapp::object::pose_stamped>&)’
delegate_(std::move(rapp::object::planned_path(plan_found, plan_error, path)));
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:111:84: note: candidates are:
In file included from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:6:0,
from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp:2:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/planned_path/planned_path.hpp:41:5: note: rapp::object::planned_path::planned_path(const rapp::object::planned_path&)
planned_path(const rapp::object::planned_path &) = default;
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/planned_path/planned_path.hpp:41:5: note: candidate expects 1 argument, 3 provided
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/planned_path/planned_path.hpp:38:5: note: rapp::object::planned_path::planned_path()
planned_path() = default;
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/planned_path/planned_path.hpp:38:5: note: candidate expects 0 arguments, 3 provided
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/planned_path/planned_path.hpp:28:2: note: rapp::object::planned_path::planned_path(uint8_t, std::string, std::vector<rapp::object::pose_stamped>)
planned_path(
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/planned_path/planned_path.hpp:28:2: note: no known conversion for argument 1 from ‘std::string {aka std::basic_string<char>}’ to ‘uint8_t {aka unsigned char}’
In file included from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp:2:0:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp: At global scope:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:199:38: error: template argument 1 is invalid
std::function<void(std::string>)> delegate_;
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp: In constructor ‘rapp::cloud::path_upload_map::path_upload_map(const rapp::object::picture&, const rapp::object::yaml&, std::string, std::function<void(std::basic_string<char>)>)’:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:134:38: error: invalid user-defined conversion from ‘std::function<void(std::basic_string<char>)>’ to ‘int’ [-fpermissive]
: asio_http(), delegate_(callback)
^
In file included from /usr/include/c++/4.8/thread:39:0,
from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/service_controller/includes.ihh:1,
from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/service_controller/service_controller.hpp:3,
from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp:1:
/usr/include/c++/4.8/functional:2386:16: note: candidate is: std::function<_Res(_ArgTypes ...)>::operator bool() const [with _Res = void; _ArgTypes = {std::basic_string<char, std::char_traits<char>, std::allocator<char> >}] <near match>
explicit operator bool() const noexcept
^
/usr/include/c++/4.8/functional:2386:16: note: return type ‘bool’ of explicit conversion function cannot be converted to ‘int’ with a qualification conversion
In file included from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp:2:0:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp: In member function ‘void rapp::cloud::path_upload_map::handle_reply(std::string)’:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:195:24: error: expression cannot be used as a function
delegate_(error);
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp: In function ‘int main(int, char**)’:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp:30:86: error: no matching function for call to ‘rapp::object::pose_metadata::pose_metadata(int, std::chrono::nanoseconds&)’
auto start = rapp::object::pose_stamped(rapp::object::pose_metadata(0,nanosec),rapp::object::pose(rapp::object::point(argv[1],argv[2],argv[3]), rapp::object::quaternion(argv[4],argv[5],argv[6],argv[7])))
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp:30:86: note: candidates are:
In file included from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_stamped/includes.ihh:2:0,
from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_stamped/pose_stamped.hpp:3,
from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/cloud/navigation/path_planning/path_planning.hpp:5,
from /home/wojciech/rapp/rapp-api/src/rapp-api/cpp/examples/path_planning.cpp:2:
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_metadata/pose_metadata.hpp:36:2: note: rapp::object::pose_metadata::pose_metadata(boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >::const_iterator)
pose_metadata(boost::property_tree::ptree::const_iterator json)
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_metadata/pose_metadata.hpp:36:2: note: candidate expects 1 argument, 2 provided
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_metadata/pose_metadata.hpp:33:5: note: rapp::object::pose_metadata::pose_metadata(const rapp::object::pose_metadata&)
pose_metadata(const rapp::object::pose_metadata &) = default;
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_metadata/pose_metadata.hpp:33:5: note: candidate expects 1 argument, 2 provided
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_metadata/pose_metadata.hpp:30:5: note: rapp::object::pose_metadata::pose_metadata()
pose_metadata() = default;
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_metadata/pose_metadata.hpp:30:5: note: candidate expects 0 arguments, 2 provided
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_metadata/pose_metadata.hpp:21:5: note: rapp::object::pose_metadata::pose_metadata(int, rapp::object::time, std::string)
pose_metadata(
^
/home/wojciech/rapp/rapp-api/src/rapp-api/cpp/includes/objects/pose_metadata/pose_metadata.hpp:21:5: note: candidate expects 3 arguments, 2 provided
@dudekw can you post your example here on Github, or submit it in branch cpp
under examples
?
I think its only a matter of using the namespace (I forgot rap::object::
) but I would like to test it myself.
Many thanks.
@alexge233 Following example should do the work:
#include "cloud/service_controller/service_controller.hpp"
#include "cloud/navigation/path_planning/path_planning.hpp"
#include "objects/pose_stamped/pose_stamped.hpp"
#include "objects/planned_path/planned_path.hpp"
#include "objects/yaml/yaml.hpp"
#include "objects/picture/picture.hpp"
#include <chrono>
#include <stdlib.h>
///
/// Pass as param start and goal poses and path to png and yaml file and map name
///
int main(int argc, char* argv[])
{
if (argc == 18) {
// service controler
rapp::cloud::platform_info info = {"155.207.19.229", "9001", "rapp_token"};
rapp::cloud::service_controller ctrl(info);
// callback lambda UPLOAD MAP
auto upload_callback = [&](std::string status)
{std::cout << "upload status: \n" << status << " \n" << std::endl;};
// upload map
std::string yaml_file_name = argv[16];
std::string png_file_name = argv[15];
auto yaml_file = rapp::object::yaml(yaml_file_name);
auto picture_file = rapp::object::picture(png_file_name);
ctrl.make_call<rapp::cloud::path_upload_map>(picture_file, yaml_file, upload_callback);
//set start and goal
std::chrono::nanoseconds nanosec(10);
auto start = rapp::object::pose_stamped(rapp::object::pose_metadata(0,nanosec),rapp::object::pose(rapp::object::point((float) atof(argv[1]),(float) atof(argv[2]),(float) atof(argv[3])), rapp::object::quaternion((float) atof(argv[4]),(float) atof(argv[5]),(float) atof(argv[6]),(float) atof(argv[7]))));
auto goal = rapp::object::pose_stamped(rapp::object::pose_metadata(0,nanosec),rapp::object::pose(rapp::object::point((float) atof(argv[8]),(float) atof(argv[9]),(float) atof(argv[10])), rapp::object::quaternion((float) atof(argv[11]),(float) atof(argv[12]),(float) atof(argv[13]),(float) atof(argv[14]))));
// callback lambda PLAN_PATH_2D
auto callback = [&](rapp::object::planned_path path)
{std::cout << "is plan found? \n" << path.plan_found << " \n" << std::endl;};
// detect faces
std::string map_name = argv[17];
ctrl.make_call<rapp::cloud::path_planning>(map_name, "NAO", start, goal, callback);
return 0;
}
}
@dudekw a few remarks:
pose_metadata
using std::chrono::nanoseconds
, but it takes a parameter sequence
, time
and frameid
.rapp::object::time
takes only one parameter, not two.path_planning
, theres only plan_path_2d
and path_upload_map
. My guess is you want the first, which also takes an additional parameter algorithm
.path_upload_map
is missing the string parameter map
.I've uploaded an example examples/path_planner.cpp
which compiles but may not work (haven't tested it yet).
@alexge233 Thank you very much! Sorry for untested example code, but I couldn't compile it before.
Current plan_path_2d cloud API implementation is copy-paste of a speech API method. Proper plan_path_2d method implementation is required to the incoming release. Could you help me with the issue?