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

Borob's profile - activity

2021-12-06 12:55:32 -0500 received badge  Great Question (source)
2021-07-06 09:19:36 -0500 received badge  Favorite Question (source)
2021-03-11 13:09:53 -0500 marked best answer ConstPtr NULL with waitForMessage

Hello.

I have a function which is supposed to just get one message from a topic, the function looks like this:

std::vector<my_msgs::Person> getPersonList()
{   
    ros::NodeHandle n;
    ros::Duration four_seconds(4.0);

    my_msgs::PersonListConstPtr person_list = ros::topic::waitForMessage<my_msgs::PersonList>(
            "/my_world/persons_available",
            n, four_seconds);
    std::vector<my_msgs::Person> person_vector;
    person_vector = person_list->persons;
    return person_vector;
}

Whereas PersonList.msg is:

Person[] persons

And Person.msg something like:

string name
int age
...

Now when I call the function, the behavior is rather erratic. Sometimes I get the correct results for the first call(s) but after some time I get a Assertion 'px != 0' failed. Googling around told me that the shared_ptr PersonListConstPtr is NULL. And indeed when I do:

if(person_list != NULL)
        person_vector = person_list->persons;

My program is not crashing, but instead nothing happens, because apparently my pointer is always NULL.

Now, the topic is correct, it is published and everything. I have the suspicion that the original pointer is still active and that I can't get hold on it anymore after returning. Can someone help me what to do? I am not very familliar with those shared_ptr. I already tried to get() the pointer but got a segmentation fault.

2019-06-30 04:59:44 -0500 received badge  Good Question (source)
2019-02-04 22:49:09 -0500 marked best answer Robot model not showing in rviz

I am trying to work with this repository: https://github.com/udacity/RoboND-Kin...

I did all the initial steps that are mentioned in the repo but have troubles showing the robot urdf in rviz. Since the people over there can't help I hope that someone here can point me in the right direction.

When I just want to load the urdf in rviz like this (in individual shells):

roscore
rosrun rviz rviz
roslaunch kuka_arm load_urdf.launch

I just see the gripper. You can see this in the first photo attached.

The urdf to me looks fine and there are no errors anywhere.

When I run the whole demo, like this:

rosrun kuka_arm safe_spawner.sh

I can verify that the model is correctly loaded in gazebo as you can see in the second screenshot. I tried this on two computers, one in a VM, one natively and with integrated graphics and dedicated nvidia card.

Can anyone else please check the urdf and help me out in determining what the problem here is?

image description image description

2018-10-08 05:51:18 -0500 asked a question Robot code from theory to practice

Robot code from theory to practice Hi there, I have a more general question about robot software. There are probably RO

2018-08-08 01:40:12 -0500 marked best answer What are ROS projects to practice?

Hello, I am using ROS on and off on average every 6 months. To stay active however, I would like to do more projects in ROS and do more advanced stuff (since I always go back after a long break, I most often do rudimentary IPC things, not much with RVIZ, etc.).

So I wanted to know if you guys can recommend ROS projects that one can do to practice. Something like these projects of this upcoming course: https://www.udacity.com/course/roboti... But without grading and free. Basically I am looking for advanced tutorials beyond what the wiki offers or something like the Kaggle challenges for ROS.

I wouldn't even be opposed if you can refer me to a book that contains this. But I think all the ROS books around are either obsolete and/or very basic.

2018-07-01 23:30:00 -0500 marked best answer Publish to topic via launch file

Is it possible to publish to a topic with a custom message type from within a launch file?

In a launch-file I launch several robots from external packages which I want to register to my running platform as they are launched.

2018-04-27 14:09:44 -0500 marked best answer How to subscribe to a topic, while publishing to another

Hey guys,

I want to write a basic controller for a quadrotor. For a target_position it should take the current_position from a simulated quadrotor, calculate an error between the two and send the command to the quadrotor to go to the position.

The current position is a topic of type PoseStamped. (/ground_truth_to_tf/pose). The topic to control the velocity is of type Twist (/cmd_vel).

My idea was: I subscribe to the current_position, and if the error is bigger than some threshold, I correct the movement. So, in the callback of the current_position topic, I want to publish a newly corrected velocity.

But here is the problem: I only want to publish one message, but on every callback from my subscription. I can't however only send one message, so I am stuck.

The code would look something like this:

//Callback method of the current_position
void positionFeedback(const geometry_msgs::PoseStamped::ConstPtr &msg, geometry_msgs::Pose *target)
{   
    geometry_msgs::Pose current_pose = msg->pose;
    geometry_msgs::Point direction = calculatePositionError(current_pose, *target);

    float distance = std::sqrt(std::pow(direction.x, 2) + std::pow(direction.y, 2)  + std::pow(direction.z, 2));
    if (distance > POSITION_ACCURACY){
        flyToTarget(direction); //method that publishes the velocity to the topic /cmd_vel
    }
}

void flyToTarget(geometry_msgs::Point target_position){
    ros::NodeHandle steer;
    ros::Publisher helmsman = steer.advertise<geometry_msgs::Twist>("/cmd_vel", 1000);
    ros::Rate loop_rate(10);
    int count = 0;
    while (ros::ok())
    {
        geometry_msgs::Twist new_vel;
        float multiplier = 3;
        new_vel.linear.x = - target_position.x * multiplier;
        new_vel.linear.y = - target_position.y * multiplier;
        new_vel.linear.z = - target_position.z * multiplier;
        helmsman.publish(new_vel);
        ros::spinOnce();
        loop_rate.sleep();
        ++count;
    }
}

So my question is, how can I do this loop? I only use basic ros stuff, this can't be that hard?

//Edit:

To clarify:

I want to make the velocity of the quadrotor dependant on it's current position. (I want to scale the velocity with a function that smoothly lowers the velocity as the quadrotor approaches the target). So I thought about invoking the velocity-update on the callback of the position:

positionCallback1( calculateAndPublishNewVelocity(...) )
positionCallback2( calculateAndPublishNewVelocity(...) )
...
positionCallbackN( calculateAndPublishNewVelocity(...) ) // distance to target smaller than my POSITION_ACCURACY

But, when I do this for the first time, my publish call never terminates, so I am stuck with:

positionCallback1(calculateAndPublishNewVelocity(...) ...

My question is: How would this be done in general? Is my approach the right one? I don't know how to escape the publish part. As I understand it, it sends messages to the topic until it is terminated by the user or via shutdown. I essentially only want to send one message for everytime the callback of the current_position is received. Right now I get segmentation fault.

There is a 5 year old question on ros.answers on how to send only one message to a topic, but it seems that there is no straight forward approach to do this.

So, how would this be done?

2018-01-11 12:23:12 -0500 received badge  Famous Question (source)
2017-12-29 10:11:04 -0500 received badge  Famous Question (source)
2017-10-25 14:30:51 -0500 received badge  Nice Question (source)
2017-08-08 20:22:07 -0500 received badge  Famous Question (source)
2017-07-28 02:59:40 -0500 received badge  Famous Question (source)
2017-07-16 08:09:02 -0500 received badge  Notable Question (source)
2017-07-13 21:20:52 -0500 received badge  Popular Question (source)
2017-07-13 12:37:11 -0500 commented question Robot model not showing in rviz

I set up everything like it says in the readme on both. And it is not showing on either.

2017-07-13 12:10:22 -0500 asked a question Robot model not showing in rviz

Robot model not showing in rviz I am trying to work with this repository: https://github.com/udacity/RoboND-Kinematics-P

2017-07-06 09:54:02 -0500 edited question ROS installation with Intel Braswell CPU (udoo)?

ROS installation with Intel Braswell CPU (udoo)? Hello, I would like to use a fast single board computer for ROS and am

2017-07-06 07:02:41 -0500 edited question ROS installation with Intel Braswell CPU (udoo)?

ROS installation on udoo? Hello, I would like to use a fast single board computer for ROS and am very intrigued by udoo

2017-07-06 07:02:38 -0500 edited question ROS installation with Intel Braswell CPU (udoo)?

ROS installation on udoo? Hello, I would like to use a fast single board computer for ROS and am very intrigued by udoo

2017-07-06 05:30:50 -0500 asked a question ROS installation with Intel Braswell CPU (udoo)?

ROS installation on udoo? Hello, I would like to use a fast single board computer for ROS and am very intrigued by udoo