Change the wind speed when the gazebo environment is running

Do make px4_sitl gazebo_iris and I want to control the wind direction and wind speed at will.

When I looked for gazebo_wind_plugin

physics_msgs::msgs::Wind wind_msg is used in gazebo_motor_model, and wind_msg is used in gazebo_motor_model

wind_vel_ = ignition::math::Vector3d(msg->velocity().x(),
msg->velocity().y(),
msg->velocity().z());
I checked that wind_vel_ enters Vector3d in this way.

So what I thought was that if I put the value I wanted in wind_msg, I could control the wind

But I don’t have a site to refer to how to implement this

Help me

By “at will” you mean you want to very them at runtime? Then yes, I guess you’d have to publish the code yourself. And AFAIK (but I could be wrong) there isn’t a command line tool letting you do that. You’d have to make your own C++ application and link the Gazebo libraries.

Otherwise, if a static, custom value wind is good enough for you, you could type in your desired value in the .xml file, as you show it on the left.

Thank you for your answer. The content may have been strange using the translator, but thank you for your understanding.

I saw the link you left and it feels difficult because I’m still a beginner. But I think it’ll be possible if you refer to the link you sent me. And I also looked it up, but I felt that I would have to write the code eventually to inject the wind in real time.

If there is any other way, please feel free to let me know. Any wrong way would be fine.

Oh, if I do a rostopic list, world_wind doesn’t come out, how can I make it come out in a rostopic? world_wind comes out only when I do gz topic -l

rostopic list

/clock
/cmd_vel
/diagnostics
/e_stop
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/performance_metrics
/gazebo/set_link_state
/gazebo/set_model_state
/husky_velocity_controller/cmd_vel
/husky_velocity_controller/cmd_vel_out
/husky_velocity_controller/odom
/husky_velocity_controller/parameter_descriptions
/husky_velocity_controller/parameter_updates
/imu/data
/imu/data/accel/parameter_descriptions
/imu/data/accel/parameter_updates
/imu/data/bias
/imu/data/rate/parameter_descriptions
/imu/data/rate/parameter_updates
/imu/data/yaw/parameter_descriptions
/imu/data/yaw/parameter_updates
/joint_states
/joy_teleop/cmd_vel
/joy_teleop/joy
/joy_teleop/joy/set_feedback
/kb_teleop/cmd_vel
/mavlink/from
/mavlink/gcs_ip
/mavlink/to
/mavros/adsb/send
/mavros/adsb/vehicle
/mavros/battery
/mavros/cam_imu_sync/cam_imu_stamp
/mavros/camera/image_captured
/mavros/cellular_status/status
/mavros/companion_process/status
/mavros/distance_sensor/rangefinder_pub
/mavros/distance_sensor/rangefinder_sub
/mavros/esc_info
/mavros/esc_status
/mavros/esc_telemetry
/mavros/estimator_status
/mavros/extended_state
/mavros/fake_gps/mocap/pose
/mavros/geofence/waypoints
/mavros/global_position/compass_hdg
/mavros/global_position/global
/mavros/global_position/gp_lp_offset
/mavros/global_position/gp_origin
/mavros/global_position/local
/mavros/global_position/raw/fix
/mavros/global_position/raw/gps_vel
/mavros/global_position/raw/satellites
/mavros/global_position/rel_alt
/mavros/global_position/set_gp_origin
/mavros/gps_input/gps_input
/mavros/gps_rtk/rtk_baseline
/mavros/gps_rtk/send_rtcm
/mavros/gpsstatus/gps1/raw
/mavros/gpsstatus/gps1/rtk
/mavros/gpsstatus/gps2/raw
/mavros/gpsstatus/gps2/rtk
/mavros/home_position/home
/mavros/home_position/set
/mavros/imu/data
/mavros/imu/data_raw
/mavros/imu/diff_pressure
/mavros/imu/mag
/mavros/imu/static_pressure
/mavros/imu/temperature_baro
/mavros/imu/temperature_imu
/mavros/landing_target/lt_marker
/mavros/landing_target/pose
/mavros/landing_target/pose_in
/mavros/local_position/accel
/mavros/local_position/odom
/mavros/local_position/pose
/mavros/local_position/pose_cov
/mavros/local_position/velocity_body
/mavros/local_position/velocity_body_cov
/mavros/local_position/velocity_local
/mavros/log_transfer/raw/log_data
/mavros/log_transfer/raw/log_entry
/mavros/mag_calibration/report
/mavros/mag_calibration/status
/mavros/manual_control/control
/mavros/manual_control/send
/mavros/mission/reached
/mavros/mission/waypoints
/mavros/mocap/pose
/mavros/mount_control/command
/mavros/mount_control/orientation
/mavros/mount_control/status
/mavros/nav_controller_output
/mavros/obstacle/send
/mavros/odometry/in
/mavros/odometry/out
/mavros/onboard_computer/status
/mavros/param/param_value
/mavros/play_tune
/mavros/radio_status
/mavros/rallypoint/waypoints
/mavros/rangefinder/rangefinder
/mavros/rc/in
/mavros/rc/out
/mavros/rc/override
/mavros/setpoint_accel/accel
/mavros/setpoint_attitude/cmd_vel
/mavros/setpoint_attitude/thrust
/mavros/setpoint_position/global
/mavros/setpoint_position/global_to_local
/mavros/setpoint_position/local
/mavros/setpoint_raw/attitude
/mavros/setpoint_raw/global
/mavros/setpoint_raw/local
/mavros/setpoint_raw/target_attitude
/mavros/setpoint_raw/target_global
/mavros/setpoint_raw/target_local
/mavros/setpoint_trajectory/desired
/mavros/setpoint_trajectory/local
/mavros/setpoint_velocity/cmd_vel
/mavros/setpoint_velocity/cmd_vel_unstamped
/mavros/state
/mavros/statustext/recv
/mavros/statustext/send
/mavros/sys_status
/mavros/terrain/report
/mavros/time_reference
/mavros/timesync_status
/mavros/trajectory/desired
/mavros/trajectory/generated
/mavros/trajectory/path
/mavros/tunnel/in
/mavros/tunnel/out
/mavros/vfr_hud
/mavros/vision_pose/pose
/mavros/vision_pose/pose_cov
/mavros/wind_estimation
/move_base_simple/goal
/navsat/fix
/navsat/fix/position/parameter_descriptions
/navsat/fix/position/parameter_updates
/navsat/fix/status/parameter_descriptions
/navsat/fix/status/parameter_updates
/navsat/fix/velocity/parameter_descriptions
/navsat/fix/velocity/parameter_updates
/navsat/vel
/odometry/filtered
/rosout
/rosout_agg
/set_pose
/tf
/tf_static
/twist_marker_server/cmd_vel
/twist_marker_server/feedback
/twist_marker_server/update
/twist_marker_server/update_ful

gz topic -l

/gazebo/default/octocopter3/mag
/gazebo/default/octocopter3/motor_speed/0
/gazebo/default/octocopter3/motor_speed/1
/gazebo/default/octocopter3/motor_speed/2
/gazebo/default/octocopter3/motor_speed/3
/gazebo/default/octocopter3/motor_speed/4
/gazebo/default/octocopter3/motor_speed/5
/gazebo/default/octocopter3/motor_speed/6
/gazebo/default/octocopter3/motor_speed/7
/gazebo/default/octocopter3/px4flow/link/opticalFlow
/gazebo/default/octocopter3/rotor_1/wrench
/gazebo/default/octocopter3/rotor_2/wrench
/gazebo/default/octocopter3/rotor_3/wrench
/gazebo/default/octocopter3/rotor_4/wrench
/gazebo/default/octocopter3/rotor_5/wrench
/gazebo/default/octocopter3/rotor_6/wrench
/gazebo/default/octocopter3/rotor_7/wrench
/gazebo/default/octocopter3/rotor_8/wrench
/gazebo/default/octocopter3/vision_odom
/gazebo/default/physics
/gazebo/default/physics/contacts
/gazebo/default/playback_control
/gazebo/default/pose/info
/gazebo/default/pose/local/info
/gazebo/default/pose/modify
/gazebo/default/request
/gazebo/default/response
/gazebo/default/roads
/gazebo/default/scene
/gazebo/default/selection
/gazebo/default/sensor
/gazebo/default/skeleton_pose/info
/gazebo/default/sky
/gazebo/default/undo_redo
/gazebo/default/user_camera/joy_pose
/gazebo/default/user_camera/joy_twist
/gazebo/default/user_camera/pose
/gazebo/default/user_cmd
/gazebo/default/user_cmd_stats
/gazebo/default/visual
/gazebo/default/wind
/gazebo/default/world_control
/gazebo/default/world_stats
/gazebo/default/world_wind
/gazebo/motor_failure_num33
/gazebo/performance_metrics
/gazebo/server/control
/gazebo/world/modify

It wasn’t obvious to me when I was a beginner either, but the list of ROS topics and the list of Gazebo topics are two different things. ROS and Gazebo, however close they are, are two different programs and don’t share topics.
And as far as I know, Gazebo doesn’t offer a nice command line tool to manually publish topics in real time, like ROS does.

So one solution is to write a C++ program that will use the Gazebo libraries and make it publish a topic.

Another way to do it, is to include the ROS libraries in a Gazebo plugin and have it read a ROS topic. So instead of reading wind input from the Gazebo wind_msg, you could read from a ROS my_wind_msg topic.

I had done something similar here, but it’s been a long time since. I’m sure the exact way to include the libraries has changed a bit, so you’ll have to brush up.

Then again, something like this ros_gz_bridge might be a much easier solution, but I haven’t tried it.

Thank you again for your response.

I thought it was the right way to do it, so I’m studying now. Thank you for your help.

I don’t know if you’ll answer, but if I have any questions later, I’ll ask. Thank you.

1 Like