스터디 노트
Published 2021. 8. 9. 21:03
ROS 개인정리 maengkyun/Pixhawk

spin()은 콜백만 처리(Blocking)

spinOnce()는 한번 콜백을 처리하고 넘어간다. (Non-blocking)

rate.sleep()은 무한루프에서 설정한 주기를 맞추기

roslaunch는 하나 이상의 정해진 노드를 실행시킬 때 사용

-노드를 실행할 때 패키지의 파라미터나 노드 이름변경, 노드 네임스페이스 설정 ROS ROOT, PACKAGE PATH 설정, 환경변수 변경 등의 옵션을 붙일 수 있다.

<arg name="fcu_url" default= "udp://:14540@127.0.0.1:14557" />
<arg name="gcs_url" default="" />
<arg name="tgt_system" default="1" />
<arg name="tgt_component" default="1" />

<node name="mavros" pkg="mavros" type="mavros_node" output="screen">
	<param name="fcu_url" value="$(arg fcu_url)" />
	<param name="gcs_url" value="$(arg gcs_url)" />
	<param name="target_system_id" value="$(arg tgt_system)" />
	<param name="target_component_id" value="$(arg tgt_component)" />

	<!--rosparam command="load" file="$(find mavros)/launch/px4_blacklist.yaml"-->

	<!-- enable heartbeat send and reduce timeout -->
	<param name="conn_heartbeat" value="5.0" />
	<param name="conn_timeout" value="5.0" />
	<!-- automatically start mavlink on USB -->
	<param name="startup_px4_usb_quirk" value="true" />
	<param name="mocap/use_tf" value="true"/>
	<param name="mocap/use_pose" value="false"/>
</node>

다른 패키지에서 다음과 같은 형식으로 호출 mavros를 호출하고 mavros setpoint_position topic에 메시지를 넘기기 위한 노드실행

<node name="pub_setpoints" pkg="modudculab_ros" type="pub_setpoints_pos" output="screen">

해당 소스코드는 modudculab_ros 코드

 

ex>

<launch>
	<node pkg="ros_tutorial_topic" type="topic_publisher" name="topic_publisher1">
    <node pkg="ros_tutorial_topic" type="topic_publisher" name="topic_publisher2">
    <node pkg="ros_tutorial_topic" type="topic_subscriber" name="topic_subscriber1">
    <node pkg="ros_tutorial_topic" type="topic_subscriber" name="topic_subscriber2">
</launch>

 

 

 

------------------------------------------------------------------------------------

 

int loopRate = 500;
geometry_msgs::PoseStamped msg_vicon_pose;

void Callback_fcu_pose(const geometry_msgs::PoseStamped msg_fcu_pose_dummy)
{
    ROS_INFO("Got data : %f, %f, %f", msg_fcu_pose_dummy.pose.position.x, msg_fcu_pose_dummy.pose.position.y, msg_fcu_pose_dummy.pose.position.z);
}

 

rospy.Subscriber("/mavros/state", State, self.state_callback) # Pulling information for mavros/state and sending it to state callback
      rospy.Subscriber("/mavros/global_position/global", NavSatFix, self.gps_callback) # Pulling GPS information and will not access callback to make gps_read statement true if NavSatFix = -1  
      ##rospy.Subscriber("cv_node",CV,self.cv_callback)
      local_position_subscribe = rospy.Subscriber('/mavros/local_position/pose', PoseStamped, self.pose_sub_callback) # Getting current position and sets current_pose to subscribed value
      local_position_pub = rospy.Publisher('/mavros/setpoint_position/local', PoseStamped, queue_size = 10) 

 

 

rostopic list

rostopic type [list] ex /laser/scan

rosmsg show [type] ex sensor_msgs/LaserScan

-----------------------------------------------------------------------

#include "sensor_msgs/LaserScan.h"

void state_cb2(const sensor_msgs::LaserScan::ConstPtr& msg){

int ranges = msg->ranges.size();

ds_data.ranges.resize(ranges);

for(int i = 0; i<ranges; ++i){

ds_data.ranges[i]=msg->ranges[i]+1;

 

ROS_INFO("distance: %4.2f\n",ds_data.ranges[i]);

}

}

 

ros::Subscriber distance_sub = n.subscribe<sensor_msgs::LaserScan>("/laser/scan",1000,state_cb2);

 

 

https://github.com/mavlink/mavros/issues/786

 

"/mavros/vision_pose/pose" not adjusting x,y value in "/mavros/local_position/pose" · Issue #786 · mavlink/mavros

Hi, I'm trying to publish position topic through "/mavros/vision_pose/pose" topic. And, see how "/mavros/local_position/pose" converges to pose by subscribing the topic. I&#...

github.com

https://uenota.github.io/px4_teleop/px4__teleop__com_8cpp_source.html

 

PX4 Teleop: src/px4_teleop_com.cpp Source File

void takeoff(ros::ServiceClient &client, mavros_msgs::State &state, geometry_msgs::PoseStamped &lpos, sensor_msgs::NavSatFix &hp, double height) Take off vehicle. void cmd_vel(ros::Publisher &pub, ros::ServiceClient &client, mavros_msgs::State &state, doub

uenota.github.io

https://github.com/mavlink/mavros/issues/1158

 

Setpoint_Position/Local Position Control: Relative Positioning · Issue #1158 · mavlink/mavros

Issue details Hello Everyone, I am attempting to control a quadcopter‘s position using a camera to move to a target using the difference between the current location of the drone and the centroid o...

github.com

https://github.com/microsoft/AirSim/blob/master/docs/build_linux.md#faqs

 

profile

스터디 노트

@myeongkyun

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!