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

Dylan's profile - activity

2022-10-12 04:33:27 -0500 marked best answer Merge two topics - get information of 2 different topics

I'm simulating in Gazebo a control with noise. The model is ideal, so there's no noise. That's why I created a topic called vel_noise where some noise is published. In another topic, called vel_control, the control of my vehicle is implemented (based on position measurements).

Both topics are Twist, i.e, they have 3 linear velocities and 3 angular velocities.

Now, I want to create a node that subscribes to both topics, add the velocities of each one and publish that information in another topic called cmd_vel.

I found that there's something called message_filters that could do this, but I couldn't make that work. Can anyone please help me, please?

My idea is to have something like this:

vel_merged.linear.x = vel_noise.linear.x + vel_control.linear.x
vel_merged.linear.y = vel_noise.linear.y + vel_control.linear.y
vel_merged.linear.z = vel_noise.linear.z + vel_control.linear.z

(I'm using Python)

I tried something like this, using message filters:

#!/usr/bin/env python
import message_filters
import rospy
from geometry_msgs.msg import Twist

class main_control_noise():  

    def __init__(self):

        image_sub = message_filters.Subscriber('vel_control', Twist)
        info_sub = message_filters.Subscriber('vel_noise', Twist)

        ts = message_filters.TimeSynchronizer([image_sub, info_sub], 10)
        ts.registerCallback(callback)
        #rospy.spin()


        return

    def callback(vel_control, vel_noise):
      # Solve all of perception here...
      print "aa"


if __name__ == '__main__':

    rospy.init_node('control_noise', anonymous=True)

    try:
        rate = rospy.Rate(100) #este rate creo que me da cada cuanto entra al while not de abajo

        while not rospy.is_shutdown():

            print "a"
            m_noise = main_control_noise()
            rate.sleep()

    except rospy.ROSInterruptException:
        rospy.loginfo("Node terminated.")

But I don't know a lot of things:

1) What information do I have to give to message_filters.Subscriber? I want to subscribe those 2 nodes (names: vel_control and vel_noise), and the "output" of those topics would be a Twist message: 3 velocities and 4 orientations. I don' know if message_filters.Subscriber('vel_control', Twist) is OK

2) I don't know what do I have to put inside the callback

For example, the vel_noise script is:

class main_noise():

    def __init__(self):

        self.velocity_publisher = rospy.Publisher('/vel_noise', Twist, queue_size=10)

        vel_msg = Twist()

        global counter

        sine_noise = math.sin(counter*math.pi/180)

        vel_msg.linear.x = sine_noise/5

        if counter % 2 == 0:
            vel_msg.linear.y = sine_noise
        else:
            vel_msg.linear.y = -sine_noise

        print "Counter: ", counter
        print "Sin: ", vel_msg.linear.x
        self.velocity_publisher.publish(vel_msg)

        return


if __name__ == '__main__':

    rospy.init_node('noise', anonymous=True)

    global counter
    counter = 0

    try:
        rate = rospy.Rate(100) #100 Hz

        while not rospy.is_shutdown():

            print "a"
            counter = counter+1
            m_noise = main_noise()
            rate.sleep()

    except rospy.ROSInterruptException:
        rospy.loginfo("Node terminated.")
2022-10-12 04:28:55 -0500 marked best answer Using this package with a different purpose [Land a quadcopter]

I need to land my quadcopter on predefined tag. I’m using ARTags, so I know the position of the target when I see it with my camera. But I need to implement a better control, so I decided to use an Extended Kalman Filter (EKF) that uses the information of the camera but also from the gyroscope, magnetometer, etc.

I found this package called tum_ardrone that does a SLAM and then the EKF. What I would need is to use the first two nodes (drone_stateestimation and maybe drone_autopilot), but I don’t want to use the drone_gui node because it needs the final position to be send by a joystick or keyboard, and I need that position to be the position or my tag. I mean, I want the final position to be read in a specific topic where I can store the position of ny tag (or maybe you have a better solution)

2022-10-12 04:27:28 -0500 received badge  Famous Question (source)
2022-06-07 04:25:33 -0500 received badge  Famous Question (source)
2021-09-10 06:20:56 -0500 received badge  Famous Question (source)
2021-08-31 09:14:18 -0500 received badge  Notable Question (source)
2021-08-31 09:14:18 -0500 received badge  Famous Question (source)
2021-06-07 03:18:44 -0500 received badge  Notable Question (source)
2021-03-12 09:18:50 -0500 received badge  Student (source)
2021-03-12 09:18:15 -0500 received badge  Famous Question (source)
2021-03-12 09:18:15 -0500 received badge  Notable Question (source)
2020-12-18 13:38:51 -0500 marked best answer [SVO] Get pose for a long time

I'm using the SVO package. I already calibrated my bottom camera (using the Pinhole model, with the specs of camera_calibration modified to be in the format expected) and modified my .launch file so it gets the images from the output of the image_proc (i.e, grayscale and rectified), but it's very difficult to obtain the pose of the camera over a long period of time.

This is my .launch file:

<launch>

    <node pkg="svo_ros" type="vo" name="svo" clear_params="true" output="screen">

        <!-- Camera topic to subscribe to -->
        <param name="cam_topic" value="/ardrone/bottom/image_rect" type="str" />

        <!-- Camera calibration file -->
        <rosparam file="$(find svo_ros)/param/ardrone_bottom.yaml" />

        <!-- Default parameter settings: choose between vo_fast and vo_accurate -->
        <rosparam file="$(find svo_ros)/param/vo_fast.yaml" />

    </node>

</launch>

and this is how I use the image_proc package:

ROS_NAMESPACE=/ardrone/bottom rosrun image_proc image_proc

rosnode info svo gives this output:

Node [/svo]
Publications: 
 * /rosout [rosgraph_msgs/Log]
 * /svo/dense_input [svo_msgs/DenseInput]
 * /svo/image [sensor_msgs/Image]
 * /svo/image/compressed [sensor_msgs/CompressedImage]
 * /svo/image/compressed/parameter_descriptions [dynamic_reconfigure/ConfigDescription]
 * /svo/image/compressed/parameter_updates [dynamic_reconfigure/Config]
 * /svo/image/compressedDepth [sensor_msgs/CompressedImage]
 * /svo/image/compressedDepth/parameter_descriptions [dynamic_reconfigure/ConfigDescription]
 * /svo/image/compressedDepth/parameter_updates [dynamic_reconfigure/Config]
 * /svo/image/theora [theora_image_transport/Packet]
 * /svo/image/theora/parameter_descriptions [dynamic_reconfigure/ConfigDescription]
 * /svo/image/theora/parameter_updates [dynamic_reconfigure/Config]
 * /svo/info [svo_msgs/Info]
 * /svo/keyframes [visualization_msgs/Marker]
 * /svo/points [visualization_msgs/Marker]
 * /svo/pose [geometry_msgs/PoseWithCovarianceStamped]
 * /tf [tf2_msgs/TFMessage]

Subscriptions: 
 * /ardrone/bottom/image_rect [sensor_msgs/Image]
 * /svo/remote_key [unknown type]

Services: 
 * /svo/get_loggers
 * /svo/image/compressed/set_parameters
 * /svo/image/compressedDepth/set_parameters
 * /svo/image/theora/set_parameters
 * /svo/set_logger_level


contacting node http://juan:34907/ ...
Pid: 19891
Connections:
 * topic: /rosout
    * to: /rosout
    * direction: outbound
    * transport: TCPROS
 * topic: /tf
    * to: /rqt_gui_py_node_20048
    * direction: outbound
    * transport: TCPROS
 * topic: /ardrone/bottom/image_rect
    * to: /ardrone/bottom/image_proc (http://juan:40291/)
    * direction: inbound
    * transport: TCPROS

When I run roslaunch svo_ros live.launch this is the output:

... logging to /home/juan/.ros/log/1b6a94be-ab2c-11e9-84b5-68ecc55d6600/roslaunch-juan-19873.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://juan:45331/

SUMMARY
========

CLEAR PARAMETERS
 * /svo/

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14
 * /svo/cam_cx: 254.861406985
 * /svo/cam_cy: 132.774654931
 * /svo/cam_d0: 0.0254329004542
 * /svo/cam_d1: 0.00484972274251
 * /svo/cam_d2: -0.00316468715909
 * /svo/cam_d3: -0.0168351839378
 * /svo/cam_fx: 724.628466389
 * /svo/cam_fy: 722.57992602
 * /svo/cam_height: 360
 * /svo/cam_model: Pinhole
 * /svo/cam_topic: /ardrone/bottom/i...
 * /svo/cam_width: 640
 * /svo/grid_size: 30
 * /svo/loba_num_iter: 0
 * /svo/max_n_kfs: 10

NODES
  /
    svo (svo_ros/vo)

ROS_MASTER_URI=http://localhost:11311

process[svo-1]: started with pid [19891]
create vo_node
[ WARN] [1563654227.665696970]: Cannot find value for parameter: svo/publish_img_pyr_level, assigning default: 0
[ WARN] [1563654227.666169164]: Cannot find value for parameter: svo/publish_every_nth_img, assigning default: 1
[ WARN] [1563654227.666518905]: Cannot find value for parameter: svo/publish_every_nth_dense_input, assigning default: 1
[ WARN] [1563654227.667630230]: Cannot find value for parameter: svo/publish_world_in_cam_frame, assigning default: 1
[ WARN] [1563654227.668068619]: Cannot find value for parameter: svo ...
(more)
2020-12-18 13:32:41 -0500 marked best answer Create world frame

I need to use the SVO package for Visual Odometry, so I need the world frame because it gives me the pose relative to that frame, but I'm not using it so I need to create it.

This is a simplified tf_frame graph of my project:

image description

and I would like to create a broadcast between odom and world, or between any frame and world. What do you suggest?

Edit: with the help of PeteBlackerThe3rd, now the rqt_tf_tree is:

image description

2020-11-17 20:20:11 -0500 received badge  Notable Question (source)
2020-11-17 20:20:11 -0500 received badge  Popular Question (source)
2020-11-17 20:20:11 -0500 received badge  Famous Question (source)
2020-09-14 05:08:59 -0500 received badge  Famous Question (source)
2020-09-14 05:08:59 -0500 received badge  Notable Question (source)
2020-09-14 00:12:20 -0500 received badge  Famous Question (source)
2020-09-02 10:01:17 -0500 received badge  Famous Question (source)
2020-07-14 02:25:04 -0500 received badge  Popular Question (source)
2020-06-14 10:47:17 -0500 received badge  Famous Question (source)
2020-06-14 10:47:17 -0500 received badge  Notable Question (source)
2020-05-19 14:30:40 -0500 received badge  Famous Question (source)
2020-05-15 15:23:06 -0500 commented question From /cmd_vel to pwm signals of the thrusters

@gvdhoorn can you please help me?

2020-05-11 01:17:57 -0500 edited question Measurements of IMU (accelerometer and gyroscope) are drifted or with too much error

Measurements of IMU (accelerometer and gyroscope) are drifted or with too much error I placed my drone on a table (i.e,

2020-05-11 01:14:13 -0500 asked a question Measurements of IMU (accelerometer and gyroscope) are drifted or with too much error

Measurements of IMU (accelerometer and gyroscope) are drifted or with too much error I placed my drone on a table (i.e,

2020-04-09 06:04:00 -0500 received badge  Famous Question (source)
2020-04-05 13:18:32 -0500 received badge  Notable Question (source)
2020-02-25 12:32:09 -0500 asked a question Move nodes in rqt_graph

Move nodes in rqt_graph I have to put a graph from rqt_graph in my Thesis, but it's width is too big and it's impossible

2019-12-16 07:06:30 -0500 received badge  Popular Question (source)
2019-12-15 13:51:00 -0500 commented question From /cmd_vel to pwm signals of the thrusters

Sorry, I thought it was the same for any vehicle. I edited the main post. Thanks

2019-12-15 13:50:36 -0500 edited question From /cmd_vel to pwm signals of the thrusters

From /cmd_vel to pwm signals of the thrusters Using the /cmd_vel topic I can send velocities to my quadcopter, but how i

2019-12-15 12:50:12 -0500 asked a question From /cmd_vel to pwm signals of the thrusters

From /cmd_vel to pwm signals of the thrusters Using the /cmd_vel topic I can send velocities to my quadcopter, but how i

2019-12-08 02:08:40 -0500 received badge  Famous Question (source)
2019-11-01 15:37:49 -0500 received badge  Popular Question (source)
2019-11-01 15:37:49 -0500 received badge  Notable Question (source)
2019-10-30 15:42:11 -0500 received badge  Famous Question (source)
2019-10-16 03:56:48 -0500 received badge  Notable Question (source)
2019-10-02 12:14:37 -0500 received badge  Popular Question (source)
2019-09-27 06:05:36 -0500 commented question Camera calibrator for monocular camera with 320x240 resolution

I have a setcamerainfo.h like this file but I don't know how the parameters height and width

2019-09-25 02:51:47 -0500 commented question Camera calibrator for monocular camera with 320x240 resolution

@Jari can you please help me? I really need to solve this

2019-09-25 02:51:27 -0500 received badge  Popular Question (source)
2019-09-21 17:10:21 -0500 commented question Camera calibrator for monocular camera with 320x240 resolution

I'm using the ardrone_autonomy. I have an AR Drone 2.0 and I'm using the bottom camera

2019-09-21 10:02:21 -0500 asked a question Camera calibrator for monocular camera with 320x240 resolution

Camera calibrator for monocular camera with 320x240 resolution I need to use the camera_calibration package for a camera

2019-09-11 21:16:27 -0500 received badge  Notable Question (source)
2019-08-22 18:26:51 -0500 commented question Subscribe to 2 topics and store outputs (different frequencies?)

that's what I did. The reference value is updated at 20 Hz and navdata at 200 Hz, and I send a new velocity at 200 Hz

2019-08-22 16:57:08 -0500 received badge  Notable Question (source)
2019-08-22 16:46:02 -0500 edited question Subscribe to 2 topics and store outputs (different frequencies?)

Subscribe to 2 topics and store outputs (different frequencies?) I have 2 topics: /vel_desired and /ardrone/navdata. The

2019-08-22 16:45:10 -0500 commented question Subscribe to 2 topics and store outputs (different frequencies?)

@usamamaq this is what I did and I think it works, but it doesn't print 10 message of the topic published at 200 Hz and