𝖄𝕺🌎𝕿𝕽𝕺¥

𝖄𝕺🌎𝕿𝕽𝕺¥

𝕴 𝖉𝖔 𝖒𝖆𝖌𝖎𝖈
github

ROS1 基础及常用指令 笔记

ros#

roslaunch#

launch multiple ROS Nodes via launch files.

roslaunch {package name} {launch file}
roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch

rosnode#

display information about active ROS Nodes.

rosnode list

rosrun#

run executables within a ROS package.

rosrun {package name} {script name}
rosrun rqt_graph rqt_graph

rostopic#

display information about active ROS topics.

rostopic list
rostopic list | grep /camera     //filter this to show only topics related to '/camera'

rostopic info /{topic_name}
$ rostopic info /cmd_vel

<!-- echo:drill down into these elements of the message specifically and find out what their values are -->
$ rostopic echo /chatter      //shows the messages being published to the topic chatter
$ rostopic echo -h    // additional options
$ rostopic echo /chatter -n2      // 2 sets number of info

$ rostopic echo -c /odom      //odom

rostopic pub {topic_name} {message_type} {data}     //to call an action from the command-line.

rosmsg#

display information about all ROS messages that are available to use in a ROS application.

rosmsg info {Type}      //Type is get by 'rostopic info'
$ rosmsg info geometry_msgs/Twist

rosservice#

could get the Type, Type tells us the type of message this service uses. Rosrun then rosservice call, and both terminal will get the output. Rosrun get print if have set, rosservice call will return the response (e.g. response_signal, response_message)

rosservice list
rosservice info /{service_name}

$ rosservice info /move_service    //name should be 'service_name = "move_service"'
$ rosservice call /move_service[SPACE][TAB]

rossrv info#

Not useful for action.
show what the service request and response

rossrv info {Type}
$ rossrv info tuos_ros_msgs/SetBool

<!-- Example output -->

bool request_signal     <-- Request
---
bool response_signal    <-- Response (Parameter 1/2)
string response_message <-- Response (Parameter 2/2)

chmod#

make permission to Read or Write to it.

chmod +x publisher.py

catkin_create_pkg#

catkin_create_pkg week1_pubsub std_msgs rospy

catkin build#

catkin build week1_pubsub
source ~/.bashrc    //should run after build

roscore#

launch the ROS Master: The baseline nodes and programs that are required for ROS to function. re-launch the ROS Master.

roscore

backup#

wsl_ros backup

restore#

wsl_ros restore

eog#

open img by command line

eog .

Application#

server#

server implement first, then client
both server and client should have same topic name

Client#

request from client.py, response for server.py

Service#

......

Action#

rostopic#

  • rostopic list: to identify the action servers that are available on the network.
  • rostopic echo: to view the messages being published by a given action server.
  • rostopic pub: to call an action from the command-line.

get what params is required?#

  • rostopic info: get the info format of action server. copy the {Type}
  • rosmsg info {Type}

Step:#

  • initialize client as class or set as object
    include name, rate, params, client wait for server
    could have shotdown_ops

  • set feedback_callback function
    could print on panel
    this function of client will be called by server automatically, not by any function from itself.

  • set goal
    include send_goal function inside the client e.g. client.send_goal(self.goal, feedback_cb=self.feedback_callback)

  • main loop
    could have while
    could change the boolean then to shutdown_ops

  • shutdown_ops function
    should if condition then rospy.logwarn()
    should have result show inside the function

  • if __name__ == '__main__':
    may have try , except

Process:#

  • client ---goal---> server : only once
    rostopic pub {goal}[Tab][Space]

  • client <---feedback--- server : everytime have update

the callback function of client will be called by server automatically, not by any function of this client.

  • client <---status--- server

the status value will be judge and set by server, then send to client

  • client <---result--- server

could use client.get_result() to get the value in client.py

More#

from geometry_msgs.msg import Twist
Twist is Type
geometry_msgs is Package

topic-based: other nodes can understand

service: low risk, quick, operations or calculations

action: longer duration, could fail

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.