socrob / autonomous_systems Goto Github PK
View Code? Open in Web Editor NEWMaterial used for learning ROS and robotics, as part of the Autonomous Systems course at Instituto Superior Tecnico
Material used for learning ROS and robotics, as part of the Autonomous Systems course at Instituto Superior Tecnico
A student had problems with the setup of AMCL in Stage, here I post some launch files and code for it
steps to reproduce error:
roscore
rosrun rviz rviz
rviz does not start and crashes with segmentation fault error
use urg_node instead:
sudo apt-get install ros-kinetic-urg-node
here is an example launch file
<!-- hokuyo usb port paths -->
<arg name="hokuyo_front_port" default="/dev/mbot/hokuyo-front" />
<arg name="hokuyo_rear_port" default="/dev/mbot/hokuyo-rear" />
<!-- front laser scanner driver -->
<node pkg="urg_node" type="urg_node" name="hokuyo_node_front">
<remap from="/scan" to="scan_front" />
<param name="ip_address" value=""/>
<param name="serial_port" value="$(arg hokuyo_front_port)"/>
<param name="serial_baud" value="115200"/>
<param name="frame_id" value="base_laser_front_link"/>
<param name="calibrate_time" value="true"/>
<param name="publish_intensity" value="false"/>
<param name="publish_multiecho" value="false"/>
<param name="angle_min" value="-1.5707963"/>
<param name="angle_max" value="1.5707963"/>
</node>
you will need udev rules, installed on your system:
SUBSYSTEM=="tty", KERNEL=="ttyACM*", SYMLINK+="mbot/hokuyo-front", MODE="0666"
#!/usr/bin/env python
import rospy
from nav_msgs.msg import Odometry
from sensor_msgs.msg import LaserScan
class EKFLocalizationKinect(object):
'''
listens to topic emotions, turns on/off different LED'S of the mbot head
to mimic the desired emotion
'''
def __init__(self):
'''
Constructor (gets executed only once at the moment of object creation)
'''
rospy.Subscriber("/robot_0/odom", Odometry, self.odomCallback, queue_size=1)
rospy.Subscriber("/robot_0/base_scan_1", LaserScan, self.laserCallback, queue_size=1)
self.odom_msg_received = False
self.laser_msg_received = False
self.odom_msg = None
self.laser_msg = None
self.loop_rate = rospy.Rate(rospy.get_param('~loop_rate', 10.0))
self.updated_robot_pose = None # or set to initial robot pose?
self.whatever_name_i_want = 3.0
def odomCallback(self, msg):
'''
gets executed every time you receive a new msg on topic /robot_0/odom
'''
self.odom_msg = msg
self.odom_msg_received = True
def laserCallback(self, msg):
'''
gets executed every time you receive a new msg on topic /robot_0/base_scan_1
'''
self.laser_msg = msg
self.laser_msg_received = True
def compare_timestamps(self):
'''
ensure that no big time difference exists between your msgs for sync purposes
'''
# get timestamps of both (from header)
# compare
# if bigger than a threshold then return falsem otherwise true
return True # HACK for now to do it later
def ekf_update(self):
'''
perform one EKF update
'''
self.updated_robot_pose = call_kalman(args...)
def start_ekf_loc(self):
'''
main loop
'''
while not rospy.is_shutdown():
if self.odom_msg_received == True:
rospy.loginfo('odom msg received!')
if self.laser_msg_received == True:
rospy.loginfo('laser msg received!')
# lower flags
self.laser_msg_received = False
self.odom_msg_received = False
# compare timestamps
if self.compare_timestamps()
# update eyes emotion
self.ekf_update()
else:
rospy.logwarn('odom and laser msgs are not in sync')
# sleep to control node frequency
self.loop_rate.sleep()
if __name__ == '__main__':
rospy.init_node('my_ekf_localication_kinect', anonymous=False)
# create object of the EKF class (constructor gets executed)
my_ekf_localication_kinect = EKFLocalizationKinect()
# call main function
my_ekf_localication_kinect.start_ekf_loc()
Last session, prof. Rodrigo suggested creating a map with gmapping and amcl, if I ain't wrong, although how are we supposed to do it, since everywhere we find something about that matter, it is said we should use a laser range finder and we don't have one. Is there another way?
If after following the instructions for the system setup you build a package, source your environment (source ~/.bashrc) the system ca'n find your package :
$ roscd example
roscd: No such package/stack 'example1'
Verify your bashrc file by typing:
gedit ~/.bashrc
If you have the following sequence of lines:
source ~/scripts/permanent.sh
source /home/<username>/ros_ws/devel/setup.bash
you should delete the line
source /home/<username>/ros_ws/devel/setup.bash
and maintain only the following line
source ~/scripts/permanent.sh
Question: We have some problems with the lookupTransform. We are asking the more recent position of the robot and upon a time it returns us an older position instead of the current one.
We have already used rospy.Time(0) and this doesn't solved our problem
I'm trying to teleop the robot with the keyboard by using the commands you gave us Oscar, but it simply doesn't work and we have no clue why. We are using the robot not the simulation, and running the command you gave on the lab2, rosrun teleop_twist_keyboard teleop_twist_keyboard.py cmd_vel:=/cmd_vel
Like we said during our presentation, we're trying to control our Pioneer 3DX with a mobile phone. To do that, we installed the application ROS All Sensors Driver (https://play.google.com/store/apps/details?id=org.ros.android.android_all_sensors_driver) and we used a ROS tutorial (http://wiki.ros.org/ROSARIA/Tutorials/Android%20teleop%20Pioneer%203at). So, as you can see in the tutorial, we make android_teleop.cpp, that contains all the instructions and we run this code with the CMakeLists.txt when we add the (rosbuild_add_executable(android_teleop android_teleop.cpp)) line to the CMakeLists.txt, but we are getting an error (as you can see in the image) and we don't know how to solve this. We already tried to add to the CMakeLists file the (add_executable(android_teleop android_teleop.cpp)) line, but that didn't solve the problem either. It seems like the executable line is not recognizable. Can you help us?
CMakeLists.txt
The android_teleop.cpp file:
` /*
2 * Copyright (c) 2013, Anas Alhashimi LTU.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Willow Garage, Inc. nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 * Anas W. Alhahsimi
29 */
#include <ros/ros.h>
#include "geometry_msgs/Twist.h"
#include "ROSARIA/BumperState.h"
#include "sensor_msgs/Imu.h"
#include <signal.h>
#include <termios.h>
using geometry_msgs::Twist;
using namespace std;
ros::Publisher chatter_pub;
ros::Time t1;
Twist vel;
int kfd = 0;
struct termios cooked, raw;
unsigned int temp=0;
float x;
float y;
float z;
void quit(int sig)
{
tcsetattr(kfd, TCSANOW, &cooked);
ros::shutdown();
exit(0);
}
void anCallback(const sensor_msgs::Imu::ConstPtr& ansmsg)
{
x=ansmsg->angular_velocity.x;
y=ansmsg->angular_velocity.y;
z=ansmsg->angular_velocity.z;
}
int main(int argc, char** argv)
{
int ther=5;
ros::init(argc, argv, "android_teleop");
ros::NodeHandle n;
chatter_pub = n.advertise("/cmd_vel", 1);
signal(SIGINT,quit);
ros::Rate r(5);
char c;
bool dirty=false;
t1=ros::Time::now();
tcgetattr(kfd, &cooked);
memcpy(&raw, &cooked, sizeof(struct termios));
raw.c_lflag &=~ (ICANON | ECHO);
raw.c_cc[VEOL] = 1;
raw.c_cc[VEOF] = 2;
tcsetattr(kfd, TCSANOW, &raw);
//subscribe to android imu sensor msgs
ros::Subscriber imu_pub = n.subscribe<sensor_msgs::Imu>("/android/imu", 1, anCallback);
while (ros::ok())
{
if(x > ther)
{
vel.linear.x = 0.2;
vel.linear.y=0;
vel.linear.z=0;
vel.angular.x = 0;
vel.angular.y = 0;
vel.angular.z = 0;
ROS_INFO("forward");
}
if(x < -ther)
{
vel.linear.x = -0.2;
vel.linear.y=0;
vel.linear.z=0;
vel.angular.x = 0;
vel.angular.y = 0;
vel.angular.z = 0;
ROS_INFO("Backward");
}
if(z > ther)
{
vel.linear.x = 0;
vel.linear.y=0;
vel.linear.z=0;
vel.angular.x = 0;
vel.angular.y = 0;
vel.angular.z = 0.5;
ROS_INFO("Turnleft");
}
if(z < -ther)
{
vel.linear.x = 0;
vel.linear.y=0;
vel.linear.z=0;
vel.angular.x = 0;
vel.angular.y = 0;
vel.angular.z = -0.5;
ROS_INFO("Turnright");
}
if(y < -ther)
{
vel.linear.x = 0;
vel.linear.y=0;
vel.linear.z=0;
vel.angular.x = 0;
vel.angular.y = 0;
vel.angular.z = 0;
ROS_INFO("stop");
}
if(y > ther)
{
vel.linear.x = 0;
vel.linear.y=0;
vel.linear.z=0;
vel.angular.x = 0;
vel.angular.y = 0;
vel.angular.z = 0;
ROS_INFO("stop");
}
chatter_pub.publish(vel);
ros::Duration(0.1).sleep(); // sleep for one tenth of a second
ros::spinOnce();
}//while
return(0);
}
`
in Lab2 in installing drivers is
sudo service udev restart
source $HOME/autonomous_systems/resources/scripts/udev_rules/install_udev_rules.sh
But it write error that cant find 85-pioneer.rules because executing of command need to be from their location(so first make cd $HOME/autonom....):
sudo cp 85-pioneer.rules /etc/udev/rules.d
After updating and upgrading ubuntu 16.04 I am not able to access rqt_bag,
although I can still open rqt. I have no idea how to solve this situation.
sofia@sofia-X541UJ:~ $ rqt_bag
Traceback (most recent call last):
File "/opt/ros/kinetic/bin/rqt_bag", line 5, in <module>
from rqt_bag.bag import Bag
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_bag/bag.py", line 39, in <module>
from .bag_widget import BagWidget
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_bag/bag_widget.py", line 40, in <module>
from python_qt_binding.QtCore import Qt, qInfo, qWarning, Signal
ImportError: cannot import name qInfo
You can use this as an example launch file for your projects, it has a bit of most common features used in launch file programming/design:
<?xml version="1.0"?>
<launch>
<!-- load values from shell environment variables (check your bashrc and make sure both ROBOT and ROBOT_ENV are set) -->
<arg name="robot" default="$(optenv ROBOT !!ROBOT env NOT SET!!)" />
<arg name="robot_env" default="$(optenv ROBOT_ENV !!ROBOT_ENV env NOT SET!!)" />
<!-- common navigation launch files -->
<include file="$(find mbot_2dnav)/ros/launch/nav_common.launch">
<arg name="robot_env" value="$(arg robot_env)" />
</include>
<node pkg="move_base" type="move_base" respawn="true" name="move_base" output="screen">
<param name="base_local_planner" value="dwa_local_planner/DWAPlannerROS" />
<rosparam file="$(find mbot_2dnav)/ros/config/dwa/move_base_params.yaml" command="load" />
<rosparam file="$(find mbot_bringup)/ros/config/$(arg robot)/robot_footprint.yaml" command="load"/>
<rosparam file="$(find mbot_2dnav)/ros/config/dwa/costmap_common_params.yaml" command="load" ns="global_costmap"/>
<rosparam file="$(find mbot_bringup)/ros/config/$(arg robot)/robot_footprint.yaml" command="load" ns="global_costmap"/>
<rosparam file="$(find mbot_2dnav)/ros/config/dwa/global_costmap_params.yaml" command="load" />
<rosparam file="$(find mbot_2dnav)/ros/config/dwa/costmap_common_params.yaml" command="load" ns="local_costmap" />
<rosparam file="$(find mbot_bringup)/ros/config/$(arg robot)/robot_footprint.yaml" command="load" ns="local_costmap"/>
<rosparam file="$(find mbot_2dnav)/ros/config/dwa/local_costmap_params.yaml" command="load" />
<rosparam file="$(find mbot_2dnav)/ros/config/dwa/dwa_local_planner_params.yaml" command="load" ns="DWAPlannerROS" />
<!-- Upload recovery behavior parameters-->
<rosparam file="$(find mbot_2dnav)/ros/config/recovery_behaviors/force_field_parameters.yaml" command="load" ns="force_field_recovery"/>
<rosparam file="$(find mbot_2dnav)/ros/config/recovery_behaviors/clear_costmap_parameters.yaml" command="load" ns="clear_costmap_recovery"/>
<!-- Remap cmd_vel to a medium priority to allow joypad override control + publish constantly for some small amount of time -->
<remap from="cmd_vel" to="/cmd_vel_constant"/>
<remap from="~force_field_recovery/cmd_vel" to="/cmd_vel_prio_medium"/>
</node>
</launch>
When i run:
add_two_ints_server.py
It gives me an Import Error: No module named beginner_tutorials.srv
but i have that file there
How can i procedure?
sudo apt-get install ros-kinetic-ar-track-alvar
you can use this sample launch file:
<launch>
<arg name="marker_size" default="5" />
<arg name="max_new_marker_error" default="0.08" />
<arg name="max_track_error" default="0.2" />
<arg name="cam_image_topic" default="/head_camera/rgb/image_raw" />
<arg name="cam_info_topic" default="/head_camera/rgb/camera_info" />
<arg name="output_frame" default="/odom" />
<node name="ar_track_alvar" pkg="ar_track_alvar" type="individualMarkersNoKinect" respawn="false" output="screen">
<param name="marker_size" type="double" value="$(arg marker_size)" />
<param name="max_new_marker_error" type="double" value="$(arg max_new_marker_error)" />
<param name="max_track_error" type="double" value="$(arg max_track_error)" />
<param name="output_frame" type="string" value="$(arg output_frame)" />
<remap from="camera_image" to="$(arg cam_image_topic)" />
<remap from="camera_info" to="$(arg cam_info_topic)" />
</node>
</launch>
We are having trouble with the sick toolbox installation. We are following this site http://wiki.ros.org/sicktoolbox_wrapper/Tutorials/UsingTheSicklms#Compiling and it says that we must connect the laser via USB to our computer. What can we do without the device?
We are having some troubles teleoperating the pioneer using a command pc with virtualbox, but if we use 2 pcs with dual boot ubuntu-windows it works fine (the problem is that we only have one).
So we are wondering if you could help us solving this issue by telling us what we should change in networks configurations (if this is the root of the problem). We are sending this email because another group said that had the same problem and you were able to help them
In order to ensure communication between host and sensor (Hokuyo) is it supposed to use a XML file?
Trying the Hokuyo URG-04LX-UG01, using the Virtual Machine that was set up for us, we incur in the following problems:
After installing the urg_node package and giving it the proper permissions:
sudo apt-get install ros-kinetic-urg-node
sudo chmod a+rw /dev/ttyACM0
We started the roscore and ran the following commands:
rosrun urg_node getID /dev/ttyACM0
Device at /dev/ttyACM0 has ID H0905398
rosrun urg_node urg_node
Segmentation fault (core dumped)
We get the proper ID but have no idea what might be causing the core dump.
use video_stream_opencv from this website
use this sample launch file:
<!-- launch video stream -->
<include file="$(find video_stream_opencv)/launch/camera.launch" >
<!-- node name and ros graph name -->
<arg name="camera_name" value="webcam" />
<!-- means video device 0, /dev/video0 -->
<arg name="video_stream_provider" value="/home/oscar/Downloads/camera_calibration.mp4" />
<!-- throttling the querying of frames to -->
<arg name="fps" value="30" />
<!-- setting frame_id -->
<arg name="frame_id" value="webcam" />
<!-- camera info loading, take care as it needs the "file:///" at the start , e.g.:
"file:///$(find your_camera_package)/config/your_camera.yaml" -->
<arg name="camera_info_url" value="" />
<!-- flip the image horizontally (mirror it) -->
<arg name="flip_horizontal" value="false" />
<!-- flip the image vertically -->
<arg name="flip_vertical" value="false" />
<!-- visualize on an image_view window the stream generated -->
<arg name="visualize" value="true" />
</include>
Is it possible to get only 1 measurement from odometry at a time?
follow this tutorial
is moved now to https://github.com/socrob/autonomous_systems_datasets
Hi!
We have a problem in showing the positions of aruco codes in rviz.
If we use PoseArray (of ros) we can see the positions of the aruco codes in rviz:(like this)
And we can check that this is right because in the gazebo environment it matches:
Our problem is that we have to show the arucos pose estimation in rviz with the associated covariance and for that we have to use PoseWithCovariance (of ros) but this type of message do not receive a list but just a number
We have 16 arucos and we don't want to create 16 topics, then publish in all them the pose with covariance and then manually execute them on rviz (showing the topic and selecting all 16).
How can we find the better way to generate a list of Poses+Covariances of the arucos ?
i made a shell script which consists in a loop that returns wi fi readings, and it works well for about a minute, but after that i get the following message: "command failed: Device or resource busy (-16)".
i think this may be related to the fact that as we are using the computer's wi fi sensor, when it gets another task, it may not be able to continue providing us the information
The .sh file has this code:
num=1
> medidaswifi.txt
while(num=1); do
echo "New measurement" >> medidaswifi.txt
date +%s >> medidaswifi.txt
iw dev wlp3s0 scan | egrep "signal|wlp3s0" | sed -e "s/\tsignal: //" -e "s/\wlp3s0 //" >> medidaswifi.txt
echo "\n\n" >> medidaswifi.txt
done
How can we connect the tag to the Raspberry Pi, the cables are all joined together and there is no configuration on the RPi gpio headers which allows the correct connection.
We are having trouble organizing the data we receive from Hokuyo. We created a bag and when we type "rosbag info .bag" we can see it has 344 messages.
We believe that the data we have access is only the last scanning, which means our "ranges" vector has only 700 elements... We think this number of measurement per scan must be correct because we can calculate it once we know the angle_min, angle_max and the angle increment, and they are the same.
The information we have access in the rosbag concerns only the last scan?
NOTE: this issue was sent to prof. Ventura by mail, we copy the issue here so that others can benefit from the answer.
Steps to reproduce error:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.