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

Morteza70's profile - activity

2023-01-02 10:23:39 -0500 received badge  Famous Question (source)
2022-03-27 04:21:41 -0500 received badge  Famous Question (source)
2022-03-27 04:21:41 -0500 received badge  Notable Question (source)
2021-12-11 13:18:56 -0500 received badge  Famous Question (source)
2021-09-07 04:16:06 -0500 commented answer roslaunch group ns doesn't work

thanks for your comments. In noetic, the node still publishes cmd_vel, not /t1/cmd_vel (not using remap and just using n

2021-09-07 04:11:36 -0500 edited question roslaunch group ns doesn't work

roslaunch group ns doesn't work Hello, As far as I know, there is two ways to change topics in the launch file: using

2021-09-06 12:07:53 -0500 received badge  Popular Question (source)
2021-09-06 08:01:37 -0500 edited question roslaunch group ns doesn't work

roslaunch group ns doesn't work Hello, As far as I know, there is two ways to change topics in the launch file: using

2021-09-05 10:43:58 -0500 asked a question roslaunch group ns doesn't work

roslaunch group ns doesn't work Hello, As far as I know, there is two ways to change topics in the launch file: using

2021-09-05 10:40:52 -0500 marked best answer configuration for launching gazebo world and model from a package

I have a package containing worlds that have several models defined in the models directory.

what configurations (e.g. in package.xml and CMakeList.txt) should I set in order to Gazebo and ROS work properly and detects my models?

2021-06-01 12:26:47 -0500 received badge  Notable Question (source)
2021-06-01 01:51:38 -0500 received badge  Popular Question (source)
2021-03-08 08:44:42 -0500 asked a question configuration for launching gazebo world and model from a package

configuration for launching gazebo world and model from a package I have a package containing worlds that have several m

2021-02-03 15:24:33 -0500 received badge  Notable Question (source)
2020-12-30 09:38:35 -0500 received badge  Enthusiast
2020-12-19 20:50:03 -0500 commented answer Service server doesn’t get the subscriber objects readings

Thanks, It worked!

2020-12-19 20:49:29 -0500 received badge  Supporter (source)
2020-12-19 20:49:24 -0500 marked best answer Service server doesn’t get the subscriber objects readings

I wrote this class for a laser/scan subscriber:

#! /usr/bin/env python
import rospy
from sensor_msgs.msg import LaserScan
import time

class laser_sub_class(object):
    def __init__(self):
        self.subscriber = rospy.Subscriber("/kobuki/laser/scan", LaserScan, self.laser_callback)
        self.ctrl_c = False
        rospy.on_shutdown(self.shutdownhook)
        self.rate = rospy.Rate(10)


    def shutdownhook(self):
        rospy.loginfo("laser shutdownhook! stopped!")
        self.ctrl_c=True

    def laser_callback(self, msg):
        rospy.loginfo("laser_callback")
        self.range= msg.ranges

if __name__=="__main__":
    rospy.init_node("laser_scan_subscriber")
    laserScan_sub_ob = laser_sub_class()
    rospy.spin()

and, I wrote this service_server that makes an object of mentioned class: laser_sub = laser_sub_class()

#! /usr/bin/env python

import rospy
from std_srvs.srv import Trigger, TriggerResponse
from laser_scan_subscriber import laser_sub_class
import time


def serv_callback(request):
    rospy.loginfo("The Service obstacle_avoidance_service has been called")
    laser_sub = laser_sub_class()
    #time.sleep(0.3)

    r = laser_sub.range
    r_min= min(r)
    min_ind = r.index(r_min)

    response = TriggerResponse()
    response.success = True
    response.message = "straight"

    if r_min <0.4:
        response.success = False
        if min_ind<360:
            response.message = "left"
        elif min_ind>360:
            response.message = "right"
        elif min_ind==360:
            if r[0]>r[710]:
                response.message = "right"
            else:
                response.message = "left"

    return response


rospy.init_node("obst_avoid_service_server")
rospy.Service("obstacle_avoidance_service", Trigger, serv_callback)
rospy.loginfo("Service /obstacle_avoidance_service Ready")

rospy.spin()

When I call this service, I get this:

‘laser_sub_class’ object has no attribute ‘range’.

but I've declared in callback of the subscriber class that: self.range= msg.ranges

so why the object has no range attribute?

2020-12-19 20:49:24 -0500 received badge  Scholar (source)
2020-12-19 20:49:09 -0500 received badge  Popular Question (source)
2020-12-17 19:27:14 -0500 edited question Service server doesn’t get the subscriber objects readings

Service server doesn’t get the subscriber objects readings I wrote this class for a laser/scan subscriber: #! /usr/bin/

2020-12-17 18:24:43 -0500 asked a question Service server doesn’t get the subscriber objects readings

Service server doesn’t get the subscriber objects readings I wrote this class for a laser/scan subscriber: #! /usr/bin/

2018-09-17 09:36:28 -0500 received badge  Notable Question (source)
2018-02-21 04:48:22 -0500 received badge  Famous Question (source)
2018-02-21 04:48:22 -0500 received badge  Notable Question (source)
2018-02-21 04:48:22 -0500 received badge  Popular Question (source)
2017-07-18 08:10:14 -0500 edited question Error in TurtleBot3 Fake Node Implementation

Error in TurtleBot3 Fake Node Implementation I installed TurtleBot3 package and then tried to install turtlebot3_simulat

2017-07-18 08:09:36 -0500 asked a question Error in TurtleBot3 Fake Node Implementation

Error in TurtleBot3 Fake Node Implementation I installed TurtleBot3 package and then tried to install turtlebot3_simulat

2017-07-17 23:10:22 -0500 received badge  Popular Question (source)
2017-07-17 07:08:41 -0500 received badge  Organizer (source)
2017-07-17 07:07:54 -0500 edited question TurtleBot Robots Wi-Fi Network

TurtleBot Robots Wi-Fi Network can numbers of TurtleBot robots connect to each other with wi-fi without a center like a

2017-07-17 07:07:21 -0500 edited question TurtleBot Robots Wi-Fi Network

TurtleBot Robots Wi-Fi Network can numbers of TurtleBot robots connect to each other with wi-fi without a center like a

2017-07-17 07:07:04 -0500 received badge  Editor (source)
2017-07-17 07:07:04 -0500 edited question TurtleBot Robots Wi-Fi Network

TurtleBot Robots Wi-Fi Network can numbers of TurtleBot robots connect to each other with wi-fi without a center like a

2017-07-17 07:06:36 -0500 edited question TurtleBot Robots Wi-Fi Network

TirtleBot Robots Wi-Fi Network can numbers of TirtleBot robots connect to each other with wi-fi without a center like a

2017-07-12 06:53:40 -0500 asked a question turtlebot robots cooperation

turtlebot robots cooperation can numbers of TurtleBot robots connect to each other with wi-fi without central PC? for ex

2017-07-12 06:51:44 -0500 asked a question TurtleBot Robots Wi-Fi Network

TirtleBot Robots Wi-Fi Network can numbers of TirtleBot robots connect to each other with wi-fi without a center like a