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

Elektrikeren's profile - activity

2020-05-04 08:02:49 -0500 commented question Turtlebot doesn't move in a straight line

We tried our program on another TurtleBot where it worked flawlessly. It was a school project, and they had plenty exces

2020-05-04 07:56:41 -0500 received badge  Student (source)
2017-11-21 07:39:13 -0500 received badge  Famous Question (source)
2017-03-29 04:04:14 -0500 received badge  Popular Question (source)
2017-03-29 04:04:14 -0500 received badge  Notable Question (source)
2017-01-11 09:43:07 -0500 received badge  Enthusiast
2017-01-09 15:09:45 -0500 asked a question Need help with ROS subscriber and publisher

I'm a little bit lost in the following code, about the ROS nodes on which is subscriber and which is the publisher:

So what I know is that minip(publisher) advertises /gui_goal topic to minip_gui(subscriber)

What about the /visualization_marker, who is the subscriber and who is the publisher?

Thanks in advance.

This is the code called "minip"

#include <ros/ros.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <fstream>
#include <visualization_msgs/Marker.h>
#include <tf/transform_listener.h>
#include <move_base_msgs/MoveBaseAction.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/simple_client_goal_state.h>
#include <std_msgs/Int8.h>

using namespace cv;

double colPosX[4]={0,0,0,0}, colPosY[4];
ros::Publisher vis_pub;
typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient;

void _send_goal(std_msgs::Int8 colSubbed)
{
MoveBaseClient ac("move_base", true);
while(!ac.waitForServer(ros::Duration(5.0))){ROS_INFO("Missing ROS nodes");}
move_base_msgs::MoveBaseGoal goal;
goal.target_pose.header.frame_id = "map";
goal.target_pose.header.stamp = ros::Time::now();
goal.target_pose.pose.position.x = colPosX[colSubbed.data];
goal.target_pose.pose.position.y = colPosY[colSubbed.data];
goal.target_pose.pose.orientation.w=1.0;
ROS_INFO("Sending goal");
while(true)
{
    ac.sendGoal(goal);
    ac.waitForResult();
    if(ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
    {
        ROS_INFO("Success");
        break;
    }
    else
    {
        ROS_INFO("Retrying");
        ros::Duration(0.5).sleep();
    }
}
}

void _publish_marker(int colCount_2, double origin_x_1, double origin_y_1)
{
double colBlue[4]={1, 0, 0.3, 0.2}, colGreen[4]={0, 0, 0.1, 1}, colRed[4]=        {0, 1, 0.6, 1};
visualization_msgs::Marker marker;
marker.ns = "minip";
marker.header.frame_id = "map";
marker.lifetime = ros::Duration();
marker.header.stamp = ros::Time::now();
marker.action = visualization_msgs::Marker::ADD;
marker.type = visualization_msgs::Marker::CYLINDER;
marker.scale.x = 0.1;
marker.scale.y = 0.1;
marker.scale.z = 0.001;
marker.color.a = 1.0;
marker.pose.orientation.x = 0;
marker.pose.orientation.y = 0;
marker.pose.orientation.z = 0;
marker.pose.orientation.w = 0;
marker.pose.position.z = 0;
marker.pose.position.x = origin_x_1;
marker.pose.position.y = origin_y_1;
marker.color.b = colBlue[colCount_2];
marker.color.g = colGreen[colCount_2];
marker.color.r = colRed[colCount_2];
marker.id = colCount_2;
vis_pub.publish(marker);
}

void _save_current_pos(int colCount_1)
{
tf::TransformListener listener;
double origin_x, origin_y;
while(true)
{
    tf::StampedTransform transform;
    try
    {
        listener.lookupTransform("/map","/base_link",ros::Time(0), transform);
        ROS_INFO("Got a transform! x = %f, y = %f",transform.getOrigin().x(),transform.getOrigin().y());
        origin_x = transform.getOrigin().x(), origin_y = transform.getOrigin().y();
        break;
    }
    catch (tf::TransformException ex){ROS_ERROR("Nope! %s", ex.what());}
}
_publish_marker(colCount_1, origin_x, origin_y);
colPosX[colCount_1]=origin_x, colPosY[colCount_1]=origin_y;
for(int checkArr=0; checkArr !=-1; checkArr++)
{
    if(colPosX[checkArr]==0){break;}
    if(checkArr==3)
    {
        ros::NodeHandle n;
        ros::Subscriber sub = n.subscribe("gui_goal", 1000, _send_goal);
        ros::spin();
    }
}
ros::Duration(0.5).sleep();
}

void _col_det ()
{
int arrBlue[4] ={245, 90, 200, 60}, arrGreen[4]={165, 30, 100, 150}, arrRed[4]={40, 160, 140, 155};
double percent[4];
VideoCapture cap;
if(!cap.open(1))
{
    ROS_INFO("Could not find camera");
    return;
}
while(true)
{
    for(int colCount=0; colCount<3; colCount++)
    {
        double pix_max=0;
        Mat frame;
        cap >> frame;
        if(frame.empty()){return;}
        for ...
(more)
2016-12-04 13:28:35 -0500 received badge  Popular Question (source)
2016-12-01 13:57:35 -0500 asked a question Implement sound in CMake

I am doing a project with color detection with OpenCV in which I would like to play a sound, when it detect the color it is specified to.

I have installed and "catkinized" the audio_common package and want to add

<depend package="sound_play"/> in my cmake project, but i am not sure how and where?

Any ideas on how i add the dependency?

Edit: When i try to 'make' in my project it outputs following:

sound_play/sound_play.h: No such file or directory

2016-12-01 07:32:44 -0500 asked a question Turtlebot doesn't move in a straight line

I have some C++ code in which i give the turtlebot a coordinate using:

goal.target_pose.pose.position.x = mypoint.point.x

goal.target_pose.pose.position.y = mypoint.point.y

The robot moves from one point to another. However only rarely does it do this in a straight line. It seems as though the turtlebot starts moving before it is done rotating. There are not any obstacles inbetween the points. It is able to get to every point, but it tends to move in small arc between them.

Any ideas on how to force the robot to move in a straight line, when there are no obstacles in its way?

I use turtlebot_bringup minimal.launch and turtlebot_navigation gmapping_demo.launch.