Robotics StackExchange | Archived questions

trajectory filter response with nothing

I've followed this tutorial

There seemed to be some out-dated information in this tutorial, so I modified some processes and did as follow :

roslaunch pr2_gazebo pr2_empty_world.launch

modify trajectoryfilterserver/launch/trajectoryfilter.launch so that it would load the config filterunnormalize.yaml. Therefore, this node will provide a service server named /trajectoryfilterserver/filter_trajectory with type armnavigationmsgs::FilterJointTrajectory

Then fill in the service request following the tutorial, and the startstate additionally, since the warning from the server node indicates. After setting all this up, the service response still response nothing. I think the most important parameter returned is res.trajectory.points[i].velocities and res.trajectory.points[i].timefromstart, but the size() of the velocities vectors is zero, and the value of timefrom_start is zero. How to use this service? Thanks~

Here is my source code :

#include "ros/ros.h"
#include "arm_navigation_msgs/FilterJointTrajectory.h"

const std::string FILTER_SERVER = "/trajectory_filter_server/filter_trajectory";

int main(int argc, char** argv)
{
    ros::init(argc, argv, "filter");
    ros::NodeHandle nh;

    ros::service::waitForService(FILTER_SERVER);
    ros::ServiceClient client = nh.serviceClient<arm_navigation_msgs::FilterJointTrajectory>(FILTER_SERVER);

    arm_navigation_msgs::FilterJointTrajectory::Request req;
    arm_navigation_msgs::FilterJointTrajectory::Response res;

    req.trajectory.joint_names.push_back("r_shoulder_pan_joint");
    req.trajectory.joint_names.push_back("r_shoulder_lift_joint");
    req.trajectory.joint_names.push_back("r_upper_arm_roll_joint");
    req.trajectory.joint_names.push_back("r_elbow_flex_joint");
    req.trajectory.joint_names.push_back("r_forearm_roll_joint");
    req.trajectory.joint_names.push_back("r_wrist_flex_joint");
    req.trajectory.joint_names.push_back("r_wrist_roll_joint");

    req.trajectory.points.resize(3);
    for(unsigned int i = 0; i < 3; i++)
    {
        req.trajectory.points[i].positions.resize(7);
    }

    req.trajectory.points[1].positions[0] = -2.0;
    req.trajectory.points[2].positions[0] = 0.0;
    req.trajectory.points[1].positions[1] = 0.0;
    req.trajectory.points[2].positions[1] = 1.0;
    req.trajectory.points[1].positions[2] = -3.0;
    req.trajectory.points[2].positions[2] = 0.0;
    req.trajectory.points[1].positions[3] = -2.0;
    req.trajectory.points[2].positions[3] = -1.0;
    req.trajectory.points[1].positions[4] = -2.0;
    req.trajectory.points[2].positions[4] = 1.0;
    req.trajectory.points[1].positions[5] = -2.0;
    req.trajectory.points[2].positions[5] = -1.0;
    req.trajectory.points[1].positions[6] = -2.0;
    req.trajectory.points[2].positions[6] = 1.0;

    req.allowed_time = ros::Duration(3.0);

    req.start_state.joint_state.name = req.trajectory.joint_names;
    req.start_state.joint_state.position.resize(7);
    req.start_state.joint_state.position.push_back(0.0);
    req.start_state.joint_state.position.push_back(0.0);
    req.start_state.joint_state.position.push_back(0.0);
    req.start_state.joint_state.position.push_back(-0.468);
    req.start_state.joint_state.position.push_back(0.0);
    req.start_state.joint_state.position.push_back(-0.79);
    req.start_state.joint_state.position.push_back(0.0);

    for(unsigned int i = 0; i < 7; i++)
    {
        req.start_state.joint_state.velocity.push_back(0.0);
    }


    if(client.call(req, res))
    {
        ROS_INFO("Filter service state : %d", res.error_code.val);
    }

    ROS_INFO("DBG_size:%d", res.trajectory.points[2].velocities.size());
    ROS_INFO("DBG_time:%f", res.trajectory.points[1].time_from_start.toSec());

    for(unsigned int i = 0; i < 7; i++)
        ROS_INFO("DBG:%f", res.trajectory.points[1].velocities[i]);

    for(unsigned int i = 0; i < 7; i++)
    {
        ROS_INFO("%s : pos[0]=%f, vel[0]=%f, time_from_start[0]=%f, pos[1]=%f, vel[1]=%f, time_from_start[1]=%f, pos[2]=%f, vel[2]=%f, time_from_start[2]=%f",
                req.trajectory.joint_names[i].c_str(), res.trajectory.points[0].positions[i], res.trajectory.points[0].velocities[i], res.trajectory.points[0].time_from_start.toSec(),
                res.trajectory.points[1].positions[i], res.trajectory.points[1].velocities[i], res.trajectory.points[1].time_from_start.toSec(),
                res.trajectory.points[2].positions[i], res.trajectory.points[2].velocities[i], res.trajectory.points[2].time_from_start.toSec());
    }

    ros::shutdown();
}

Asked by Albert K on 2012-12-16 17:59:25 UTC

Comments

Answers