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

BV_Pradeep's profile - activity

2021-11-24 01:16:33 -0500 received badge  Teacher (source)
2021-11-24 01:16:33 -0500 received badge  Self-Learner (source)
2021-11-24 01:16:33 -0500 received badge  Necromancer (source)
2021-08-20 15:36:31 -0500 marked best answer Passing Multiple Arguments to Subscriber Callback function in python

Hi All,

I am wrote the following code to track position of my robot in rviz using markers.

import rospy
from visualization_msgs.msg import Marker
from geometry_msgs.msg import PoseStamped,Point


def callback(data,marker,pub_point):
    add_point = Point()
    add_point.x = data.pose.position.x
    add_point.y = data.pose.position.y
    add_point.z = 0
    marker.points.append(add_point)
    # Publish the Marker
    pub_point.publish(marker)

if __name__ == '__main__':
    rospy.init_node('position_tracker')
    pub_point = rospy.Publisher('realpoints_marker', Marker, queue_size=1)
    rospy.loginfo('Generate the system')

    marker = Marker()
    marker.header.frame_id = "/map"
    marker.type = marker.POINTS
    marker.action = marker.ADD

    # marker scale
    marker.scale.x = 0.03
    marker.scale.y = 0.03
    marker.scale.z = 0.03

    # marker color
    marker.color.a = 1.0
    marker.color.r = 1.0
    marker.color.g = 0.0
    marker.color.b = 0.0

    # marker orientaiton
    marker.pose.orientation.x = 0.0
    marker.pose.orientation.y = 0.0
    marker.pose.orientation.z = 0.0
    marker.pose.orientation.w = 1.0

    # marker position
    marker.pose.position.x = 0.0
    marker.pose.position.y = 0.0
    marker.pose.position.z = 0.0

    # marker line points
    marker.points = []
    rospy.Subscriber("/pose", PoseStamped, callback,marker,pub_point)

I get a error saying that queue size needs to be Integer. It is because of how rospy class is defined http://docs.ros.org/melodic/api/rospy/html/rospy.topics.Subscriber-class.html

The fourth argument is queue size.

I need to pass marker and pub_point objects to callback function.

Solution:

import rospy
from visualization_msgs.msg import Marker
from geometry_msgs.msg import PoseStamped,Point

def callback(data):
    add_point = Point()
    add_point.x = data.pose.position.x
    add_point.y = data.pose.position.y
    add_point.z = 0
    rospy.loginfo('Publishing Marker Point')
    marker.points.append(add_point)
    # Publish the Marker
    pub_point.publish(marker)

marker = Marker()
marker.header.frame_id = "/my_frame"
marker.type = marker.POINTS
marker.action = marker.ADD

# marker scale
marker.scale.x = 0.03
marker.scale.y = 0.03
marker.scale.z = 0.03

# marker color
marker.color.a = 1.0
marker.color.r = 1.0
marker.color.g = 0.0
marker.color.b = 0.0

# marker orientaiton
marker.pose.orientation.x = 0.0
marker.pose.orientation.y = 0.0
marker.pose.orientation.z = 0.0
marker.pose.orientation.w = 1.0

# marker position
marker.pose.position.x = 0.0
marker.pose.position.y = 0.0
marker.pose.position.z = 0.0

# marker line points
marker.points = []
print "Marker created...."

rospy.loginfo('Publishing Marker Point')
rospy.init_node('position_tracker')
pub_point = rospy.Publisher('realpoints_marker', Marker, queue_size=1)
print "Publisher created...."
rospy.Subscriber("/simulated_waypoints", PoseStamped, callback)
print "Subcriber created...."
rospy.spin()
2021-08-10 16:35:22 -0500 received badge  Student (source)
2021-07-08 14:28:01 -0500 received badge  Famous Question (source)
2021-07-08 14:28:01 -0500 received badge  Popular Question (source)
2021-07-08 14:28:01 -0500 received badge  Notable Question (source)
2020-09-21 07:39:44 -0500 received badge  Famous Question (source)
2020-08-31 14:58:38 -0500 received badge  Famous Question (source)
2020-07-03 12:39:00 -0500 received badge  Notable Question (source)
2020-07-03 05:54:09 -0500 received badge  Notable Question (source)
2020-07-03 05:54:09 -0500 received badge  Famous Question (source)
2020-06-18 04:06:09 -0500 commented question RVIZWeb not starting properly

I git cloned rvizweb from OSRF page and followed their instructions on "catkin_make install" sourcing the install folder

2020-06-18 03:53:06 -0500 received badge  Popular Question (source)
2020-06-03 07:52:39 -0500 asked a question RVIZWeb not starting properly

RVIZWeb not starting properly Hi All, I am running ROS Melodic n Ubuntu 18.04 LTS version. I am working RVIZ web to dis

2020-06-01 20:29:26 -0500 commented question rosbridge_address not found

@gvdhoon edited the question as per your instructions, Please reopen the question

2020-06-01 20:28:15 -0500 edited question rosbridge_address not found

rosbridge_address not found Hi All, I am running ROS Melodic on Ubuntu 18.04 . I started rosbridge server on local sys

2020-06-01 16:53:13 -0500 received badge  Notable Question (source)
2020-06-01 09:58:24 -0500 asked a question rosbridge_address not found

rosbridge_address not found Hi All, I am running ROS Melodic on Ubuntu 18.04 . I started rosbridge server on local sys

2020-04-09 12:56:43 -0500 received badge  Famous Question (source)
2020-02-21 22:25:43 -0500 received badge  Famous Question (source)
2020-02-21 22:21:41 -0500 received badge  Famous Question (source)
2020-02-03 02:58:41 -0500 received badge  Famous Question (source)
2020-01-28 07:55:39 -0500 received badge  Popular Question (source)
2020-01-24 09:51:13 -0500 received badge  Famous Question (source)
2020-01-21 20:02:43 -0500 received badge  Popular Question (source)
2020-01-21 20:02:43 -0500 received badge  Notable Question (source)
2020-01-21 03:06:14 -0500 marked best answer Tracking Robot position using Marker

Hi All,

I am using ROS Kinetic on Ubuntu 16.04. I am working on a RVIZ Marker program to track "\AMCL_Pose" parameter and visualize in RVIZ. The code I have written is as follows

"""
The following program is used to display the real pose positions taken by the
robot in rviz.
References:
1.https://www.programcreek.com/python/example/88812/visualization_msgs.msg.Marker
"""

import rospy
from visualization_msgs.msg import Marker
from geometry_msgs.msg import PoseWithCovarianceStamped,Point

def callback(data):
    add_point = Point()
    add_point.x = data.pose.pose.position.x
    add_point.y = data.pose.pose.position.y
    add_point.z = 0
    rospy.loginfo('Publishing Marker Point')
    marker.points.append(add_point)
    # Publish the Marker
    pub_point.publish(marker)
    rospy.sleep(5)


marker = Marker()
marker.header.frame_id = "/map"
marker.type = marker.LINE_STRIP
marker.action = marker.ADD

# marker scale
marker.scale.x = 0.03
marker.scale.y = 0.03
marker.scale.z = 0.03

# marker color
marker.color.a = 1.0
marker.color.r = 1.0
marker.color.g = 0.0
marker.color.b = 0.0

# marker orientaiton
marker.pose.orientation.x = 0.0
marker.pose.orientation.y = 0.0
marker.pose.orientation.z = 0.0
marker.pose.orientation.w = 1.0
"""
# marker position
marker.pose.position.x = 0.0
marker.pose.position.y = 0.0
marker.pose.position.z = 0.0
"""
# marker line points
marker.points = []
rospy.loginfo('Marker created')

rospy.init_node('position_tracker')

pub_point = rospy.Publisher('realpoints_marker', Marker, queue_size=1)
print "Publisher created...."

rospy.Subscriber("/amcl_pose",PoseWithCovarianceStamped, callback)
print "Subcriber created...."
rospy.spin()

I get the following result image description

The issue is that the length and orientation of the line are not proper. The robot has moved over 20 meters but in rviz it showing only 5 meters.

How to resolve this issue ?

2020-01-21 03:06:04 -0500 answered a question Tracking Robot position using Marker

Fixed the issue by removing the sleep time in the publisher.

2020-01-21 03:03:45 -0500 marked best answer "Permission denied" when importing tf

Hi All,

I am using ros kinetic on ubuntu 16.04 xenial. while trying to import tf library in python code I get following error

Traceback (most recent call last):
  File "pose_visualizer.py", line 13, in <module>
    import  tf
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf/__init__.py", line 28, in <module>
    from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 39, in <module>
    from .buffer_interface import *
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/buffer_interface.py", line 32, in <module>
    import roslib; roslib.load_manifest('tf2_ros')
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/launcher

.py", line 62, in load_manifest
    sys.path = _generate_python_path(package_name, _rospack) + sys.path
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/launcher.py", line 93, in _generate_python_path
    m = rospack.get_manifest(pkg)
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 167, in get_manifest
    return self._load_manifest(name)
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 211, in _load_manifest
    retval = self._manifests[name] = parse_manifest_file(self.get_path(name), self._manifest_name, rospack=self)
  File "/usr/lib/python2.7/dist-packages/rospkg/manifest.py", line 414, in parse_manifest_file
    _static_rosdep_view = init_rospack_interface()

  File "/usr/lib/python2.7/dist-packages/rosdep2/rospack.py", line 59, in init_rospack_interface
    lookup = _get_default_RosdepLookup(Options())
  File "/usr/lib/python2.7/dist-packages/rosdep2/main.py", line 134, in _get_default_RosdepLookup
    verbose=options.verbose)
  File "/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py", line 585, in create_default
    sources = load_cached_sources_list(sources_cache_dir=sources_cache_dir, verbose=verbose)
  File "/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py", line 543, in load_cached_sources_list
    with open(cache_index, 'r') as f:
IOError: [Errno 13] Permission denied: '/home/rnd424/.ros/rosdep/sources.cache/index'

How to resolve this error ?

2020-01-21 01:52:11 -0500 commented question How to publish a message to a topic while playing rosbag?

The question is unclear as rosbag play <filename> will playback your recorded file. if you then look at the no

2020-01-21 01:51:42 -0500 commented question How to publish a message to a topic while playing rosbag?

The question is unclear as rosbag play <filename> will playback your recorded file. if you then look at the no

2020-01-21 01:05:32 -0500 asked a question "Permission denied" when importing tf

tf import error Hi All, I am using ros kinetic on ubuntu 16.04 xenial. while trying to import tf library in python cod

2019-12-10 00:46:20 -0500 received badge  Notable Question (source)
2019-12-10 00:46:20 -0500 received badge  Famous Question (source)
2019-12-09 23:14:57 -0500 answered a question Wrong Pose update while moving robot slowely in reverse direction using tele-operation

@Delb, I am posting a screenshot for my colleague, Please find the screenshot below.

2019-12-04 11:50:24 -0500 received badge  Notable Question (source)
2019-12-04 11:50:24 -0500 received badge  Famous Question (source)
2019-12-04 11:50:24 -0500 received badge  Popular Question (source)
2019-12-02 05:27:55 -0500 received badge  Notable Question (source)
2019-12-02 04:02:18 -0500 asked a question Map Matching with Laser Scan and Static Map

Map Matching with Laser Scan and Static Map Hi All, I working on a Localization and Navigation problem by writing my ow

2019-11-22 01:03:34 -0500 received badge  Famous Question (source)
2019-11-09 00:56:49 -0500 received badge  Popular Question (source)
2019-11-05 05:08:48 -0500 commented answer Bi-Directional Navigation using Move Base for Rosbot

I am using move_base which uses base local planner. how to use pose_follower with move base ?

2019-11-05 01:57:04 -0500 edited question Bi-Directional Navigation using Move Base for Rosbot

Bi-Directional Navigation using Move Base for turtlebot Hi All, I am using ROS Kinetic on ubuntu 16.04 OS. I am working