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

maruchi's profile - activity

2021-10-21 07:51:10 -0500 received badge  Favorite Question (source)
2019-10-24 14:01:32 -0500 received badge  Nice Question (source)
2018-10-09 11:13:22 -0500 received badge  Nice Question (source)
2017-03-15 13:35:19 -0500 received badge  Nice Question (source)
2014-04-20 12:27:22 -0500 marked best answer how to get the starting simulation time from gazebo ?

Dear, I have a controller for a simple robot in gazebo. In my controller, I need to get the starting simulated time because there is lag between starting gazebo simulation and starting my controller. In my controller, I used this line (Init_time) to get the starting simulation time, but it always got out 0.

Init_time = ros::Time::now().toSec();

double time = odom->header.stamp.toSec();

2014-04-20 12:26:44 -0500 marked best answer how to add a subscriber in keyboard teleop ?

Hi, I have an incomplete C++ code which intends to add a subscriber to get state from robot model. Due to my limited knowledge, I can not proceed on the below code. What I want from this code is to get robot states ("base_pose_ground_truth":position and velocity) and put a simple proportional trajectory following controller for a desired trajectory (double desired_pos = 15 * sin(ros::Time::now().toSec());).

During compiling it, I have the error messages:

.../src/keyboard.cpp:113:17: error: cannot convert ‘ros::Subscriber’ to ‘double’ in assignment

.../src/keyboard.cpp:117:45: error: ‘max_force’ cannot be used as a function

.../src/keyboard.cpp:118:45: error: ‘max_force’ cannot be used as a function

----The below is the incomplete C++ code -------------------

#include <termios.h>
#include <signal.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/poll.h>

#include <boost/thread/thread.hpp>
#include <ros/ros.h>
#include <geometry_msgs/Wrench.h>
#include <nav_msgs/Odometry.h>


class ErraticKeyboardTeleopNode
{
    private:
        double thrust_;

        geometry_msgs::Wrench box_force_;
        nav_msgs::Odometry states_;
        ros::NodeHandle n_;
        ros::Publisher pub_;
        ros::Subscriber sub_;

    public:
        ErraticKeyboardTeleopNode()
        {
            pub_ = n_.advertise<geometry_msgs::Wrench>("box_force", 1);

            ros::NodeHandle n_private("~");
            n_private.param("thrust", thrust_, 30.0);
        }

        ~ErraticKeyboardTeleopNode() { }
        void keyboardLoop();

        void stopRobot()
        {
            box_force_.force.x = 0.0;
            box_force_.force.y = 0.0;
            box_force_.force.z = 0.0;
            pub_.publish(box_force_);
        }
};

ErraticKeyboardTeleopNode* tbk;
int kfd = 0;
struct termios cooked, raw;
bool done;

int main(int argc, char** argv)
{
    ros::init(argc,argv,"tbk", ros::init_options::AnonymousName | ros::init_options::NoSigintHandler);
    ErraticKeyboardTeleopNode tbk;

    boost::thread t = boost::thread(boost::bind(&ErraticKeyboardTeleopNode::keyboardLoop, &tbk));

    ros::spin();

    t.interrupt();
    t.join();
    tbk.stopRobot();
    tcsetattr(kfd, TCSANOW, &cooked);

    return(0);
}

void ErraticKeyboardTeleopNode::keyboardLoop()
{

    double max_force = thrust_;
    double current_pos;


    for(;;)
    {
        boost::this_thread::interruption_point();


        ros::Subscriber base_pose_sub_ = n_.subscribe<nav_msgs::Odometry> ("base_pose_ground_truth", 15, &ErraticKeyboardTeleopNode::keyboardLoop, this);

  double desired_pos = 15 * sin(ros::Time::now().toSec());
  current_pos = base_pose_sub_;
  max_force = -10 * (current_pos - desired_pos);


        box_force_.force.x = 1 * max_force(4);
        box_force_.force.y = 1 * max_force(5);
        box_force_.force.z = 0;
        pub_.publish(box_force_);
    }
}
2014-04-20 12:26:44 -0500 marked best answer how to get states (position and velocity) from the simple box robot ?

Hi, I have simple box robot model which is controlled by keyboard teleop in the gazebo environment. The next step I want to do is putting a simple feedback controller. The first thing I need to do is to get robot model states (position and velocity of center of gravity of the simple box robot model). And the next step I think is that the keyboard teleop should subscribe the states.

Are these procedures are right? If then, could you let me know how to get the robot model states ? Should I have put robot state publisher into robot urdf ? If there is appropriate link or tutorial, please let me know.

And if there is other way for me to do a feedback control for the simple box robot, please let me know.

2014-04-20 12:26:44 -0500 marked best answer how to put subscriber and publisher in one cpp file ?

Hi, I have a limited knowledge in C++ so that feel a difficulty in combining a subscriber and a publisher in one C++ file. Based on the tutorial, http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29 , could anybody give some directions on making one C++ file which includes a subscriber and a publisher ?

2014-04-20 12:26:31 -0500 marked best answer How to modify or change C++ file located in the ROS stack

I have the following error message:

/home/username/ros_workspace/my_controller_pkg/src/my_controller_file.cpp:52: error: ‘class pr2_mechanism_model::JointState’ has no member named ‘position_1’

/home/username/ros_workspace/my_controller_pkg/src/my_controller_file.cpp:53: error: ‘class pr2_mechanism_model::JointState’ has no member named ‘position_2’

I think it mean I have to delare "position_1" and "position_2" in the "joint.h" file, but this header file belongs to ROS stack so that it will not be changed. Is anybody who know how to modify the C++ header file belonged to ROS stack?

2014-04-20 12:26:16 -0500 marked best answer Simple URDF-Controller Example

Hi, I have been trying to figure it out "Simple URDF-Controller Example" in the following link, http://www.ros.org/wiki/pr2_mechanism/Tutorials/SImple%20URDF-Controller%20Example. If there is anyone who know the details to follow the above example, could you let me know it? I followed all the required recommendation, but could not complete the tutorial.

Before describing what problems I have in following the "Simple URDF-Controller Example", I want to say that my overall goal is that making robot model, putting state feedback controller, and simulating using ROS. Eventually the final goal will be implementing on Gumstix.

About following the above tutorial, "Simple URDF-Controller Example", I followed the recommended tutorial, "Writing a realtime joint controller", which is on the link, http://www.ros.org/wiki/pr2_mechanism/Tutorials/Writing%20a%20realtime%20joint%20controller . I have no problem in this tutorial. Based on this tutorial, to follow the tutorials of "Simple URDF-Controller Example", the procedures I have taken are:

$ roscreate-pkg my_controller_pkg pr2_controller_interface pr2_mechanism_model pluginlib $ roscd my_controller_pkg $ rosmake And I put robot.xml (which is in the also create a directory src and a file called src/my_controller_file.cpp ) inside the new package and create the directory include, then include/my_controller_pkg/my_controller_file.h, where this .h file is in "Writing a realtime joint controller". And also create a directory src and a file called src/my_controller_file.cpp, where this .cpp file is made according to "Simple URDF-Controller Example" and "Writing a realtime joint controller". And Open the CMakeLists.txt file, and add the following line on the bottom: rosbuild_add_library(my_controller_lib src/my_controller_file.cpp) and $ make

Then the following error messages are shown:

/home/username/ros_workspace/my_controller_pkg/src/my_controller_file.cpp: In member function ‘virtual bool my_controller_ns::MyControllerClass::init(pr2_mechanism_model::RobotState*, ros::NodeHandle&)’: /home/username/ros_workspace/my_controller_pkg/src/my_controller_file.cpp:22: error: ‘wheel1_state’ was not declared in this scope

/home/username/ros_workspace/my_controller_pkg/src/my_controller_file.cpp:38: error: ‘wheel2_state’ was not declared in this scope

/home/username/ros_workspace/my_controller_pkg/src/my_controller_file.cpp:50: error: a function-definition is not allowed here before ‘{’ token

/home/username/ros_workspace/my_controller_pkg/src/my_controller_file.cpp:57: error: a function-definition is not allowed here before ‘{’ token

/home/username/ros_workspace/my_controller_pkg/src/my_controller_file.cpp:66: error: a function-definition is not allowed here before ‘{’ token

/home/username/ros_workspace/my_controller_pkg/src/my_controller_file.cpp: At global scope:

/home/username/ros_workspace/my_controller_pkg/src/my_controller_file.cpp:67: error: expected ‘}’ at end of input

make[3]: * [CMakeFiles/my_controller_lib.dir/src/my_controller_file.o] Error 1

make[3]: Leaving directory `/home/username/ros_workspace/my_controller_pkg/build'

make[2]: * [CMakeFiles/my_controller_lib.dir/all] Error 2

make[2]: Leaving directory `/home/username/ros_workspace/my_controller_pkg/build'

make[1]: * [all] Error 2

make[1]: Leaving directory `/home/username/ros_workspace/my_controller_pkg/build'

make: * [all] Error 2

That is why I can not proceed on the tutorial, "Simple URDF-Controller Example".

Here is my_controller_file.cpp: include "my_controller_pkg/my_controller_file.h" include <pluginlib class_list_macros.h="">

namespace my_controller_ns {

/// Controller initialization in non-realtime bool MyControllerClass::init(pr2_mechanism_model::RobotState *robot, ros::NodeHandle &n) { std::string wheel1, wheel2;

///Link all Joints //////////////////////////////////////////////////////////////////////// if (!n ... (more)

2014-04-20 06:50:52 -0500 marked best answer tf tutorial warning message

Hi,

I am trying to follow this tutorial, but I got the following messages:

Traceback (most recent call last):
  File "/opt/ros/electric/stacks/geometry_tutorials/turtle_tf/nodes/turtle_tf_listener.py", line 57, in <module>
    (trans,rot) = listener.lookupTransform('/turtle2', '/turtle1', rospy.Time())
tf.ExtrapolationException: Lookup would require extrapolation at time 1333037934.805088997, but only time 1333037934.805421114 is in the buffer, when looking up transform from frame [/turtle1] to frame [/turtle2]
[turtle_pointer-6] process has died [pid 3789, exit code 1].
log files: /home/user/.ros/log/e0b84f1e-79ba-11e1-87ee-0023aea58509/turtle_pointer-6*.log

Could anyone resolve this problem?

My system info: Ubuntu 11.04, ROS electric

2014-04-20 06:50:10 -0500 marked best answer Difference between <dynamics damping="0.7" friction="100.0" /> and <mu1>1</mu1>

Hi,

Could anyone give me some explanation the difference between dynamics damping, and mu1, mu2 in the urdf ?

As I understand it, mu1 and mu2 are tangential friction forces applied between body and surface, so that the tangential friction force applied to the body as the body weight when mu=1.

<dynamics damping="0.7" friction="100.0"/> is the damping force which is proportional to the velocity of the moving body.

What should I do in the urdf to applying the damping force which is proportional to the velocity in the simple sliding box? Below is the sliding box urdf code:

<robot name="sliding_box"
       xmlns:body="http://playerstage.sourceforge.net/gazebo/xmlschema/#body"
       xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
       xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" >

  <link name="base_link">
    <inertial>
      <mass value="1"/>
      <origin xyz="0 0 0"/>
      <inertia ixx="0.05" ixy="0" ixz="0" iyy="0.05" iyz="0" izz="0.05"/>
    </inertial>
    <visual>
      <origin rpy="0 0 0" xyz="0 0 0.0"/>
      <geometry>
        <box size="1.0 1.0 1.0"/>
      </geometry>
    </visual>
    <collision>
      <origin rpy="0 0 0" xyz="0 0 0.0"/>
      <geometry>
        <box size="1.0 1.0 1.0"/>
      </geometry>
    </collision>
  </link>

  <gazebo reference="base_link">
    <mu1>0</mu1>
    <mu2>0</mu2>
    <fdir1 value = "1 0 0"/>
 <dynamics damping="0.7" friction="100.0" />
    <material>Gazebo/Black</material>
    <turnGravityOff>false</turnGravityOff>
  </gazebo>

  <gazebo>
        <controller:gazebo_ros_force name="box_force_controller" plugin="libgazebo_ros_force.so">
         <alwaysOn>true</alwaysOn>
         <updateRate>15.0</updateRate>
         <topicName>box_force</topicName>
         <bodyName>base_link</bodyName>
        </controller:gazebo_ros_force>
  <controller:gazebo_ros_p3d name="p3d_base_controller" plugin="libgazebo_ros_p3d.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>15.0</updateRate>
    <bodyName>base_link</bodyName>
    <topicName>base_pose_ground_truth</topicName>
    <gaussianNoise>0</gaussianNoise>
    <frameName>map</frameName>
    <xyzOffsets>0 0 0</xyzOffsets> 
    <rpyOffsets>0 0 0</rpyOffsets>
    <interface:position name="p3d_base_position"/>
  </controller:gazebo_ros_p3d>
  </gazebo>

</robot>
2014-04-20 06:49:57 -0500 marked best answer best practice for multi robot simulation

Hi,

Could anybody let me know what is the best practice for multi-robot simulation in ROS ? I want to simulate both an aerial vehicle and a ground vehicle in gazebo, and control them for the missions such as path-following and tracking objects.

2014-04-20 06:49:56 -0500 marked best answer error message when running "Quadrotor indoor SLAM demo"

Hi,

When I tried to run the quadrotor demo here , I got the following error message:

[ERROR] [1332786035.950907356, 0.255000000]: Trajectory Server: Transform from /map to /base_link failed: Frame id /map does not exist! Frames (6): Frame /front_cam_link exists with parent /base_link.
Frame /base_link exists with parent NO_PARENT.
Frame /front_cam_optical_frame exists with parent /front_cam_link.
Frame /laser0_frame exists with parent /base_link.
Frame /sonar_link exists with parent /base_link.


[ERROR] [1332786036.383930902, 0.503000000]: Trajectory Server: Transform from /map to /base_link failed: Frame id /map does not exist! Frames (9): Frame /front_cam_link exists with parent /base_link.
Frame /base_link exists with parent /base_stabilized.
Frame /front_cam_optical_frame exists with parent /front_cam_link.
Frame /laser0_frame exists with parent /base_link.
Frame /sonar_link exists with parent /base_link.
Frame /base_footprint exists with parent /nav.
Frame /nav exists with parent NO_PARENT.
Frame /base_stabilized exists with parent /base_footprint.


[ INFO] [1332786036.541020052, 0.555000000]: lookupTransform base_footprint to /laser0_frame timed out. Could not transform laser scan into base_frame.
[rviz-9] process has died [pid 3011, exit code -11]. log files: /home/user/.ros/log/5e1b3464-7770-11e1-8b32-0023aea58509/rviz-9*.log


[ERROR] [1332786036.869724780, 0.750000000]: Trajectory Server: Transform from /map to /base_link failed: Frame id /map does not exist! Frames (9): Frame /front_cam_link exists with parent /base_link.
    Frame /base_link exists with parent /base_stabilized.
    Frame /front_cam_optical_frame exists with parent /front_cam_link.
    Frame /laser0_frame exists with parent /base_link.
    Frame /sonar_link exists with parent /base_link.
    Frame /base_footprint exists with parent /nav.
    Frame /nav exists with parent NO_PARENT.
    Frame /base_stabilized exists with parent /base_footprint.


    [ERROR] [1332786037.258785570, 1.004000000]: Trajectory Server: Transform from /map to /base_link failed: Frame id /map does not exist! Frames (9): Frame /front_cam_link exists with parent /base_link.
    Frame /base_link exists with parent /base_stabilized.
    Frame /front_cam_optical_frame exists with parent /front_cam_link.
    Frame /laser0_frame exists with parent /base_link.
    Frame /sonar_link exists with parent /base_link.
    Frame /base_footprint exists with parent /nav.
    Frame /nav exists with parent NO_PARENT.
    Frame /base_stabilized exists with parent /base_footprint.


    [ERROR] [1332786037.356971730, 1.055000000]: Transform failed during publishing of map_odom transform: Unable to lookup transform, cache is empty, when looking up transform from frame [/base_footprint] to frame [/nav]

Could anybody let me know how to resolve the error message ?

Thanks~

2014-04-20 06:48:55 -0500 marked best answer differences in simulation from gazebo and Matlab

Dear,
I have a simple urdf model and have tried to control the model using some nonlinear controller. To verify the controller, I tested it in Matlab simulation. The designed controller worked well in the Matlab environment, but the c++ coded controller has not worked in gazebo. So I made open loop test both in ROS and Matlab, for example, applied unit force and moment to the model and checked the outputs of positions and velocities. The values from the gazebo simulation is far smaller than those from Matlab. What should I modify or check in gazebo simulation ? I checked mass properties, put viscous damping (modeled using feedback velocity), used the time from ros::Time::now().toSec().

Is this problem related to time in gazebo?

2014-04-20 06:48:47 -0500 marked best answer how to mark the prescribed trajectory in gazebo simulation ?

Dear,

I was able to make my simple model follow the prescribed position trajectory (circle or infinity shape or any smooth trajectory) in gazebo simulation. One more thing I want to do to show the prescribed trajectory in the gazebo simulation so that I want to show how closely my model follows the given trajectory. What part should I modify or edit ? Do I need to see the world file or look for different world file?

2014-04-20 06:48:45 -0500 marked best answer how to measure an angle?

Dear,

I want to measure yaw angle (radian). What command should I use ? In my c++ file, I used like this;

  double q0 = odom->pose.pose.orientation.w;
  double q1 = odom->pose.pose.orientation.x;
  double q2 = odom->pose.pose.orientation.y;
  double q3 = odom->pose.pose.orientation.z;
  double omega = odom->twist.twist.angular.z;
  double psi = atan2(2*(q0*q3+q1*q2),1-2*(q2*q2+q3*q3));

This yaw angle produce only between -pi and pi. But I want to measure directly the yaw angle in radian without the limitation of -pi and +pi, that is, measure the counter-clockwise one and half circling as +3 pi and the clockwise two circling as -4*pi.

One alternative can be coded this way:

  double omega = odom->twist.twist.angular.z;
  double delta_psi = omega*dt;
  psi += delta_psi;

But the heading angle psi might accumulate some integration error. Do I have to implement more accurate integration method ?