Ask Your Question
0

Error while catkin_make with ompl code

asked 2018-06-07 15:39:53 -0600

manas93 gravatar image

Hi, I am writing a simple program for OMPL to publish the path in ROS. while I doing catkin_make for the below code and getting following error.

Code: #include "ros/ros.h" #include "geometry_msgs/Point.h" #include <ompl base="" statespace.h=""> #include <omplapp apps="" se3rigidbodyplanning.h=""> #include <omplapp config.h=""> #include <vector> #include <ompl geometric="" planners="" rrt="" rrtsharp.h=""> #include <ompl geometric="" pathgeometric.h=""> #include<iostream>

using namespace ompl;

int main(int argc,char **argv) {

// Declaring the variables

std::vector<geometry_msgs::Point> traj;
geometry_msgs::Point node;

// Initializing the node to publish the data      
ros::init(argc,argv,"bot1");

// Creating a node handle for the node
ros::NodeHandle bot_1;


// Defining the topic and the message type
ros::Publisher waypoints_pub=bot_1.advertise<geometry_msgs::Point>("trajectory_bot1",10);


// plan in SE3, defining the setup in 3D state space
app::SE3RigidBodyPlanning setup;

// loading the robot and the environment
std::string robot_fname = std::string(OMPLAPP_RESOURCE_DIR) + "/3D/quadrotor.dae";
std::string env_fname = std::string(OMPLAPP_RESOURCE_DIR) + "/3D/manhattan-19k.dae";
setup.setRobotMesh(robot_fname);
setup.setEnvironmentMesh(env_fname);

// define start state
base::ScopedState<base::SE3StateSpace> start(setup.getSpaceInformation());
start->setX(-20.38);
start->setY(-0.11);
start->setZ(-90.72);
start->rotation().setIdentity();

// define goal state
base::ScopedState<base::SE3StateSpace> goal(start);
goal->setX(800.49);
goal->setY(-0.11);
goal->setZ(45.72);
goal->rotation().setIdentity();

// set the start & goal states
setup.setStartAndGoalStates(start, goal);

// setting collision checking resolution to 1% of the space extent
setup.getSpaceInformation()->setStateValidityCheckingResolution(0.1);

//Setting up the planner- RRT#
setup.setPlanner(std::make_shared<geometric::RRTsharp>(setup.getSpaceInformation()));

// we call setup just so print() can show more information
setup.setup();
setup.print();

// try to solve the problem
if (setup.solve(10))
{
    // simplify & print the solution
    setup.simplifySolution();


       // setup.getSolutionPath().printAsMatrix(std::cout);

    // computing the path and storing into ompl_path variable
auto ompl_path = setup.getSolutionPath();

// creating object to extarct the path components
geometric::PathGeometric path (ompl_path);

// Counting the number of states in the path
unsigned int number_of_states = path.getStateCount();


// Displaying the number of states computed
std::cout<< number_of_states<<std::endl;


// converting the OMPL states into ROS pose
for ( int i=0; i<number_of_states; i++)
{
    node.x=path.getState(i)->as<base::SE3StateSpace::StateType>()->getX();
    node.y=path.getState(i)->as<base::SE3StateSpace::StateType>()->getY();
    node.z=path.getState(i)->as<base::SE3StateSpace::StateType>()->getZ();

    traj.push_back(node);
}

}

//Publishing the computed trajectory on the topic "trajectory_bot1"
waypoints_pub.publish(traj);

return 0;

}

Error:

In file included from /opt/ros/kinetic/include/ros/serialization.h:37:0, from /opt/ros/kinetic/include/ros/publisher.h:34, from /opt/ros/kinetic/include/ros/node_handle.h:32, from /opt/ros/kinetic/include/ros/ros.h:45, from /home/manas/catkin_ws/src/testing/Practice.cpp:12: /opt/ros/kinetic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::MD5Sum<m>::value(const M&) [with M = std::vector<geometry_msgs::point_<std::allocator<void> > >]’: /opt/ros/kinetic/include/ros/message_traits.h:255:102: required from ‘const char* ros::message_traits::md5sum(const M&) [with M = std::vector<geometry_msgs::point_<std::allocator<void ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-06-08 10:35:27 -0600

I believe your issue is in the second-to-last line:

waypoints_pub.publish(traj);

Specifically, a ROS publisher can only publish ROS messages (see the API docs), but traj is a std::vector, which explains the line your error:

error: ‘const class std::vector<geometry_msgs::point_<std::allocator<void> > >’ has no member named ‘__getMD5Sum’

The publisher expect the type that you pass in to have the method __getMD5Sum, which std::vector does not have.

I expect that you are looking for some message in trajectory_msgs, or you could make your own message that is a list of geometry_msgs::Points.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-06-07 15:39:53 -0600

Seen: 62 times

Last updated: Jun 08 '18