PX4 / PX4-SITL_gazebo-classic

Set of plugins, models and worlds to use with OSRF Gazebo Simulator in SITL and HITL.
http://dev.px4.io/simulation-gazebo.html
368 stars 787 forks source link

how to enable camera and take its feed #228

Closed chrismath closed 4 years ago

chrismath commented 6 years ago

I have been trying to enable camera in this simulator.I did make some changes in the cmake file but the there is no topic providing the camera output

EliaTarasov commented 6 years ago

Hey chrismath!

  1. What vehicle do you actually test?
  2. What camera do you want to use? (e.g. optical flow cam, vision cam, gimbal cam).

In general sitl_gazebo can output images to gazebo cam topic and to ros cam topic. So you may use gz topic -l for gazebo topics or rostopic list for ros topics.

chrismath commented 6 years ago

I was planning to do indoor navigation, I have been working with the iris quadrotor in the simulator. I want to use vision cam. But on running rostopic list there are no topics related to image_raw

EliaTarasov commented 6 years ago

iris_vision model do not use ros vision cam. Take a look at iris_fpv_cam instead. Use roslaunch px4 mavros_posix_sitl.launch vehicle:=iris_fpv_cam. I've just tested it and it works ok.

chrismath commented 6 years ago

Thank you EliaTarasov ill try it out.Sorry for the late reply

EliaTarasov commented 5 years ago

@chrismath any news on this issue?

chrismath commented 5 years ago

nope

EliaTarasov commented 5 years ago

Did you try and it didn't work out?

Veilkrand commented 5 years ago

I launch px4 mavros_posix_sitl.launch vehicle:=iris_fpv_cam from another launch file and the model loads and shows at Gazebo. However PX4 complains at start:

px4 starting.

INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
Error: Unknown model 'iris_fpv_cam'
etc/init.d-posix/rcS: 48: exit: Illegal number: -1
ERROR [px4] Startup script returned with return value: 512

What am I missing? Thanks!

EliaTarasov commented 5 years ago

@Veilkrand this can happen if your external launch file does not take into account that roslaunch px4 mavros_posix_sitl.launch command must be executed from src/Firmware directory.

Veilkrand commented 5 years ago

First I setup the globals in here:

#!/bin/bash
px4_dir=~/Firmware
#source $px4_dir/Tools/setup_gazebo.bash $px4_dir $px4_dir/build/posix_sitl_def$
source $px4_dir/Tools/setup_gazebo.bash $px4_dir $px4_dir/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$px4_dir
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$px4_dir/Tools/sitl_gazebo

And then I use this launch file:

<?xml version="1.0"?>
<launch>
  <include file="$(find px4)/launch/mavros_posix_sitl.launch">
    <arg name="vehicle" value="iris_fpv_cam" />
  </include>
  <node name="offb" pkg="offb" type="offb_node" output="screen"/>
</launch>

It finds the px4 package and the model. What am I doing wrong?

EliaTarasov commented 5 years ago

I will try to reproduce this tomorrow and will inform you on results. Thanks!

Veilkrand commented 5 years ago

I think I got what was the problem. If you change: <arg name="vehicle" value="iris_fpv_cam" /> Gazebo will load the right .sdf model but PX4 won't find the target with the name of the model. So you need to keep the name argument as iris, and change directly the sdf argument.

<arg name="sdf" value="$(find mavlink_sitl_gazebo)/models/$(arg my_model_name)/$(arg my_model_name).sdf"/>
EliaTarasov commented 5 years ago

Great! So the problem solved?

Veilkrand commented 5 years ago

It works for me. But I wonder why roslaunch px4 mavros_posix_sitl.launch vehicle:=iris_fpv_cam works for you. I should be missing something

nkhedekar commented 5 years ago

Following the instructions mentioned here and

I think I got what was the problem. If you change: <arg name="vehicle" value="iris_fpv_cam" /> Gazebo will load the right .sdf model but PX4 won't find the target with the name of the model. So you need to keep the name argument as iris, and change directly the sdf argument.

<arg name="sdf" value="$(find mavlink_sitl_gazebo)/models/$(arg my_model_name)/$(arg my_model_name).sdf"/>

it worked perfectly.

AlexWUrobot commented 1 year ago

I solve this by this ref link: https://ubungmachtdenmeistersite.wordpress.com/2022/11/23/tracking-ar-tags-in-ros/

If you want to install USB camera on Ubuntu 18.04, ROS Melodic, and OpenCV python 2.7

I search so many websites and find this two website is very useful.

https://varunagrawal.github.io/2017/10/23/ar-track/
http://projectsfromtech.blogspot.com/2017/09/tracking-ar-tags-with-ros-monocular.html

However, I follow the instruction of this two websites, but something cannot work.

In the end, I adjust the tracker.launch file like this below screenshot. Then I succeed in my drone onboard PC, Jetson TX1.

I also find you have to notice, if you using Ubuntu 20.04, the default python version is 3.6.

However, the ROS AR tracking code uses the python version is 2.7.

You may need to re-config cv-bridge or openCV to python 2.7, according to this link: https://stackoverflow.com/questions/49221565/unable-to-use-cv-bridge-with-ros-kinetic-and-python3?rq=1

image