ROS学习(一)

ROS学习笔记

ROS初次实践

启动ros小海龟

1
2
3
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

1720418580780

创建工作空间

1
2
3
4
5
6
7
8
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace

sudo echo "source ~/catkin_ws/setup.bash" >> ~/.bashrc
source ~/.bashrc

catkin_make

1720418935125

创建功能包

1
2
3
4
5
6
cd ./src
catkin_create_pkg hellowword std_msgs rospy roscpp

cd..
catkin_make
source ./devel/setup.sh

1720419804547

话题编程

1
2
3
4
5
pub = rospy.Publisher( 'chatter' ,String, queue size=10)
pub. publish(hello_str)


rospy. Subscriber( ' chatter' ,String, callback)

1720420322056

服务编程

1
2
3
4
5
6
7
8
9
10
ros::NodeHandle n;
ros::ServiceServer service= n. advertiseservice( "add two ints",add);



ros::NodeHandle n;
ros::ServiceClient client= n. serviceClient<learningcommunication::AddTwoInts>( "add two ints");
learning_communication::AddTwoInts srv;
srv.request.a =atoll(argv[1]) ;
srv.request.b =atoll(argv[2]) ;

1720420776977

动作编程

1
2
3
4
5
6
7
8
9
10
11
12
#客户端
self._ac = actionlib.SimpleActionClient('wash_dishes', WashDishesAction)
self._ac.send_goal(goal, feedback_cb=self.feedback_callback)
self._ac.cancel_goal()
result = self._ac.get_result()
#服务端
self._as = actionlib.SimpleActionServer('wash_dishes', WashDishesAction, execute_cb=self.execute_cb, auto_start=False)
self._as.start()
self._as.set_preempted()
self._as.publish_feedback(feedback)
self._as.set_succeeded(result)

1720421132058

关键组件

launch文件

通知启动多个进程,并给其添加执行参数
1720421265726

tf坐标变换

1
2
roslaunch turtle_tf turtle_tf_demo.launch
rosrun tf view_frames

1720421570296

QT工具箱

1720421728461

rviz可视化

1720421798117

gazebo仿真

1720421881705

Author

Daniel Niu

Posted on

2024-07-08

Updated on

2024-09-27

Licensed under

Comments