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

Juan Carlos's profile - activity

2023-07-06 15:30:37 -0500 received badge  Famous Question (source)
2023-06-15 13:07:50 -0500 received badge  Student (source)
2023-06-15 13:07:40 -0500 received badge  Famous Question (source)
2023-06-15 13:07:40 -0500 received badge  Notable Question (source)
2023-06-15 13:07:40 -0500 received badge  Popular Question (source)
2023-06-05 18:39:25 -0500 edited question Hello, I want to use the Groot monitor. Is it possible to use a groot monitor with the turtlebot simulation ?

Hello, I want to use the Groot monitor. My question is, is it possible to use a groot monitor with the turtlebot simulat

2023-06-05 18:37:22 -0500 edited question Hello, I want to use the Groot monitor. Is it possible to use a groot monitor with the turtlebot simulation ?

Hello, I want to use the Groot monitor. My question is, is it possible to use a groot monitor with the turtlebot simulat

2023-06-05 18:37:13 -0500 edited question Hello, I want to use the Groot monitor. Is it possible to use a groot monitor with the turtlebot simulation ?

Hello, I want to use the Groot monitor. My question is, is it possible to use a groot monitor with the turtlebot simulat

2023-06-05 18:04:12 -0500 asked a question Hello, I want to use the Groot monitor. Is it possible to use a groot monitor with the turtlebot simulation ?

Hello, I want to use the Groot monitor. My question is, is it possible to use a groot monitor with the turtlebot simulat

2023-06-01 10:47:32 -0500 commented answer Hello everyone, I am running multiple nodes in different executables and I would like to use MultiThreadedExecutor. However, how to know which cores are my nodes using ?

Thank you for your answer. However, do you know if there is a way to relate ros2 nodes with the process Id. Because as y

2023-06-01 09:59:30 -0500 received badge  Popular Question (source)
2023-05-31 16:14:21 -0500 asked a question Hello everyone, I am running multiple nodes in different executables and I would like to use MultiThreadedExecutor. However, how to know which cores are my nodes using ?

Hello everyone, I am running multiple nodes in different executables and I would like to use MultiThreadedExecutor. Howe

2023-05-26 14:55:59 -0500 commented answer I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

Thanks a lot, I use the action client navigate_to_pose. I just create the client and with the function async_cancel_all_

2023-05-26 14:55:18 -0500 commented answer I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

Thanks a lot, I use the action client navigate_to_pose. I just create the client and with the function async_cancel_all_

2023-05-26 14:54:40 -0500 commented answer I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

Thanks a lot, I use the action client navigate_to_pose. I just create the client and with the function async_cancel_all_

2023-05-26 14:54:26 -0500 commented answer I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

Thanks a lot, I use the action client navigate_to_pose. I just create the client and with the function async_cancel_all_

2023-05-26 14:52:33 -0500 commented answer I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

Thanks a lot, I use the action client navigate_to_pose. I just create the client and with the function async_cancel_all_

2023-05-26 14:52:11 -0500 commented answer I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

Thanks a lot, I use the action client navigate_to_pose. I just create the client and with the function async_cancel_all_

2023-05-26 14:51:32 -0500 commented answer I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

Thanks a lot, I use the action client navigate_to_pose. I just create the client and with the function async_cancel_all_

2023-05-26 14:47:44 -0500 marked best answer I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

I want to replicate this button but in a python code. The robot should stop if it is close <2 m from any obstacle. I know the functions BasicNavigator.cancelTask() works but just if you add the goal in code but I need to use the Nav2 Goal tool.

image description

I tried using the Simple Commander API just calling the BasicNavigator.cancelTask() function but is not working I think I am using wrong. Does anyone how to do it ? It should be calling a service but I do not know which one exactly.

#!/usr/bin/env python3 
import rclpy
from nav2_simple_commander.robot_navigator import BasicNavigator
from rclpy.node import Node

from rclpy.action import ActionClient
from std_srvs.srv import SetBool

class StopNavigation(Node):
    def __init__(self):
        super().__init__('stop_navigation')
        # Create a BasicNavigator object.
        self.navigator = BasicNavigator()

    def stop_navigation_client(self):
        while rclpy.ok:
            self.navigator.waitUntilNav2Active()
            client = self.create_client(SetBool, "soft_stop_navigation")

            # Wait for the SetBool client to become available.
            while not client.wait_for_service(timeout_sec=1.0):
                rclpy.spin_once(self)

            # Send a request to the SetBool client.
            request = SetBool.Request()
            request.data = True
            future = client.call_async(request)
            rclpy.spin_until_future_complete(self, future)    

            # Check the response.
            response = future.result()
            print("")
            print("future_t: ", response.success)
            print("feedback: ",self.navigator.getFeedback())
            print("")
            if response.success:
                print("SetBool service succeeded, Cancel Nav.")
                self.navigator.cancelTask()

                # Check if the task was successfully canceled
                if self.navigator.cancelTask():
                    print("Task was successfully canceled")
                else:
                    print("Task could not be canceled")
                break
            else:
                print("Continue Nav...")

def main():
    # Initialize the ROS node.
    rclpy.init()

    # Create a MyNode object.
    node = StopNavigation()

    # Wait for the SetBool client to become available.
    node.stop_navigation_client()
    rclpy.spin_once(node)

    # Shutdown the ROS node.
    rclpy.shutdown()

if __name__ == "__main__":
    main()
2023-05-26 12:30:44 -0500 received badge  Notable Question (source)
2023-05-24 14:08:54 -0500 received badge  Popular Question (source)
2023-05-23 20:34:51 -0500 edited question I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less tha

2023-05-23 20:34:16 -0500 edited question I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less tha

2023-05-23 20:22:41 -0500 asked a question I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less than 2 meters from an obstacle

I am using in rviz2 the tool nav2 goal. But I want to cancel the robot's navigation when it is at a distance of less tha

2022-10-18 05:16:27 -0500 received badge  Famous Question (source)
2021-04-26 14:59:34 -0500 received badge  Famous Question (source)
2020-09-21 07:59:13 -0500 received badge  Famous Question (source)
2020-05-08 17:52:54 -0500 received badge  Notable Question (source)
2020-01-22 08:49:41 -0500 received badge  Notable Question (source)
2020-01-10 11:33:33 -0500 received badge  Notable Question (source)
2020-01-10 11:32:42 -0500 received badge  Enthusiast
2020-01-09 16:46:14 -0500 received badge  Popular Question (source)
2020-01-09 11:41:19 -0500 commented question hi, I have a troubule with this code, this run but when write in terminal rostopic hz '/PWM' say 'no new messages', and when write rostopic echo /PWM, not display anything. please what can I do ?

yes, i'm sure, I use for publish self.pub.publish(msg), for this reason see the topic, but when write rostopic echo, thi

2020-01-08 15:54:40 -0500 edited question hi, I have a troubule with this code, this run but when write in terminal rostopic hz '/PWM' say 'no new messages', and when write rostopic echo /PWM, not display anything. please what can I do ?

hi, I have a troubule with this code, this run but when write in terminal rostopic hz '/PWM' say 'no new messages', and

2020-01-08 15:53:44 -0500 edited question hi, I have a troubule with this code, this run but when write in terminal rostopic hz '/PWM' say 'no new messages', and when write rostopic echo /PWM, not display anything. please what can I do ?

hi, I have a troubule with this code, this run but when write in terminal rostopic hz '/PWM' say 'no new messages', and

2020-01-08 15:53:44 -0500 received badge  Editor (source)
2020-01-08 15:52:28 -0500 edited question hi, I have a troubule with this code, this run but when write in terminal rostopic hz '/PWM' say 'no new messages', and when write rostopic echo /PWM, not display anything. please what can I do ?

hi, I have a troubule with this code, this run but when write in terminal rostopic hz '/PWM' say 'no new messages', and

2020-01-08 15:51:24 -0500 asked a question hi, I have a troubule with this code, this run but when write in terminal rostopic hz '/PWM' say 'no new messages', and when write rostopic echo /PWM, not display anything. please what can I do ?

hi, I have a troubule with this code, this run but when write in terminal rostopic hz '/PWM' say 'no new messages', and

2020-01-03 18:44:24 -0500 commented answer Hi, I want to use the message filter in this example , I tried to register callback from a class member function as in the following code:

Thanks you!, you are correct, forgot the nav_msgs in the CMakelist, thaks

2020-01-03 18:43:02 -0500 marked best answer Hi, I want to use the message filter in this example , I tried to register callback from a class member function as in the following code:
#include <sensor_msgs/LaserScan.h>
#include <nav_msgs/Odometry.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <ros/ros.h>

using namespace nav_msgs;
using namespace sensor_msgs;
using namespace message_filters;

class Data{

        public:
                void callback(const OdometryConstPtr& msg, const LaserScanConstPtr& dat);

        };

void Data::callback(const OdometryConstPtr& msg, const LaserScanConstPtr& dat){
        //pos1 = msg->pose.pose.orientation.w;
}

int main (int argc, char **argv){

        ros::init(argc, argv, "odome");
        ros::NodeHandle nh;

        message_filters::Subscriber<Odometry> odometria(nh, "/odom", 1);
        message_filters::Subscriber<LaserScan> laser(nh, "/scan", 1);

        Data data;

        TimeSynchronizer<Odometry, LaserScan> sync(odometria, laser, 10);
        sync.registerCallback(boost::bind(&Data::callback, &data,_1,_2));

        ros::spin();
        return 0;
}

and this its the error that show, sorry it's so long.

cd /home/juan/catkin_ws/build/gps_pos && /usr/bin/cmake -E cmake_link_script CMakeFiles/prueba.dir/link.txt --verbose=1
/usr/bin/c++   -O3 -DNDEBUG   CMakeFiles/prueba.dir/src/prueba.cpp.o  -o /home/juan/catkin_ws/devel/lib/gps_pos/prueba -rdynamic /opt/ros/kinetic/lib/libroscpp.so -lboost_filesystem -lboost_signals /opt/ros/kinetic/lib/librosconsole.so /opt/ros/kinetic/lib/librosconsole_log4cxx.so /opt/ros/kinetic/lib/librosconsole_backend_interface.so -llog4cxx -lboost_regex /opt/ros/kinetic/lib/libxmlrpcpp.so /opt/ros/kinetic/lib/libroscpp_serialization.so /opt/ros/kinetic/lib/librostime.so /opt/ros/kinetic/lib/libcpp_common.so -lboost_system -lboost_thread -lboost_chrono -lboost_date_time -lboost_atomic -lpthread -lconsole_bridge -Wl,-rpath,/opt/ros/kinetic/lib 
CMakeFiles/prueba.dir/src/prueba.cpp.o: En la función `message_filters::Connection message_filters::Signal9<nav_msgs::Odometry_<std::allocator<void> >, sensor_msgs::LaserScan_<std::allocator<void> >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>::addCallback<boost::shared_ptr<nav_msgs::Odometry_<std::allocator<void> > const> const&, boost::shared_ptr<sensor_msgs::LaserScan_<std::allocator<void> > const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&>(boost::function<void (boost::shared_ptr<nav_msgs::Odometry_<std::allocator<void> > const> const&, boost::shared_ptr<sensor_msgs::LaserScan_<std::allocator<void> > const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&, boost::shared_ptr<message_filters::NullType const> const&)> const&)':
prueba.cpp:(.text._ZN15message_filters7Signal9IN8nav_msgs9Odometry_ISaIvEEEN11sensor_msgs10LaserScan_IS3_EENS_8NullTypeES8_S8_S8_S8_S8_S8_E11addCallbackIRKN5boost10shared_ptrIKS4_EERKNSC_IKS7_EERKNSC_IKS8_EESO_SO_SO_SO_SO_SO_EENS_10ConnectionERKNSB_8functionIFvT_T0_T1_T2_T3_T4_T5_T6_T7_EEE[_ZN15message_filters7Signal9IN8nav_msgs9Odometry_ISaIvEEEN11sensor_msgs10LaserScan_IS3_EENS_8NullTypeES8_S8_S8_S8_S8_S8_E11addCallbackIRKN5boost10shared_ptrIKS4_EERKNSC_IKS7_EERKNSC_IKS8_EESO_SO_SO_SO_SO_SO_EENS_10ConnectionERKNSB_8functionIFvT_T0_T1_T2_T3_T4_T5_T6_T7_EEE]+0x4d2): referencia a `message_filters::Connection::Connection(boost::function<void ()> const&)' sin definir
CMakeFiles/prueba.dir/src/prueba.cpp.o: En la función `message_filters::Synchronizer<message_filters::sync_policies::ExactTime<nav_msgs::Odometry_<std::allocator<void> >, sensor_msgs::LaserScan_<std::allocator<void> >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType> >::~Synchronizer()':
prueba.cpp:(.text._ZN15message_filters12SynchronizerINS_13sync_policies9ExactTimeIN8nav_msgs9Odometry_ISaIvEEEN11sensor_msgs10LaserScan_IS5_EENS_8NullTypeESA_SA_SA_SA_SA_SA_EEED2Ev[_ZN15message_filters12SynchronizerINS_13sync_policies9ExactTimeIN8nav_msgs9Odometry_ISaIvEEEN11sensor_msgs10LaserScan_IS5_EENS_8NullTypeESA_SA_SA_SA_SA_SA_EEED5Ev]+0x28): referencia a `message_filters::Connection::disconnect()' sin definir
CMakeFiles/prueba.dir/src/prueba.cpp.o: En la función `message_filters::Connection message_filters::SimpleFilter<nav_msgs::Odometry_<std::allocator<void> > >::registerCallback<ros::MessageEvent<nav_msgs::Odometry_<std::allocator<void> > const> const&>(boost::function<void (ros::MessageEvent<nav_msgs::Odometry_<std::allocator<void> > const> const&)> const&)':
prueba.cpp:(.text._ZN15message_filters12SimpleFilterIN8nav_msgs9Odometry_ISaIvEEEE16registerCallbackIRKN3ros12MessageEventIKS4_EEEENS_10ConnectionERKN5boost8functionIFvT_EEE[_ZN15message_filters12SimpleFilterIN8nav_msgs9Odometry_ISaIvEEEE16registerCallbackIRKN3ros12MessageEventIKS4_EEEENS_10ConnectionERKN5boost8functionIFvT_EEE]+0x310): referencia a `message_filters::Connection::Connection(boost::function<void ()> const&)' sin definir
CMakeFiles/prueba.dir/src/prueba.cpp.o: En la función `message_filters::Connection message_filters::SimpleFilter<sensor_msgs::LaserScan_<std::allocator<void> > >::registerCallback<ros::MessageEvent<sensor_msgs::LaserScan_<std::allocator<void> > const> const&> ...
(more)
2019-12-31 08:07:14 -0500 received badge  Popular Question (source)
2019-12-30 03:23:53 -0500 commented answer I have an error trying to subscribe to multiple topics, between them there are two of the same type, this is the error, please what can I do ?

Thank you!, published this tipic with a message type that had Header, use Odometry for this case and works well thanks.

2019-12-30 03:23:53 -0500 asked a question Hi, I want to use the message filter in this example , I tried to register callback from a class member function as in the following code:

Hi, For the example of message filter in this example , I tried to register callback from a class member function as in

2019-12-30 00:10:13 -0500 marked best answer I have an error trying to subscribe to multiple topics, between them there are two of the same type, this is the error, please what can I do ?

this is the code:

#! /usr/bin/env python
import serial
import rospy
import message_filters
import numpy as np

from sensor_msgs.msg import Imu
from nav_msgs.msg import Odometry
from std_msgs.msg import Float32


class adq_datos(object):
        def __init__(self):
                self.datos = 0

                self.pwm = message_filters.Subscriber('/PWM', Float32)
                self.encoder = message_filters.Subscriber('/enc_data', Odometry)
                self.gps = message_filters.Subscriber('/gps', Float32)
                self.imu = message_filters.Subscriber('/mti/sensor/imu_free', Imu)

                self.ts = message_filters.TimeSynchronizer([self.pwm, self.encoder, self.gps, self.imu], 10)
                self.ts.registerCallback(self.synchronize_data)
                rospy.spin()

        def synchronize_data(self, data):
                self.datos = data.pose.covariance[5]
                print self.datos

if __name__=='__main__':
        try:
                rospy.init_node('save_data',anonymous=True, disable_signals=True)
                print "Nodo Creado"
                cv = adq_datos()
        except rospy.ROSInterruptException:
                pass

this is the error that show

[ERROR] [1576621538.678741]: bad callback: <bound method Subscriber.callback of <message_filters.Subscriber object at 0x75b23850>>
Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
    cb(msg)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/message_filters/__init__.py", line 75, in callback
    self.signalMessage(msg)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/message_filters/__init__.py", line 57, in signalMessage
    cb(*(msg + args))
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/message_filters/__init__.py", line 216, in add
    my_queue[msg.header.stamp] = msg
AttributeError: 'Float32' object has no attribute 'header'