I'm trying to create some sort of base_controller for my motors in C++. I have two question about topics that I cannot answer for now.
First, if I read a message on the cmd_vel topic for example using a subscriber does the message I just read "disappeared" from the topic. Meaning if another Node try to read it, is the previously read message "gone" ?
Second, depending on the answer to the first question, how can I know if their is a steady stream of command coming from the cmd_vel topic ? Meaning if the message is erased when I read it how can I know that it was not 'outdated" or when to stop ?
If it is not erase by reading but rather by if their more new information, how can two node send data on the same topic ?
To try to be clearer here is a situation example :
Let's say I publish a Twist for my robot to go forward on the cmd_vel for 3 second and I publish no stop Twist after those 3 seconds.
- What is my subscriber to this topic going to read during the 3 first second and after ?
- Same question but what if my subscriber is a little bit slow and start reading 1 second after I start publishing the twists ?
Thanks a lot.
↧
Question on topic publication
↧
ROS Gazebo reset_simulation or reset_world breaks commands sent to cmd_vel
Hi,
I am currently using the tum simulator (which build upon the gazebo simulator) on ROS Fuerte . I want to run algorithms on the simulator, and in order to do that I need to reset the simulation every now and then. However, when I call /gazebo/reset_simulation or /gazebo/reset_world, it breaks something:
The quadrotor will reset to its original position, but then commands sent to /cmd_vel are ignored. (Even commands sent to takeoff or land topics). If the quadrotor is not moving (on ground) before I call /gazebo/reset_simulation. The quadrotor will reset to its original position, and stays on the ground (takeoff command does nothing, even with using a ps3 controller, pressing L1 does nothing). If the quadrotor is flying before the /gazebo/reset_simulation is called, the quadrotor will reset to its original position and flies off randomly. When I echo the cmd_vel topic, the command velocities are still being published, and gazebo still subscribes to cmd/vel. Can someone explain why this happens?
Are there any other ways to reset the simulator?
I have also tried using the service /gazebo/set_model_state, but then the quadrotor just bounces off from the origin.
Thanx,
Kind Regards.
↧
↧
Independently change angular and linear velocities (cmd_vel)
Hi people!
This is really an easy question for the experts:
I am coding some *roslisp/cram* functions where I would like to change **independently** the angular and linear velocity of my robot in parallel threads. I first used the usual way of publishing the velocity in *roslisp* `roslisp:advertise "/cmd_vel" "geometry_msgs/Twist"` but then I realised that when publishing an angular velocity `(roslisp:publish-msg (roslisp:advertise "/cmd_vel" "geometry_msgs/Twist) pub (z angular))` I would **reset the linear speed to zero** and the converse when publishing a linear speed.
**Is there any [easy] way to modify the angular and linear velocity of the robot independently from one another in simultaneous processes?**
The only solution I have is any time I want to modify only one component of the velocity is to read the current velocity and publish the values of the changed component together with the values that are not change. That is not ideal as with parallel threads changing simultaneously the same topic I might have problems.
Hey, thanks a lot.
↧
Topic not being created properly
Hello, I am using ROS groovy and I have created a .cpp file that is suppose to use the command_velocity topic in conjunction with ros turtlesim to move the simulated turtlebot in a direction, When I compiled my code everything went fine with catkin_make. Now that I run my code though it seems like the command_velocity topic is not being created or anything is being published at all.
#include
#include
int main(int argc, char **argv){
ros::init(argc, argv, "move");
ros::NodeHandle n;
ros::Publisher move_bot = n.advertise("cmd_vel_mux/input/teleop",1);
geometry_msgs::Twist vel;
vel.angular.z = 1.5;
vel.linear.x = 1.5;
move_bot.publish(vel);
ros::spin();
return 0;
}
I am not sure what the problem is and I am fairly new to ROS programming any insight would be appreciated, thank you.
↧
Creating a teleop node/cmd_vel publisher
I'm trying to piece all of this together and have a couple questions. I am building a robot "Inga" who will run a pair of pittman motors through an Arduino Mega ADK with an Adafruit motor controller shield and a Robogaia encoder shield, ROS Hydro on 64 bit Toshiba Satellite running Ubuntu Precise. I'm getting comfortable with ROS but still at the shallow end of the learning curve. I know just enough C++ to not entirely helpless, am pretty good with python. I'm choosing to write most of my stuff in C++ to help me in my learning there. My ultimate goal is to employ the Nav stack using a Kinect and an XV-11 Lidar, plus some infrareds and sonars. In the process of learning how to do all of this I'm starting with just being able to move the bot around using a ps2 joystick and then build up to the Nav stack from there as my knowledge and time allows. I've read the appropriate tutorials for joy including creating a teleop node as well as all the Nav stack tutorials and ROS by Example.
Here's what I think I know:
1) I need to write code for the Arduino that subscribes to gemoetry/Twist msgs to get cmd_vel and that publishes the encoder data. This is almost done.
2) I need to create a base controller that subscribes to the joystick and publishes the cmd_vel messages the Arduino will read. This is what I'm working on now.
In order to create (2) I've copied the "Creating a Simple teleop node" code from [here] (http://wiki.ros.org/joy/Tutorials/WritingTeleopNode), renamed it inga_joy.cpp and modified it as follows:
#include
#include
#include
class TeleopInga
{
public:
TeleopInga();
private:
void joyCallback(const sensor_msgs::Joy::ConstPtr& joy);
ros::NodeHandle nh_;
int linear_, angular_;
double l_scale_, a_scale_;
ros::Publisher vel_pub_;
ros::Subscriber joy_sub_;
};
TeleopInga::TeleopInga():
linear_(1),
angular_(2)
{
nh_.param("axis_linear", linear_, linear_);
nh_.param("axis_angular", angular_, angular_);
nh_.param("scale_angular", a_scale_, a_scale_);
nh_.param("scale_linear", l_scale_, l_scale_);
vel_pub_ = nh_.advertise("inga/command_velocity", 1);
joy_sub_ = nh_.subscribe("joy", 10, &TeleopInga::joyCallback, this);
}
void TeleopInga::joyCallback(const sensor_msgs::Joy::ConstPtr& joy)
{
turtlesim::Velocity vel;
vel.angular = a_scale_*joy->axes[angular_];
vel.linear = l_scale_*joy->axes[linear_];
vel_pub_.publish(vel);
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "teleop_inga");
TeleopInga teleop_inga;
ros::spin();
}
Essentially what I've done so far is create a pkg in catkin_ws/src named inga_teleop with dependencies joy roscpp rospy and std_msgs
THE QUESTIONS:
1. On line 2: #include - since I'm not using turtlesim, where do I get the header to include for Velocity.h?
2. On line 44: turtlesim::Velocity vel; - this will just be the package that I include for Velocity.h ?
3. I see that I'm using sensor msgs, should I have included them in my initial package, or are these part of std_msgs?
4. Once I'm done, does this get included in my launch file (I think I know it does) and how?
↧
↧
turtlebot is not moving with published messages on cmd_vel
Hello, I have a simple turtle_move.cpp file that is suppose to make the turtlebot move in a square. The turtlesim program moves like its suppose to fine with my source code. I am using ROS groovy and a turtlebot 2.
#include
#include
int main(int argc, char **argv) {
// Initialize the ROS system and become a node.
ros::init(argc, argv, "turtle_move");
ros::NodeHandle nh;
// Create a publisher object.
ros::Publisher pub = nh.advertise(
"cmd_vel", 1);
// Seed the random number generator.
// Loop at 2Hz until the node is shut down.
ros::Rate rate(.5);
// Create and fill in the message.
geometry_msgs::Twist vel;
vel.angular.z = 0.0;
vel.linear.x = 0.0;
do{
// Publish the message.
pub.publish(vel);
rate.sleep();
vel.angular.z = 0.0;
vel.linear.x = 5.0;
ROS_INFO_STREAM("Sending random velocity command:"
<< " linear=" << vel.linear.x<< " angular=" << vel.angular.z);
pub.publish(vel);
rate.sleep();
vel.angular.z = (float)1.5708;
vel.linear.x = 0.0;
// Send a message to rosout with the details.
ROS_INFO_STREAM("Sending random velocity command:"<< " linear=" << vel.linear.x<< " angular=" << vel.angular.z);
// Wait until it's time for another iteration.
rate.sleep();
}while(ros::ok());
}
The turtlebot is suppose to follow a square path. I have verified that my turtlebot is on and functional by running the turtlebot_teleop program first and everything was running fine. But when I try to run my program to make the turltebot follow a square it doesn't work. I have made sure that all my dependencies are accurate, my CMakeLists.txt includes an executable turtle_move.cpp file that runs just like I ran my code for the turtlesim which is working.
I noticed that a launch file exists does anyone know if this might be the reason my code is not controlling the turtlebot.
Thank you.
↧
holding a twist message on cmd_vel node
Hi again,
I have come up with some code that allows for a turtlebot 2, to go in a straight path for 5 seconds. My problem is that it sends the velocity command for a split fraction of time, Im not sure what it is. I am looking for a way to hold a published command on a topic for a period of time. What is the easiest way to hold a command on a topic for a certain period of time?
I guess I'm looking for some command that is like;
ros::topic.hold(time);
#include
#include
#include
#include
using namespace std;
int main(int argc, char** argv){
ros::init(argc, argv, "gs_now");
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise(
"/cmd_vel_mux/input/navi", 1);
ros::Rate rate(1);
geometry_msgs::Twist vel;
vel.angular.z = 0.0;
vel.linear.x = 0.1;
clock_t t, l;
t = clock();
while(ros::ok()){
l = clock() - t;
if( ((double)l / ((double)CLOCKS_PER_SEC)) == 1.000){
pub.publish(vel);
ROS_INFO_STREAM("Sending random velocity command:"<< " linear=" << vel.linear.x<< " angular=" << vel.angular.z<< " at time =" << ((double)l / ((double)CLOCKS_PER_SEC)));
}
else if(((double)l / ((double)CLOCKS_PER_SEC)) == 2.000){
pub.publish(vel);
ROS_INFO_STREAM("Sending random velocity command:"<< " linear=" << vel.linear.x<< " angular=" << vel.angular.z<< " at time =" << ((double)l / ((double)CLOCKS_PER_SEC)));
}
else if(((double)l / ((double)CLOCKS_PER_SEC)) == 3.000){
pub.publish(vel);
ROS_INFO_STREAM("Sending random velocity command:"<< " linear=" << vel.linear.x<< " angular=" << vel.angular.z<< " at time =" << ((double)l / ((double)CLOCKS_PER_SEC)));
}
else if(((double)l / ((double)CLOCKS_PER_SEC)) == 4.000){
pub.publish(vel);
ROS_INFO_STREAM("Sending random velocity command:"<< " linear=" << vel.linear.x<< " angular=" << vel.angular.z<< " at time =" << ((double)l / ((double)CLOCKS_PER_SEC)));
}
else if(((double)l / ((double)CLOCKS_PER_SEC)) == 5.000){
ros::shutdown();
}
//rate.sleep();
}
}
Thank you.
↧
How to increase speed of passing velocity commands to p3dx
Hi all,
I am working on a project that requires me to send velocity commands to p3dx robot at a high speed. At the moment the robot takes a while (about 0.2s-0.3s) to change to a new speed once the command is given. Could you suggest any way in which I can increase this speed.
I am using "ROSARIA" to connect to the robot and subscribing via "cmd_vel". The robot is connected to the PC using an USB to RS422 converter.
Any suggestions will be appreciated. Thanks in advance
↧
Pioneer P3-AT Doesn't Move - ROSARIA
I have a concern regarding getting the Pioneer P3-AT to move. I have rosaria successfully installed, and I'm running on GROOVY. I run roscore in one terminal. Then I start rosaria in a second terminal and I receive the following:
viki@ROS:~/catkin_ws$ rosrun rosaria RosAria _port:=/dev/ttyS0
'[ INFO] [1404333851.509725930]: RosAria: using port: [/dev/ttyS0]
Could not connect to simulator, connecting to robot through serial port /dev/ttyS0.
Syncing 0
Syncing 1
Syncing 2
Connected to robot.
Name: PSU_3773
Type: Pioneer
Subtype: p3at-sh
Using default parameters for a p3at-sh robot
ArRobotConnector: Connecting to MTX batteries (if neccesary)...
ArRobotConnector: Connecting to MTX sonar (if neccesary)...
'[ INFO] [1404333852.481173839]: Setting TicksMM from ROS Parameter: 138
'[ INFO] [1404333852.493839324]: Setting DriftFactor from ROS Parameter: 0
'[ INFO] [1404333852.506890756]: Setting RevCount from ROS Parameter: 32550
'[ INFO] [1404333852.687692264]: RosAria: publishing new recharge state 0.
'[ INFO] [1404333852.690871777]: RosAria: publishing new motors state 0.
'[ INFO] [1404333854.139017779]: RosAria: publishing new motors state 1.
This is my issue,I am attempting to move the robot. I have tried the following command
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.1, y: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}'
no errors are displayed, but the robot doesn't move.
I then saw a similar post with a different model pioneer so I followed one of the suggestions and removed the readParameters() function from RosAria.cpp and received the following when I ran RosAria again:
viki@ROS:~/catkin_ws$ rosrun rosaria RosAria _port:=/dev/ttyS0
'[ INFO] [1404405147.590012597]: RosAria: using port: [/dev/ttyS0]
Could not connect to simulator, connecting to robot through serial port /dev/ttyS0.
Syncing 0
Syncing 1
Syncing 2
Connected to robot.
Name: PSU_3773
Type: Pioneer
Subtype: p3at-sh
Using default parameters for a p3at-sh robot
ArRobotConnector: Connecting to MTX batteries (if neccesary)...
ArRobotConnector: Connecting to MTX sonar (if neccesary)...
'[ INFO] [1404405148.654086464]: Setting TicksMM from Dynamic Reconfigure: 0 -> 138
'[ INFO] [1404405148.656896634]: Setting RevCount from Dynamic Reconfigure: 0 -> 32550
'[ INFO] [1404405148.723689412]: RosAria: publishing new recharge state 0.
'[ INFO] [1404405148.732294984]: RosAria: publishing new motors state 0.
'[ INFO] [1404405150.196582428]: RosAria: publishing new motors state 1.
I then tried to run the above rostopic command again a but again did not work.
I have also written a program that is intended to move the robot as well. That program compiles fine and runs, but again the robot doesn't move, with and without the readParameters() function. Do I have any calibration settings are not properly set? Any guidance would be greatly appreciated.
↧
↧
Make sure geometry_msgs::Twist or cmd_vel units
Hi all,
I have confusion about the unit of geometry_msgs::Twist, are they m/s and rad/s? Because I saw the sample code turltebot teleop as well as kobuki teleop, they setup these parameters equal 1.0 for each press button. However I checked the specification of the turtlebot kobuki in this [link](http://kobuki.yujinrobot.com/home-en/about/specifications/) , the maximum of linear velocity is just 70 cm/s, if my above opinion is right, the setup parameters in sample code is 100cm/s, it is overload the motor.
So what is the true unit of geometry_msgs::Twist or cmd_vel?
↧
How to use the subscribed cmd_vel?
Hi,
i calculate the geometry_msgs::Twist cmd_vel and can subscribe to this topic /myrobot/cmd_vel successfully.
But i don't know how to use it, e.g. send it directly to my robot? I mean I can call back with velCallback, but how to use the velocity, in the main() function or in the velCallback() function if i want to send it to the robot? I hope i express my question clearly.
Below is the simple subscriber node.
----------
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "geometry_msgs/Twist.h"
using namespace std;
void velCallback(const geometry_msgs::Twist& vel)
{
cout<<"velocity\n"<
↧
problem with move_base
I am trying to control a bot with a lidar. When i run the launch files to switch on the lidar and obtain the cmd_vel values from rosserial based on odometry data, the cmd_vel is being published by the move_base.launch file. But, when i run the navigation stack which uses this data, I get an error that says-" THe bot cannot move forward". A little debugging tells me that the navigation stack subscribes to cmd_vel from move_base. But, the cmd_vel is not being output by the launch files itself. How to solve this problem?q
↧
How to implement velocity transformation?
Hi all,
i have the velocity topic /cmd_vel, and it's the type geometry_msgs::Twist, it is given in the object reference frame, and now i need to transform the velocity to another frame, such as my robot's base frame. How can i do that, if i know the translation and rotation between the two frames?
I think it is different from position transformation, because velocity is 6 dimension and position only 3.
Does someone have this knowledge? Any help is appreciated.
↧
↧
Navigation cmd_vel and TwistStamped
Hello,
I've set up the navigation stack on my robot. The issue is `move_base` is publishing the velocity commands on `cmd_vel` whose message is of type `Twist`, but my robot is subscribing to a topic called `base_velocity` whose message is of type `TwistStamped`. So as I understand, only [remapping](http://wiki.ros.org/roslaunch/XML/remap) wouldn't do the work. What can I do to remap topics of different message types.
Thanks
**Answer:** So I wrote the node below that converts `cmd_vel` messages to `base_velocity,`
#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Twist, TwistStamped
import time
def callback(cmdVelocity):
baseVelocity = TwistStamped()
baseVelocity.twist = cmdVelocity
now = rospy.get_rostime()
baseVelocity.header.stamp.secs = now.secs
baseVelocity.header.stamp.nsecs = now.nsecs
baseVelocityPub = rospy.Publisher('base_velocity', TwistStamped, queue_size=10)
baseVelocityPub.publish(baseVelocity)
def cmd_vel_listener():
rospy.Subscriber("cmd_vel", Twist, callback)
rospy.spin()
if __name__ == '__main__':
rospy.init_node('cmd_vel_listener', anonymous=True)
cmd_vel_listener()
↧
multiplexing between two topic
Hi i am using P3AT(USARSim simulator) and want to drive it from my **ROS-Fuerte**. what i want to do is,
1. Driving the robot using keyboard (using teleop_twist_keyboard)
2. Automated navigation of robot (using Navigation stack)
I want to drive the robot using keyboard but when i commit mistake(i.e. approaching to hit a wall) the automated behavior need to be activated.
by following [this](http://wiki.ros.org/cmd_vel_mux), i have my configuration file
**example_cfg.yaml**
subscribers:
- name: "Human_is_Driving"
topic: "teleop_cmd_vel"
timeout: 0.5
priority: 5
- name: "MACHINE_TAKES_OVER"
topic: "auto_cmd_vel"
timeout: 0.5
priority: 5
publisher: "velocity_multiplexer/mux_cmd_vel"
**standalone.launch**
**resulting rqt graphs of**
1. [teleoperation](https://www.dropbox.com/s/91x7g395wb2n10i/rqt_graph_teleop.png?dl=0)
2. [automated navigation](https://www.dropbox.com/s/iqcy1vnzwxobi92/rqt_graph_move_base.png?dl=0)
i am not able to understand the complexity of the problem.
please help me to understand ***"how can i switch between cmd_vel used by teleop & cmd_vel used by move_base"***
↧
I need to write a subscribe to the cmd_vel for turtlebot
I need to write a subscribe to the cmd_vel topic, where am publishing to turtlebot the gazebo. So I want to return the speed turtlebot through the subscriber, not chei code examples for this case, I'm using an example of publisher where the directional control turtlebot in the gazebo. would be grateful for any help! !
I know I have 2 variables that the publisher would velocidada the angular and linear speed, but I need a topic that returns me the speed if not possible at least the subscriber's cmd_vel help me.
Thank you
↧
cmd_vel linear and angular relationship
Hi All,
I'm using rqt robot steering to output cmd_vel message which I subscribe to and they control the power of the motors.
Linear is fine and +/-100% is controlling the motors fed and reverse okay. How should I combine that with the rotational input such that the effect is to increase or decrease the rate of turn? Just something simple is fine, this is a 2 wheeled robot.
The examples I keep finding on the internet seem to be simple key based designs. i.e. F=Fwd/L=Left etc...
Many Thanks
Mark
↧
↧
Which topics can i use to receive all turtlebot sensors information?
i already have the turtlebot 2, and i want to subscribe all topics that have any information from sensors. I already subscribe the odom topic and cmd_vel topic, and i want to know which topics are lacking
----------
void odomCallback(const nav_msgs::Odometry::ConstPtr& odom)
{
ROS_INFO("I received odom: [%f,%f,%f]", odom->pose.pose.position.x, odom->pose.pose.position.y,odom->pose.pose.position.z);
}
ros::Subscriber sub_odom = nh.subscribe("odom", 1000, odomCallback);
----------
This code is right? Where can i see more subscribers to the other sensors?
↧
Commanding simple paths / curves to move_base
Hi
I want to measure the power consumption of my robot when it moves on some simple paths.
For example I would like to command **a straight movement leading to a curve of a specific radius with a certain speed**. Is there any way to save and modify certain paths? What I tried so far: - Just giving goals to the robot leads to a very unspecific behavior which is not easily repeatable. - Also simply using *cmd\_vel* is too low level for this. Thanks for your help.
For example I would like to command **a straight movement leading to a curve of a specific radius with a certain speed**. Is there any way to save and modify certain paths? What I tried so far: - Just giving goals to the robot leads to a very unspecific behavior which is not easily repeatable. - Also simply using *cmd\_vel* is too low level for this. Thanks for your help.
↧
Use irobot create in gazebo with ROS
hello everyone i follow this tutorial [http://guitarpenguin.is-programmer.com/posts/58100.html](http://guitarpenguin.is-programmer.com/posts/58100.html) to let my robot model subscribe cmd_vel and move in gazebo ,but when i spawn model in gazebo the terminal show:
[ INFO] [1420784789.699143934, 242.985000000]: Loaded gazebo_ros_control.
[ INFO] [1420784789.703800416, 242.985000000]: DiffDrive missing , defaults is my_robot
[ INFO] [1420784789.703967194, 242.985000000]: Starting plugin DiffDrive(ns = my_robot/)!
[ WARN] [1420784789.704044386, 242.985000000]: DiffDrive(ns = my_robot/): missing default is na
[ INFO] [1420784789.705129170, 242.985000000]: DiffDrive(ns = my_robot/): = my_robot
[ WARN] [1420784789.705392286, 242.985000000]: DiffDrive(ns = my_robot/): missing default is false
[ WARN] [1420784789.705423241, 242.985000000]: DiffDrive(ns = my_robot/): missing default is false
[ WARN] [1420784789.705642094, 242.985000000]: DiffDrive(ns = my_robot/): missing default is 0
[ WARN] [1420784789.705671681, 242.985000000]: DiffDrive(ns = my_robot/): missing default is 5
[ WARN] [1420784789.706323840, 242.985000000]: DiffDrive(ns = my_robot/): missing default is 1
[ WARN] [1420784789.706749342, 242.985000000]: GazeboRosDiffDrive Plugin (ns = ) missing , defaults to 1
[ INFO] [1420784789.708436488, 242.985000000]: DiffDrive(ns = my_robot/): Try to subscribe to cmd_vel!
[ INFO] [1420784789.715558793, 242.985000000]: DiffDrive(ns = my_robot/): Subscribe to cmd_vel!
[ INFO] [1420784789.716687462, 242.985000000]: DiffDrive(ns = my_robot/): Advertise odom on odom !
↧