Ask Your Question

emreay's profile - activity

2019-12-31 03:26:23 -0600 received badge  Taxonomist
2019-12-07 17:07:55 -0600 marked best answer Problem Moving the Robot in Rviz

I have written a urdf file for my differential drive mobile robot an want to make it move on rviz. I'm doing the tutorials on the book "Learning ROS for Robotic Programming" and used the codes and examples there, modifying them for myself.

So here is the urdf code;

<robot name="AGV">
    <link name="base_link">
        <visual>
            <geometry>
                <box size="0.49 .82 .2"/>
            </geometry>
            <origin rpy="0 0 0" xyz="0 0 0.01"/>
            <material name="gray">
                <color rgba="0 0 0 0.6"/>
            </material>
        </visual>
    </link>

    <link name="wheel_1">
        <visual>
            <geometry>
                <cylinder length="0.05" radius="0.1"/>
            </geometry>
            <origin rpy="0 1.57079633 0" xyz="0.22 0 0"/>
            <material name="black">
                <color rgba="1 0 0 1"/>
            </material>
        </visual>
    </link>

    <link name="wheel_2">
        <visual>
            <geometry>
                <cylinder length="0.05" radius="0.1"/>
            </geometry>
            <origin rpy="0 1.57079633 0" xyz="-0.22 0 0"/>
            <material name="black"/>
        </visual>
    </link>

    <joint name="base_to_wheel1" type="continuous">
        <parent link="base_link"/>
        <child link="wheel_1"/>
        <origin xyz="0 0 0"/>
        <axis xyz="1 0 0"/>
    </joint>

    <joint name="base_to_wheel2" type="continuous">
        <parent link="base_link"/>
        <child link="wheel_2"/>     
        <origin xyz="0 0 0"/>
        <axis xyz="1 0 0"/>
    </joint>
  </robot>

This is the broadcaster code:

#include<string>
#include<ros/ros.h>
#include<tf/transform_broadcaster.h>

int main(int argc, char** argv) {
    ros::init(argc, argv, "tf_broadcaster");
    ros::NodeHandle n;
    tf::TransformBroadcaster broadcaster;
    ros::Rate loop_rate(30);
    double angle= 0;
    // message declarations
    geometry_msgs::TransformStamped odom_trans;
    odom_trans.header.frame_id = "odom";
    odom_trans.child_frame_id = "base_link";
    while (ros::ok()) {
        // (moving in a circle with radius 1)
        odom_trans.header.stamp = ros::Time::now();
        odom_trans.transform.translation.x = cos(angle);
        odom_trans.transform.translation.y = sin(angle);
        odom_trans.transform.translation.z = 0.0;
        odom_trans.transform.rotation = tf::createQuaternionMsgFromYaw(angle);
        //send transform
        broadcaster.sendTransform(odom_trans);
        loop_rate.sleep();
    }
    return 0;
}

I launch the urdf on rviz and the node, but I get the problem as; No transform from [wheel_1] to [/base_link] No transform from [wheel_2] to [/base_link]

I'm not very experienced on ROS and TF and couldn't figure out why there is no transform between two links, isn't urdf is for that?

2018-01-22 09:06:08 -0600 received badge  Enlightened (source)
2018-01-22 09:06:08 -0600 received badge  Good Answer (source)
2017-05-12 05:53:16 -0600 received badge  Famous Question (source)
2017-02-10 07:13:29 -0600 received badge  Famous Question (source)
2017-01-06 18:43:32 -0600 received badge  Notable Question (source)
2016-11-29 07:11:17 -0600 commented answer Node Specific Parameters in YAML

Thank you..

2016-11-29 01:10:55 -0600 received badge  Popular Question (source)
2016-11-28 10:37:10 -0600 asked a question Node Specific Parameters in YAML

Right now, for every node I am creating a yaml file and put all the parameters inside and call this file in the launch file under the corresponding node.

Is it possible to create only one yaml file where I can specify name tags for parameters? Something like;

Node name:

param1: 1.0
param2: 2.0

Node name2:

param1: 3.0
param2: 4.0
2016-11-18 13:20:15 -0600 received badge  Critic (source)
2015-09-10 09:37:31 -0600 received badge  Famous Question (source)
2015-06-02 11:45:18 -0600 received badge  Student (source)
2015-06-02 11:16:22 -0600 commented answer CMake Error for depending two custom packages

Teşekkürler :)

2015-06-02 09:08:21 -0600 received badge  Notable Question (source)
2015-06-02 06:24:16 -0600 received badge  Popular Question (source)
2015-06-02 06:19:17 -0600 commented question CMake Error for depending two custom packages

Thank you, I have revised my question and added CMake code of agv_msgs.

2015-06-01 07:45:31 -0600 asked a question CMake Error for depending two custom packages

I have created a package called agv_msgs. I want to make this package contain my custom messages. I have built it with no problems. After that I have created another packege called agv_teleop and while creating this package I indicated agv_msgs, std_msgs, roscpp and rospy as its dependencies. I have modified the CMake list but when I try to catkin_make them I get the following error;

CMake Error at /home/emreay/catkin_ws/devel/share/agv_msgs/cmake/agv_msgsConfig.cmake:141 (message):
  Project 'agv_teleop' tried to find library 'agv_msgs'.  The library is
  neither a target nor built/installed properly.  Did you compile project
  'agv_msgs'? Did you find_package() it before the subdirectory containing
  its code is included?
Call Stack (most recent call first):
  /opt/ros/groovy/share/catkin/cmake/catkinConfig.cmake:75 (find_package)
  agv_teleop/CMakeLists.txt:7 (find_package)


-- Configuring incomplete, errors occurred!
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed

I have done the catkin_make for agv_msgs before I create the agv_teleop package. I also included agv_teleop for find_package() in CMakeLists of agv_teleop. I cannot figure out what I was doing wrong.

My CMakeLists for agv_msgs;

cmake_minimum_required(VERSION 2.8.3)
project(agv_msgs)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  message_generation
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()

################################################
## Declare ROS messages, services and actions ##
################################################

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
##   your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
##   * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
##   * If MSG_DEP_SET isn't empty the following dependencies might have been
##     pulled in transitively but can be declared for certainty nonetheless:
##     * add a build_depend tag for "message_generation"
##     * add a run_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
##   * add "message_generation" and every package in MSG_DEP_SET to
##     find_package(catkin REQUIRED COMPONENTS ...)
##   * add "message_runtime" and every package in MSG_DEP_SET to
##     catkin_package(CATKIN_DEPENDS ...)
##   * uncomment the add_*_files sections below as needed
##     and list every .msg/.srv/.action file to be processed
##   * uncomment the generate_messages entry below
##   * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

## Generate messages in the 'msg' folder
 add_message_files(
   FILES
   uint8Array.msg
 )

## Generate services in the 'srv' folder
# add_service_files(
#   FILES
#   Service1.srv
#   Service2.srv
# )

## Generate actions in the 'action' folder
# add_action_files(
#   FILES
#   Action1.action
#   Action2.action
# )

## Generate added messages and services with any dependencies listed here
 generate_messages(
   DEPENDENCIES
   std_msgs
 )

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent ...
(more)
2015-04-29 04:45:22 -0600 received badge  Famous Question (source)
2015-04-25 13:49:31 -0600 received badge  Popular Question (source)
2015-04-25 13:49:31 -0600 received badge  Notable Question (source)
2015-02-28 10:19:45 -0600 received badge  Famous Question (source)
2015-01-26 09:38:50 -0600 asked a question Serial Communication with TI C2000

Hello,

I have a Texas Instruments C2000 type card (F28335) which I have programmed using Simulink. I will use it for motor controls on the mobile robot. I want to send velocity references to TI from its SCI-A port. So I will calculate the necessary velocity values for motors (or use navigation stack etc.) and I want to send these values from the USB of the laptop that the ros is running to the serial port of the card via an RS232-USB converter cable.

I don't want to use rosserial since I'm programming C2000 with simulink and can't use rosserial that way. Also I don't need to directly subscribe/publish on ROS environment. I just want to send simple data such as #100! and parse them on the microcontroller. How can I do that?

Thanks.

2015-01-14 00:17:49 -0600 received badge  Nice Answer (source)
2015-01-03 18:45:40 -0600 received badge  Teacher (source)
2015-01-02 04:20:13 -0600 received badge  Editor (source)
2015-01-02 04:15:23 -0600 answered a question Basic user interface, run nodes,

There is a package called node_manager_fkie for managing nodes, topics and so on with a GUI. You can use launch files as well as the buttons in the GUI to launch the nodes that are not running or crashed.

2015-01-01 12:34:02 -0600 received badge  Notable Question (source)
2014-12-31 17:09:44 -0600 answered a question ubuntu 14.10 and ros installation error help me

ROS Electric does not officially support -i.e. there is no pre-built for- Ubuntu 14.10 as can be seen in REP 3 - Target Platforms since it is released in 2011. You can install ROS Electric on Ubuntu 10.04/10.10/11.04/11.10.

Also please read FAQ.

2014-12-31 14:45:05 -0600 received badge  Popular Question (source)
2014-12-31 14:29:49 -0600 commented answer Right Angle Turn Problem

Thank you for your answer. But I see that your answer is about localization of real robot in real world, however I'm just trying to achieve this 'ideal' trajectory with a model in rviz so there are no wheel measurement errors and slipping. My problem is code originated.

2014-12-31 06:06:14 -0600 received badge  Autobiographer
2014-12-31 05:46:52 -0600 asked a question Right Angle Turn Problem

Hi,

I'm trying to move my urdf model on a rectangular/square trajectory in rviz. In order to do that I try to broadcast certain transforms within certain time intervals using a timer. But the robot cannot turn exact 90 degrees, instead it turns a bit less. The errors are summed and the trajectory becomes useless. What is the right way to do this ? Thanks.

My transform broadcaster node:

#include<string>
#include<ros/ros.h>  
#include<tf/transform_broadcaster.h>
#include<math.h>

class rectangularTrajectory
{
    public:
    rectangularTrajectory();
    ~rectangularTrajectory();
    void moveAgv(double vx, double vy, double wth);
    void setPrevTime(ros::Time now);
    int getState();

    private:
    void timerCallback(const ros::TimerEvent&);
    void broadcastTF(tf::TransformBroadcaster *tf_broadcaster,
                    std::string device_frame,
                    double x, double y, double z,
                    double theta);
    ros::NodeHandle nh_;
    ros::Timer timer;
    tf::TransformBroadcaster broadcaster;
    double x, y, th, vx, vy, wth, dt, delta_x, delta_y, delta_th;
    ros::Time current_time, prev_time, duration;
};

rectangularTrajectory::rectangularTrajectory()
{
    ROS_INFO("Calling the constructor of the class rectangularTrajectory");
    timer = nh_.createTimer(ros::Duration(1.0), &rectangularTrajectory::timerCallback, this);
    x = 0.0;
    y = 0.0;
    th = M_PI/2;
}

rectangularTrajectory::~rectangularTrajectory()
{
    ROS_INFO("Calling the deconstructor of the class rectangularTrajectory");
}

void rectangularTrajectory::broadcastTF(tf::TransformBroadcaster *tf_broadcaster,
                 std::string device_frame,
                 double x, double y, double z,
                 double theta)
{
    // broadcast Transform from vehicle to device
    geometry_msgs::TransformStamped odom_trans;
    odom_trans.header.stamp = ros::Time::now();
    odom_trans.header.frame_id = "odom";
    odom_trans.child_frame_id = device_frame;
    odom_trans.transform.translation.x = x;
    odom_trans.transform.translation.y = y;
    odom_trans.transform.translation.z = z;
    odom_trans.transform.rotation = tf::createQuaternionMsgFromYaw(theta);
    //broadcasting the transform
    tf_broadcaster->sendTransform(odom_trans);
}

void rectangularTrajectory::moveAgv(double vx, double vy, double wth)
{
    current_time = ros::Time::now(); //set current time
    dt = (current_time - prev_time).toSec(); //time differential
    delta_x = vx*cos(th)*dt; //change in x axis in world frame
    delta_y = vx*sin(th)*dt; //change in y axis in world frame
    delta_th = wth*dt; //change in the orientation
    x += delta_x;
    y += delta_y;
    th += delta_th;
    //broadcast transforms
    broadcastTF(&broadcaster,"base_link",x,y,0,th);
    broadcastTF(&broadcaster,"wheel_left",x,y,0,th);
    broadcastTF(&broadcaster,"wheel_right",x,y,0,th);
    //set previous time
    prev_time = current_time;
    ros::spinOnce();
}

void rectangularTrajectory::setPrevTime(ros::Time now)
{
    prev_time = now.now();
}

int rectangularTrajectory::getState()
{
    int state;  
    nh_.getParam("state",state);
    return state;
}

void rectangularTrajectory::timerCallback(const ros::TimerEvent&)
{
    int new_state;
    new_state = getState()+1;
    nh_.setParam("state",new_state);
    ROS_INFO("timer triggered, new state: %d",new_state);
}

//main function
int main(int argc, char** argv) 
{
    ros::init(argc, argv, "rectangular_tf"); //node initialize
    rectangularTrajectory rectangularTrajectory_;
    rectangularTrajectory_.setPrevTime(ros::Time::now());
    while (ros::ok())
    {
        ros::spinOnce();

        while((rectangularTrajectory_.getState())%2 == 0)
        {
            rectangularTrajectory_.moveAgv(4,0,0);
        }

        while((rectangularTrajectory_.getState())%2 == 1)
        {
            rectangularTrajectory_.moveAgv(0,0,M_PI/2);
        }

    }//end of while
    return 0;
}//end of main

My launch file:

<launch>
    <!-- RVIZ -->
    <node name="rviz" pkg="rviz" type="rviz" args="-d $(find agv)/urdf.rviz" />
    <arg name="gui" default="False" />
    <param name="robot_description" textfile="$(find agv)/urdf/agv_.urdf" />
    <param name="use_gui" value="$(arg gui)"/>
    <param name="state" value="0" type="int"/>
    <!-- ROBOT STATE PUBLISHER NODE -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
    <!-- RECTANGULAR TF ...
(more)
2014-12-26 07:20:56 -0600 received badge  Famous Question (source)
2014-12-25 10:08:56 -0600 answered a question Mobile Robot Teleoperation in Rviz

I have found the answers for most of my questions and now I'm able to do teleoperation. I am writing the answers in case someone else might the same problems.

So the answers;

  1. In the odometry transform broadcaster, my mistake was to only create transforms between /odom and /base_link. This was the reason why I the robot only moved around a circle of odom frame. I have fixed this.

  2. I still don't know why I only see /odom frame and no higher world frame.

  3. Joint_state.velocity[] acts as what we treated. It's just a variable. So in my case since the joints are continuous they should be taken as angular velocities.

  4. I didn't have a time differential so my usage was wrong. It is fixed by;

    while (ros::ok())
    {
    ros::spinOnce(); //check new messages
    current_time = ros::Time::now(); //set current time
    
    nh_.getParam("wLeft",wLeft); //get left wheel angular velocity value from parameter server
    nh_.getParam("wRight",wRight); //get right wheel angular velocity value from parameter server
    
    vLeft = wheelRadius*wLeft; //linear velocity of left wheel
    vRight = wheelRadius*wRight; //linear velocity of rigth wheel
    vx = (vRight+vLeft)/2; //linear velocity in ROBOT frame
    wth = (vRight-vLeft)/length; //angular velocity of the ROBOT
    dt = (current_time - prev_time).toSec(); //time differential
    delta_x = vx*cos(th)*dt; //change in x axis in world frame
    delta_y = vx*sin(th)*dt; //change in y axis in world frame
    delta_th = wth*dt; //change in the orientation
    
    x += delta_x;
    y += delta_y;
    th += delta_th;
        //broadcast transforms
        broadcastTF(&broadcaster,"base_link",x,y,0,th);
        broadcastTF(&broadcaster,"wheel_left",x,y,0,th);
        broadcastTF(&broadcaster,"wheel_right",x,y,0,th);
        //set previous time
    prev_time = current_time;
        //rest until loop rate is done
        loop_rate.sleep();}//end of while