Catkin code to interface RFT60-HA01 sensor via catkin workspace to a ROS node.
Before you start your journey of making and building different stacks, it's essential to familiarize yourself with the following tools:
- Rosdep: Rosdep on ROS Wiki
- Synaptic
- If ROS has been set up from source, remember to source the setup script:
source ~/ros_catkin_ws/install_isolated/setup.bash
- Add the sourcing script to your .bashrc to make it permanent:
echo 'source ~/ros_catkin_ws/install_isolated/setup.bash' >> ~/.bashrc
- Source the .bashrc file to apply the changes:
source ~/.bashrc
mick@mick-Predator-PHN16-71:~/catkin_ft$ rosparam set /RFT_COM_PORT /dev/ttyUSB0
mick@mick-Predator-PHN16-71:~/catkin_ft$ rosparam set /RFT_TORQUE_DEVIDER 1000
mick@mick-Predator-PHN16-71:~/catkin_ft$ rosrun rft_sensor_serial rft_sensor_serial
If there is error even after package got built, then go to the Common Errors section.
- Starting rqt-service caller:
mick@mick-Predator-PHN16-71:~/catkin_ft$ source devel/setup.bash
mick@mick-Predator-PHN16-71:~/catkin_ft$ rosrun rqt_service_caller rqt_service_caller
mick@mick-Predator-PHN16-71:~/catkin_ft$ rostopic echo /RFT_Force
- Run the sensor and get data on rostopic.
#Important Key Points
-
Building ROS from Source: Ensure ROS is built from the source for proper integration.
-
Sourcing ROS: Always remember to source ROS; it's crucial. Alternatively, add it to ~/.bashrc.
-
Using Rosdep: Utilize rosdep to install all necessary dependencies efficiently.
-
Port Access: Check if your port is locked by another process or if you lack access permissions.
#Common Errors
Example of a common error encountered:
mick@mick-Predator-PHN16-71:~/catkin_ft$ source devel/setup.bash
mick@mick-Predator-PHN16-71:~/catkin_ft$ rosrun rft_sensor_serial rft_sensor_serial
[ INFO] [1713562305.371650824]: RFT Serial port: /dev/ttyUSB0
[ INFO] [1713562305.372459789]: RFT Serial port baud-rate: 115200
[ INFO] [1713562305.372557372]: Force Divider of RFT sensor: 50.000000
[ INFO] [1713562305.372640026]: Torque Divider of RFT sensor: 1000.000000
[ERROR] [1713562305.372774309]: COM Port Open Error
#Resolving Errors
Steps to resolve port access issues:
mick@mick-Predator-PHN16-71:~/catkin_ft$ sudo chmod 666 /dev/ttyUSB0
mick@mick-Predator-PHN16-71:~/catkin_ft$ sudo usermod -a -G dialout $USER
mick@mick-Predator-PHN16-71:~/catkin_ft$ lsof | grep ttyUSB0
mick@mick-Predator-PHN16-71:~/catkin_ft$ source devel/setup.bash
#Successful Configuration
Output after resolving the issue:
mick@mick-Predator-PHN16-71:~/catkin_ft$ rosrun rft_sensor_serial rft_sensor_serial
[ INFO] [1713562410.453484136]: RFT Serial port: /dev/ttyUSB0
[ INFO] [1713562410.453849304]: RFT Serial port baud-rate: 115200
[ INFO] [1713562410.454102646]: Force Divider of RFT sensor: 50.000000
[ INFO] [1713562410.454469397]: Torque Divider of RFT sensor: 1000.000000
[ INFO] [1713562410.456895889]: RFT Force/Torque Sensor <Serial> is ready!!!!
-
Complete till the step 7 of Method 1
-
Call rosservice /rft_serial_op_service and pass the params from the image in step 9 into the input parameters.
To start the communication
mick@mick-Predator-PHN16-71:~/Robotous_FT_RFT60/catkin_ft$ rosservice call /rft_serial_op_service "{opType: 11, param1: 0, param2: 0, param3: 0}"
To automatically set the bias values
mick@mick-Predator-PHN16-71:~/Robotous_FT_RFT60/catkin_ft$ rosservice call /rft_serial_op_service "{opType: 17, param1: 1, param2: 0, param3: 0}"
To stop the service:
mick@mick-Predator-PHN16-71:~/Robotous_FT_RFT60/catkin_ft$ rosservice call /rft_serial_op_service "{opType: 12, param1: 0, param2: 0, param3: 0}"
-
Echo the topic to see the F/T data being published
-
mick@mick-Predator-PHN16-71:~/Robotous_FT_RFT60/catkin_ft$ rostopic list mick@mick-Predator-PHN16-71:~/Robotous_FT_RFT60/catkin_ft$ rostopic echo /RFT_FORCE
-
Making a simple bash script to automate this is preferred. A simple one named rft_rosservice.sh is created and the following commands added to it
#!/bin/bash # roscore in the background roscore & # Source the FT sensor workspace source ~/Robotous_FT_RFT60/catkin_ft/devel/setup.bash # Set the necessary parameters rosparam set /RFT_COM_PORT /dev/ttyUSB0 rosparam set /RFT_TORQUE_DEVIDER 1000 # Run the rft_sensor_serial node in the background rosrun rft_sensor_serial rft_sensor_serial & # Capture the process ID of the background job NODE_PID=$! # Function to stop the service and clean up cleanup() { rosservice call /rft_serial_op_service "{opType: 12, param1: 0, param2: 0, param3: 0}" kill $NODE_PID } # Set trap to catch termination signals and run cleanup trap cleanup SIGINT SIGTERM # Wait for the node to initialize sleep 2 # Set bias values rosservice call /rft_serial_op_service "{opType: 17, param1: 1, param2: 0, param3: 0}" # Start communication rosservice call /rft_serial_op_service "{opType: 11, param1: 0, param2: 0, param3: 0}" # Echo the topic rostopic echo /RFT_FORCE # Wait indefinitely until the script is terminated wait $NODE_PID