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

tambel's profile - activity

2021-12-02 03:37:11 -0500 received badge  Famous Question (source)
2021-11-14 20:52:10 -0500 received badge  Famous Question (source)
2018-05-26 04:29:08 -0500 received badge  Famous Question (source)
2017-09-20 11:23:37 -0500 received badge  Famous Question (source)
2017-07-10 08:47:01 -0500 received badge  Notable Question (source)
2017-07-10 08:47:01 -0500 received badge  Popular Question (source)
2017-03-03 04:32:18 -0500 asked a question ActionServer not calling trancition callback on every goal result.

Hello. I am learning to work with "non-simple" action server/client. I used tutorial that calculates Fibonacci sequence in "actionlib_tutorials" pkg and changed SimpleActionServer to ActionServer(and client).

I tried to use servers goal callback only for receive goal, and do all work in thread. GoalHandles i am storing in some container to have access them from thread (is it correct?)

I sending goal from ActionClient and setting received goal to setAccepted and then to setSucceesed on ActionServer On client side i`m expecting transition callback calls with states in this order:

PENDING
ACTIVE
WAITING_FOR_RESULT
DONE

and its working fine until i sending many(3 in example) goals. ActionServer receives them and start thread for each. Now im expecting the same transitions order on client side but 3 times. But only one random goal reaches DONE state, another stuck on WAITING_FOR_RESULT

example:

PENDING
PENDING
PENDING
ACTIVE
ACTIVE
ACTIVE
WAITING_FOR_RESULT
WAITING_FOR_RESULT
WAITING_FOR_RESULT
DONE

I know that ActionServer and Client communicates with each other between topics. I changing goal states on server side without any delay and maybe its very quick for client subscriber and it looses some result messages? I used rqt topic monitor and created my own subscriber, but they are both receiving all 3 message. Why its stuck only on DONE and work fine on another states?

Where is the problem?

Thank You.

Here is the code:

Server

#include <ros/ros.h>
#include <actionlib/server/action_server.h>
#include <actionlib_tutorials/FibonacciAction.h>
#include <actionlib/server/server_goal_handle.h>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include <algorithm>

using namespace actionlib;
using namespace std;

typedef actionlib::ActionServer<actionlib_tutorials::FibonacciAction>::GoalHandle handle;
vector<handle> vh;
int i=0;
std::thread threads[2];


//real goal handling in this thread, just accepting, and set it succeeded.
void job(actionlib::ActionServer<actionlib_tutorials::FibonacciAction>::GoalHandle  goal)
{
    goal.setAccepted();
    goal.setSucceeded();
}

void GoalCB(actionlib::ActionServer<actionlib_tutorials::FibonacciAction>::GoalHandle goal)
{
    //only starting thread here
    int id=i;
    i++;
    vh.push_back(goal);
    threads[id]=thread(job,id,vh[id]);
    threads[id].detach();
}
int main(int argc, char** argv)
{
    ros::init(argc,argv,"s");
    ros::NodeHandle nh_;
    actionlib::ActionServer<actionlib_tutorials::FibonacciAction> as(nh_,"fibonacci",boost::bind(GoalCB,_1),false); 
    as.start();
    ros::spin();
}

Client:

#include <ros/ros.h>
#include <actionlib/client/action_client.h>
#include <actionlib_tutorials/FibonacciAction.h>    
#include <iostream>
using namespace actionlib;
using namespace actionlib_tutorials;
using namespace std;

void TranCB(actionlib::ActionClient<actionlib_tutorials::FibonacciAction>::GoalHandle  goal) 
{
    CommState cs=goal.getCommState();
    cout<<cs.toString()<<endl;  
}
void sub_cb(const actionlib_tutorials::FibonacciActionResultConstPtr& msg)
{
    msgs.push_back(msg);
}
int main(int argc, char** argv)
{
    ros::init(argc,argv,"c");   
    ros::NodeHandle nh_;
    actionlib::ActionClient<actionlib_tutorials::FibonacciAction> ac("fibonacci");
    ROS_INFO("Waiting for action server to start.");   
    ac.waitForActionServerToStart(ros::Duration(1, 0));
    ROS_INFO("Action server started, sending goal.");
    FibonacciGoal goal;
    actionlib::ActionClient<actionlib_tutorials::FibonacciAction>::GoalHandle gh, gh2, gh3;
    gh=ac.sendGoal(goal, boost::bind(TranCB,_1));//, &doneCb, &activeCb, &feedbackCb);
    cout<<"sended 1 goal"<<endl;
    gh2=ac.sendGoal(goal, boost::bind(TranCB,_1));//, &doneCb, &activeCb, &feedbackCb);
    cout<<"sended 2 goal"<<endl;
    gh3=ac.sendGoal(goal, boost::bind ...
(more)
2017-02-18 21:02:49 -0500 received badge  Notable Question (source)
2016-06-17 02:46:20 -0500 received badge  Famous Question (source)
2016-04-05 11:17:13 -0500 received badge  Notable Question (source)
2016-01-26 00:21:49 -0500 received badge  Notable Question (source)
2016-01-22 09:33:58 -0500 received badge  Popular Question (source)
2015-10-27 10:58:56 -0500 received badge  Taxonomist
2015-08-07 02:27:11 -0500 received badge  Enthusiast
2015-08-06 09:47:25 -0500 received badge  Organizer (source)
2015-08-06 09:46:14 -0500 asked a question Smooth JointTrajectory calculation

HI.I wrote simple adapter to my robot that listen topic with JointTrajectory messages, and motors drivers rotating motor angles by this messages.

First question: is JointTrajectory good option for this task?

All motor features hidden from me, and i cant control motor in low level layer, i just can set rotation angle. One of the features- limitation of instant angle rotation (for example: it cant move from 0 deg to 90deg instantly, because limit on 50deg and it stops on 50deg). That limitation implemented in low level layer of motor and i don't have access to it. Right way, i think, to rotate it smoothly, by small angle, and small time interval.

Second question: what can i use in ros, to calculate JointTrajectory with smooth joint rotation? I know i can calculate by myself, but i just want to know if some tool is exist.

Thank you.

2015-07-21 09:02:16 -0500 received badge  Popular Question (source)
2015-07-21 06:32:42 -0500 received badge  Citizen Patrol (source)
2015-07-21 04:33:57 -0500 received badge  Editor (source)
2015-07-21 04:33:35 -0500 asked a question Cant set Start State of robot in planning pane

Hello. I generated my robots moveit package with moveit_setup_assistant, but i cant set start state in planing pane in rviz. I just can set goal state, and when i click "Plan" button, it moves between "unknown" start state and goal state in infinite loop.

I have no idea what can be wrong.

Thank you for any help.

Thank You, gvdhoorn. It helped. But i have one more question, that i forgot to write above:

There is no reaction when i move effectors ball in rviz. I looked for right option in "Planning Request" this time, but didnt find anything about this.

2015-06-25 17:36:03 -0500 received badge  Popular Question (source)
2015-06-25 04:19:03 -0500 commented answer How to use Twist messages in robo-arm?

Thank you, it really helps!

2015-06-25 03:57:28 -0500 received badge  Notable Question (source)
2015-06-25 03:47:50 -0500 asked a question How to use Twist messages in robo-arm?

Hello. We have arm with servo joints,we are writing controller for it, and i don't know how correctly apply Twist messages,to control it.

Some questions:

1)If task is only to rotate angles of servos , i need only "angular" field of Twist?

2) If arm has 4 servos, i have to send 4 Twist for each of them? How should i do this? Arrays, separated topics or otherwise?

3) Twist not used for this tasks and this questions don't make sense.

I will be appreciate any advice. Thank you very much.

2015-05-18 04:11:56 -0500 received badge  Scholar (source)
2015-05-18 04:11:09 -0500 received badge  Supporter (source)
2015-05-17 21:54:18 -0500 received badge  Popular Question (source)
2015-05-16 04:18:34 -0500 asked a question recieve all data from tf message

listener.lookupTransform('/frame1', '/frame2', rospy.Time(0)) function works with 2 frames, so if i need to know all frames positions, relative to frame1, i have to call "lookupTransform" for each frame? Is that right way? I mean, if i have 10 frames, i should call lookupTransform 9 times, is this normal to performance?