ROS General - ashBabu/Utilities GitHub Wiki
Set the node as anonymous by changing the line:
rospy.init_node("counter_publisher")
to:
rospy.init_node("counter_publisher", anonymous=True)
This would spawn as many “counter_publisher” nodes as you want, each one publishing on the “/counter” topic.
- The example can be found here
-
Action client not connected;Controller spawner could not find the expected ROS controller interface
These issues are mainly because of the namespace in the controllers.yaml file and the libgazebo_ros_control package
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"> <!-- libgazebo_ros_control.so is generated in devel/lib after compilation -->
<robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
<legacyModeNS>true</legacyModeNS>
<robotNamespace>${arm_type}</robotNamespace>
</plugin>
</gazebo>If the controllers.yaml file is in namespace scara_arm as shown below, then ${arm_type} should be scara_arm as well
scara_arm:
position_joint_trajectory_controller:
type: "position_controllers/JointTrajectoryController"
joints:
- arm_joint_0
- arm_joint_1
- arm_joint_2
state_publish_rate: 150 sudo apt-get install ros-melodic-usb-cam
roslaunch usb_cam usb_cam-test.launch
self.listener = tf.TransformListener()
self.listener.waitForTransform("base_link", "perception_link", rospy.Time(0), rospy.Duration(2.0))
self.trans, self.rot = self.listener.lookupTransform(target_frame="base_link",
source_frame="perception_link", time=rospy.Time(0))NOTE: The above indicates:- self.trans = translation of the origin of perception_link from base_link
self.rot = rotation of the perception_link frame wrt the base_link frame
Install hrl-kdl
- clone the hrl_kdl repository
git clone https://github.com/gt-ros-pkg/hrl-kdl.git - install pykd_utils
cd hrl-kdl/pykdl_utilspython setup.py buildsudo python setup.py install - install hrl_geom
cd ~/catkin_ws/src/hrl-kdl/hrl_geom/python setup.py buildsudo python setup.py install - install urdf_parser and urdfdom-py
sudo apt-get install ros-melodic-urdf-parser-plugin ros-melodic-urdfdom-py - build the catkin workspace
cd ~/catkin_wscatkin build
The line from pykdl_utils.kdl_kinematics import KDLKinematics needs the folder pykdl_utils inside the root for this line to work
Note: might require sudo apt-get install ros-melodic-python-orocos-kdl
Solution:
Inside ~/.ignition/fuel/config.yaml replace
url: https://api.ignitionfuel.org
by
url: https://api.ignitionrobotics.org
- In the
.bashrc, add the following: export ROS_MASTER_URI=http://192.xxx.1.yyy:11311-
export ROS_IP=192.xxx.1.yyywhere 192.xxx.1.yyy is the ip of the master machine obtained from runningifconfig
- Fire up a
terminaland runexport ROS_MASTER_URI=http://192.xxx.1.yyy:11311andexport ROS_IP=192.xxx.1.zzzwhere zzz is the last number on the ip of the slave machines - The above has to be run in every
terminalsor update the.bashrcwith those two commands
- Set the linux master exactly as above
- Set environment variables in Windows 10 as shown here
- There's a chance that the
pingip address of windows machine wont work from linux master. If needed, reset the firewall settings as described here
- In the terminal on the master machine, run
roscore - Assuming
ROSis set up in the slave machine, open a terminal, runrostopic listand should be able to see/rosout/rosout_agg. This establishes the basic connection - In the master machine, launch anything, for eg:
roslaunch panda_moveit_config demo.launch(assuming franka_ros and MoveIt) - In the slave machine, run
rostopic echo /tf. This should print the transform continuously on the terminal
-
rostopic listworks on the slave machine butrostopic echo /topicdoes not show anything. Discussion here
$ rostopic info /gazebo/model_states
Type: gazebo_msgs/ModelStates
Publishers:
* /gazebo (http://my-workstation:42193/)
Subscribers:
* /rostopic_117_1574085827847 (http://132.11.11.111:40064/)
In the above, Publishers is coming from the master and Subscribers are the slaves. So the slaves are confused what my-workstation is because it was told the master is 132.11.11.111:40064. Solution is to add
132.11.11.111 my-workstation to the end of /etc/hosts.
- Might have to disable firewall on the Ubuntu master
sudo ufw disable
- Instructions here
- Instructions here
<link name="${arm_id}_link2">
<visual>
<material name="blue"/>
<geometry>
<cylinder length="${l2}" radius="${radius}"/>
</geometry>
<origin rpy="0 ${pi/2} 0" xyz="${l2/2} 0 0"/>
##################
_**This rotation of 90 abt y will shift the cylinder axis to x. The translation of l2/2 will shift the CG of cylinder from its geometrical centre to the left edge**_
############
</visual>
<collision>
<geometry>
<cylinder length="${l2}" radius="${radius}"/>
</geometry>
</collision>
<inertial>
<mass value="${massL2}"/>
<inertia ixx="${IL_xx}" ixy="0.0" ixz="0.0" iyy="${IL_yy}" iyz="0.0" izz="${IL_zz}"/>
</inertial>
</link>
<joint name="${arm_id}_joint2" type="revolute">
<safety_controller k_position="100.0" k_velocity="40.0" soft_lower_limit="-1.7628" soft_upper_limit="1.7628"/>
<origin rpy="${pi/2} ${-5*pi/4} 0" xyz="0 0 ${l1+offset2}"/>
#########################
_**Joint axis (i+1) is defined with respect to the previous joint axis (i). In this case, ```i+1``` coord sys is rotated by ```Rx(90)*Ry(-5pi/4)``` and translated along ```z``` by ```l1+offset2``` wrt ```i``` coord sys**_
#############################
<parent link="${arm_id}_link1"/>
<child link="${arm_id}_link2"/>
<axis xyz="0 0 1"/>
<limit effort="87" lower="-1.7628" upper="1.7628" velocity="2.1750"/>
</joint>
-
rosdep install --from-paths src --ignore-src -r -yinside yourcatkin_ws
sudo apt-get install ros-melodic-xacrosudo apt-get install ros-melodic-urdf-tutorial- Create the
robot.xacrofile in yourcatkin_ws/src/package_folder/urdf/ - Create the
robot.urdf.xacrofile which has the following structure
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="free_floating_spacecraft_manipulator_3dof">
<xacro:include filename="$(find free_floating_3_dof_arm)/urdf/free_floating_3dof.xacro" />
<xacro:spacecraft_arm />
</robot>
- Run the command
rosrun xacro xacro --inorder -o free_floating_3dof.urdf free_floating_3dof.urdf.xacroto get the urdf file -
check_urdf free_floating_3dof.urdfto check if your urdf file is successfully parsed -
roslaunch urdf_tutorial display.launch model:='$(find free_floating_3_dof_arm)/urdf/free_floating_3dof.urdf'orroslaunch urdf_tutorial display.launch model:='/path_to_the_folder_containing_urdf/filename.urdf'
Note: Necessay packages need to be installed
catkin_create_pkg simple_navigation_goals geometry_msgs move_base_msgs actionlib roscpp rospy std_msgs
rosrun xacro xacro --inorder -o model.urdf model.urdf.xacro
rosrun tf tf_echo /parent /child_frame
touch /path/to/catkin_ws/your/package/CATKIN_IGNORE
rosrun rqt_tf_tfree rqt_tf_tfree # to see the tf_tree
rosrun rqt_graph rqt_graph # to see the nodes publishing and subscribing to topics
rosrun rqt_logger_level rqt_logger_level # to debug nodes