ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Gauss Lee's profile - activity

2013-10-29 01:17:09 -0500 received badge  Famous Question (source)
2013-10-29 01:17:09 -0500 received badge  Notable Question (source)
2013-10-29 01:17:09 -0500 received badge  Popular Question (source)
2012-10-16 03:07:46 -0500 received badge  Famous Question (source)
2012-10-16 03:07:46 -0500 received badge  Popular Question (source)
2012-10-16 03:07:46 -0500 received badge  Notable Question (source)
2012-08-19 06:27:01 -0500 received badge  Famous Question (source)
2012-08-19 06:27:01 -0500 received badge  Popular Question (source)
2012-08-19 06:27:01 -0500 received badge  Notable Question (source)
2011-08-30 04:26:15 -0500 answered a question Why the ROS client could fail!

It works! Thanks a lot, Lorenz!!!

2011-08-30 04:21:01 -0500 received badge  Scholar (source)
2011-08-30 04:21:01 -0500 marked best answer Why the ROS client could fail!

Your service callback needs to have the line

return true;

at the end. If it returns false, the service call is considered as failed. If you don't return anything, I believe the behavior is undefined. You actually should get a compiler warning that the function doesn't return a value.

2011-08-30 04:20:55 -0500 commented answer Why the ROS client could fail!
Yes. Thank you! I suddenly find All my clients cannot work anymore. The roscore is warning it cannot write into the ROS_LOG_DIR, it needs reset! I do not know why? I just updated my ROS sometimes when it needs me to.
2011-08-30 04:20:55 -0500 commented answer Why the ROS client could fail!
Yes. Thank you! I suddenly find All my clients cannot work anymore. The roscore is warning it cannot write into the ROS_LOG_DIR, it needs reset! I do not know why? I just updated my ROS sometimes when it needs me to.
2011-08-30 03:36:53 -0500 answered a question Why the ROS client could fail!

Hi, I upload my full version of codes of the server, hope somebody can find out the errors!

The server can work but the the client always failed!

do not why, quite annoying!

#include "ros/ros.h"
#include <cstdlib>
#include <string.h>
#include <math.h>
#include "Crawlers/Cpg.h"
#include "Crawlers/joint.h"

class Pub{
public:
ros::NodeHandle p;
ros::Publisher pub;
Crawlers::joint data;
std::vector<float> posture;
public:
Pub(ros::NodeHandle s);
bool callback1(Crawlers::Cpg::Request &req,
               Crawlers::Cpg::Response &res);

};
Pub::Pub(ros::NodeHandle s){

p=s;
posture.resize(26);
//head///////////////
posture[0] = 0.0f;
posture[1] = -0.7;
/////leftleg//////////
posture[2]=-0.4f;   //LHipYawPitch
    posture[3]=0.2437f;  //LHipRoll
    posture[4]=-0.925f;  //LHipPitch
    posture[5]=1.8f;   //LKneePitch
    posture[6]=0.75f;   //LAnklePitch
    posture[7]=0.68f;    //AnkleRoll
    /////rightleg/////////
    posture[8]=-0.4f;   //RHipYawPitch
    posture[9]=-0.2437f;  //RHipRoll
    posture[10]=-0.925f;  //RHipPitch
    posture[11]=1.8f;   //RKneePitch
    posture[12]=0.75f;   //RAnklePitch
    posture[13]=-0.68f;    //RAnkleRoll
    ////leftarm////////
    posture[14]= 0.44f;    //LShoulderPitch
    posture[15]=0.1f;         //LShoulderRoll
    posture[16]=-1.58f;         //LElbowYaw
    posture[17]=-0.1f;         //LElbowRoll
    posture[18]=0.0f;            //LWaistYaw
    posture[19]=0.0f;          //RHand
    ////rightarm//////
    posture[20]= 0.44f;           //RShoulderPitch
    posture[21]=-0.1f;         //RShoulderRoll
    posture[22]=1.58f;         //RElbowYaw
    posture[23]=0.1f;         //RElbowRoll
    posture[24]=0.0f;            //RWaistYaw
    posture[25]=0.0f;          //RHand
pub = p.advertise<Crawlers::joint>("jointvalue", 1000);
}




bool Pub::callback1(Crawlers::Cpg::Request &req,
                   Crawlers::Cpg::Response &res){
  ///head
  data.HeadYaw = posture[0];

  data.HeadPitch = posture[1];
  ///leftleg
  data.LHipYawPitch = posture[2];

  data.LHipRoll = posture[3] - 0.25f*req.cpg3;

  data.LHipPitch = posture[4] + 0.4f*req.cpg3;

  data.LKneePitch = posture[5] -0.02f*req.cpg3;

  data.LAnklePitch = posture[6];

  data.LAnkleRoll = posture[7]; 

  ///rightleg
  data.RHipYawPitch = posture[8];

  data.RHipRoll = posture[9] +0.25f*req.cpg4;

  data.RHipPitch = posture[10] + 0.4f*req.cpg4;

  data.RKneePitch = posture[11]-0.02f*req.cpg4;

  data.RAnklePitch = posture[12];

  data.RAnkleRoll = posture[13];

  ///leftarm
  data.LShoulderPitch = posture[14] + 0.4f*req.cpg1;

  data.LShoulderRoll = posture[15] + 0.1f*req.cpg1;

  data.LElbowYaw = posture[16];

  data.LElbowRoll = posture[17] +(-0.1f)*exp(-(( 0.4f*req.cpg1 )-sqrt(0.2))/2.0);


  data.LWristYaw = posture[18];

  data.LHand = posture[19];
  ///rightarm
  data.RShoulderPitch = posture[20] + 0.4f* req.cpg2;

  data.RShoulderRoll = posture[21] - 0.1f* req.cpg2;

  data.RElbowYaw = posture[22];

  data.RElbowRoll = posture[23] + 0.1f*exp(-(( 0.4f*req.cpg2 )-sqrt(0.2))/2.0);

  data.RWristYaw = posture[24];

  data.RHand = posture[25];            
  pub.publish(data);
  ROS_INFO("Cpg1:[%f]", req.cpg1); ROS_INFO("Cpg2:[%f]", req.cpg2);                


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

  ros::init(argc, argv, "jointout");
  ros::NodeHandle s;
  Pub Node(s);
  ros::ServiceServer jointserv = s.advertiseService("Cpgdata", &Pub::callback1, &Node);
  ROS_INFO("ready to send joint data!");
  ros::spin();

}
2011-08-30 03:29:39 -0500 received badge  Supporter (source)
2011-08-30 03:24:14 -0500 commented answer Why the ROS client could fail!
Thank you for your reply. I do not know how to test with ROSSERVICE TOOL. Could you give me a simple example?
2011-08-30 01:00:28 -0500 asked a question Why the ROS client could fail!

I have implemented a new server and client. The server can work very well but the client always failed!! The errors are shown below:

The srv file is as follows:

float32 cpg1
float32 cpg2
float32 cpg3
float32 cpg4
---
float32 input1
float32 input2
float32 input3
float32 input4

And the crucial part of the client is:

ros::init(argc, argv, "Cpgvalue");

ros::NodeHandle node;
ros::ServiceClient crawling = node.serviceClient<Crawlers::Cpg>("Cpgdata");
Crawlers::Cpg crawlingdata;
std::vector<float> res;
res.resize(4);
ros::Rate loop_rate(1000);

while(ros::ok())
{
crawlingcpg.CpgNetworkCalculation(feedback);
crawlingdata.request.cpg1 = crawlingcpg.CpgResult[0];
crawlingdata.request.cpg2 = crawlingcpg.CpgResult[1];
crawlingdata.request.cpg3 = crawlingcpg.CpgResult[2];
crawlingdata.request.cpg4 = crawlingcpg.CpgResult[3];

    res[0] = crawlingdata.response.input1;
    res[1] = crawlingdata.response.input2;
    res[2] = crawlingdata.response.input3;
    res[3] = crawlingdata.response.input4;

loop_rate.sleep();

ROS_INFO("Cpg1:[%f]", crawlingcpg.CpgResult[0]); ROS_INFO("Cpg2:[%f]", crawlingcpg.CpgResult[1]);   
if (crawling.call(crawlingdata))
    {      
      ROS_INFO("suceeded!");
    }
    else{
      ROS_INFO("client failed" );
      return 1;     
    }

    ros::spin();
}
return 0;

Whatever I modified, I always got the same error:

[ INFO] [1314708828.730975843]: client failed

Can somebody figure out what is the problem?

2011-07-22 01:52:10 -0500 received badge  Editor (source)
2011-07-22 01:51:42 -0500 commented question About "No module named yaml" error
But I do not know why this happens!!!! Why AL_DIR is clashed to ROS!
2011-07-22 01:51:11 -0500 commented question About "No module named yaml" error
I located the problem in my .bashrc file, it is that AL_DIR is set. IF I comment AL_DIR which is supposed to be NAOSDK dir. Then ROS can find the yaml module.
2011-07-22 01:51:10 -0500 commented question About "No module named yaml" error
I located the problem in my .bashrc file, it is that AL_DIR is set. IF I comment AL_DIR which is supposed to be NAOSDK dir. Then ROS can find the yaml module.
2011-07-22 01:51:10 -0500 commented question About "No module named yaml" error
I located the problem in my .bashrc file, it is that AL_DIR is set. IF I comment AL_DIR which is supposed to be NAOSDK dir. Then ROS can find the yaml module.
2011-07-22 00:49:56 -0500 answered a question About "No module named yaml" error

Is it about the PYTHONPATH setting? Or something else, I am not sure...

2011-07-22 00:08:50 -0500 asked a question About "No module named yaml" error

Hi, ROS experts,

I have recently run into the same problem on struggling with "no module named yaml" frequently!

Obviously, I have already installed the yaml lib, every time I install ROS, there is no such kind of errors. But afterwards, this error will occur especially after I edit the bashrc to add some new paths.

Could somebody tell you what is the problem on my ROS! I am sure I did not change any path settings on ROS!

Updated:

I located the problem in my .bashrc file, it is that AL_DIR is set. IF I comment AL_DIR which is supposed to be NAOSDK dir. Then ROS can find the yaml module. Somebody tells me why?

Best,

Gauss

2011-07-19 05:19:13 -0500 marked best answer response of a server in python

Posting your actual .srv file would help, but I think you just have a bit of terminology issues. If you have two lines in your response section of the service definition, you would have two fields in the response message. For instance, if servicename.srv is:

int8 someRequestStuff
---
int8 firstThingToReturn
int8 secondThingToReturn

In this case, you could:

resp = servicenameResponse()
resp.firstThingToReturn = 1
resp.secondThingToReturn = 2
return resp
2011-07-19 05:14:35 -0500 marked best answer About response function in a server file.

You probably want something like:

def Receive(req):
#Motion= ALproxy("ALMotion")
    names = "HeadYaw"
    fractionMaxSpeed = 0.1
    useSensors  = True 
    HeadYaw = Motion.getAngles(names, useSensors)
    Motion.setAngles(names, req.HeadYawSet,fractionMaxSpeed)
    names = "HeadPitch"
    HeadPitch=Motion.getAngles(names, useSensors)
    Motion.setAngles(names, req.HeadPitchSet, fractionMaxSpeed)

    # new code 
    resp = headResponse()
    resp.HeadYaw= HeadYaw
    resp.HeadPitch= HeadPitch
    return resp

Assuming that your service is in a file called head.srv

Note that for headResponse to be defined you may also need to add a line like this towards the top of your source:

from your_pkg.srv import *
2011-07-11 09:26:46 -0500 answered a question About response function in a server file.

Thanks a lot! ;-)

2011-07-10 11:45:13 -0500 answered a question How to build ROS nodes with other libraries?

I guess you need to modify the CMakefile.txt to add more libs.

2011-07-10 09:34:14 -0500 asked a question response of a server in python

Hi, everybody,

I have a simple question. If I have more than 2 responses in the srv file. How Can I use them in python code. How to use the servicenameResponse() function?

Cheers,

Gauss

2011-07-10 08:26:10 -0500 asked a question About response function in a server file.

Hello everybody,

I am a newer to ROS. I defined a srv file:

float64 HeadYawSet
float64 HeadPitchSet
---
float64 HeadYaw
float64 HeadPitch

I am going to write a server to get the value from "HeadYawSet" and "HeadPitchSet" simultaneously acquire joint data to put them in HeadYaw and HeadPitch. And my code is below:

def Receive(req):
#Motion= ALproxy("ALMotion")
    names = "HeadYaw"
    fractionMaxSpeed = 0.1
    useSensors  = True 
    HeadYaw = Motion.getAngles(names, useSensors)
    Motion.setAngles(names, req.HeadYawSet,fractionMaxSpeed)
    names = "HeadPitch"
    HeadPitch=Motion.getAngles(names, useSensors)
    Motion.setAngles(names, req.HeadPitchSet, fractionMaxSpeed)
    req.HeadYaw= HeadYaw;
    req.HeadPitch= HeadPitch;
    #print "HeadYawSet:" %(req.HeadPitchSet)
    #return headResponse( [HeadYaw, HeadPitch] )

##ROS is responsible for communicating the sub-processes with naoqi, it reads any data from the robot and give them to all the sub ##processes and it gets all the data from sub-processes and send them to the robot. NAOQI---ROS---PROCESSES

def receive_server():
    rospy.init_node('head')
    s = rospy.Service('receiving_on_head', head, Receive)
    print "Ready to receive the head joint values"

    rospy.spin()

if __name__ == "__main__":
    receive_server()

it gave me strange errors when I run my client code in C++ Traceback (most recent call last): File "/opt/ros/diamondback/stacks/ros_comm/clients/rospy/src/rospy/impl/tcpros_service.py", line 600, in _handle_request response = convert_return_to_response(self.handler(request), self.response_class) File "head.py", line 34, in Receive req.HeadYaw= HeadYaw; AttributeError: 'headRequest' object has no attribute 'HeadYaw' [ERROR] [WallTime: 1310328838.362102] Error processing request: 'headRequest' object has no attribute 'HeadYaw' None

Can anybody help me a bit here? Thank you so much!