ethz-asl / rotors_simulator

RotorS is a UAV gazebo simulator
1.2k stars 756 forks source link

Unstable flight control #692

Closed Faraz441 closed 2 years ago

Faraz441 commented 2 years ago

I am new in ROS project. I want to control my drone with joystick and hovering by using RotorS simulation. For this purpose, I added the node of joystick from this file mav_with_joy. Launch to mav_hovering_example_with_vi_sensor. Launch. It seems my node is working, but when I press the button of joystick it moves a little right, left and forward, but automatically comes to same position but my yaw is not working.When I increase my throttle fully then it becomes more unstable.It moves different direction without controlling or pressing my button on joystick. Any idea, Please help me. Here is my added joystick file.

<launch>
  <arg name="mav_name" default="firefly"/>
  <arg name="world_name" default="basic"/>
  <arg name="enable_logging" default="false" />
  <arg name="enable_ground_truth" default="true" />
  <arg name="log_file" default="$(arg mav_name)" />

  <env name="GAZEBO_MODEL_PATH" value="${GAZEBO_MODEL_PATH}:$(find rotors_gazebo)/models"/>
  <env name="GAZEBO_RESOURCE_PATH" value="${GAZEBO_RESOURCE_PATH}:$(find rotors_gazebo)/models"/>
                                       <!-- Start Gazebo -->

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find rotors_gazebo)/worlds/$(arg world_name).world" />
    <!-- <arg name="debug" value="true"/> -->
    <arg name="paused" value="true"/>
    <!-- <arg name="gui" value="false"/> -->
    <!-- <arg name="verbose" value="true"/> -->
  </include>
                                     <!-- Spawn MAV -->

   <group ns="$(arg mav_name)">
    <include file="$(find rotors_gazebo)/launch/spawn_mav.launch">
      <arg name="mav_name" value="$(arg mav_name)" />
      <arg name="model" value="$(find rotors_description)/urdf/mav_with_vi_sensor.gazebo" />
      <arg name="enable_logging" value="$(arg enable_logging)" />
      <arg name="enable_ground_truth" value="$(arg enable_ground_truth)" />
      <arg name="log_file" value="$(arg log_file)"/>
    </include>
                                      <!-- Position control -->
    <node name="lee_position_controller_node" pkg="rotors_control" type="lee_position_controller_node" output="screen">
      <rosparam command="load" file="$(find rotors_gazebo)/resource/lee_controller_$(arg mav_name).yaml" />
      <rosparam command="load" file="$(find rotors_gazebo)/resource/$(arg mav_name).yaml" />
      <remap from="odometry" to="odometry_sensor1/odometry" />
    </node>       
                                         <!-- hovering control -->       
    <node name="hovering_example" pkg="rotors_gazebo" type="hovering_example" output="screen"/>
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
   </group>
                                           <!--  joystick-->
 <group ns="$(arg mav_name)">
    <node name="joy_node" pkg="joy" type="joy_node" />
    <node name="rotors_joy_interface" pkg="rotors_joy_interface" type="rotors_joy_interface" />
    <node name="roll_pitch_yawrate_thrust_controller_node" pkg="rotors_control" type="roll_pitch_yawrate_thrust_controller_node"        output="screen">
      <rosparam
        command="load" file="$(find rotors_gazebo)/resource/roll_pitch_yawrate_thrust_controller_$(arg mav_name).yaml" />
      <rosparam command="load" file="$(find rotors_gazebo)/resource/$(arg mav_name).yaml" />
      <remap from="odometry" to="odometry_sensor1/odometry" />
    </node>
  </group>
</launch>