Skip to content

Commit 4917309

Browse files
author
YH.Wang
committed
1.1.0 Add lock state protection while certain data is processed coping in a normal receiving state to avoid race conditions, and update README.md.
1 parent 38db1a6 commit 4917309

File tree

8 files changed

+45
-14
lines changed

8 files changed

+45
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ This chapter describes that the user can use a script program to extract specifi
123123
- Embedded TM ROS Driver [Usage Guideline](./doc/tm_humble_description_e.md)
124124

125125
**Note 1**: If the user just want to use the TM Robot nominal model to control the robot, the user can skip the rest of this chapter.<br/>
126-
**Note 2**: The tm_description package contains description files and meshes, available for the TM12S model, and some Cobot models will be added later.
126+
**Note 2**: The tm_description package contains description files and meshes, available for the TM5S, TM7S, TM12S, TM14S, and TM25S model, and some Cobot models will be added later.
127127
<div> </div>
128128

129129
## __7. Contact us / Technical support__

doc/tm_humble.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ The user can manually click the `Data Table Setting` <sup>2</sup> item and check
132132
>```
133133
> Example :``ros2 run tm_driver tm_driver robot_ip:=192.168.10.2``, if the <robot_ip_address> is 192.168.10.2
134134
>
135-
> Now, the user can use a new terminal to run each ROS node or command but don't forget to source the correct setup shell files as starting a new terminal.
135+
> Now, the user can use a new terminal to run each ROS node or command, but don't forget to source the correct setup shell files as starting a new terminal.
136136
>
137-
> &#10146; <sup>1</sup> The user can download the TM driver relative ROS apps [Experimental TM2 Humble ROS Apps](https://github.com/TechmanRobotInc/tm2_ros2/tree/humble) of the GitHub repository for ROS applications.
138-
> **Note**: When you are finished, press CTRL + C in all terminal windows to shut everything down.<br/>
137+
> &#10146; <sup>1</sup> The user can download the TM driver relative ROS apps [Experimental TM2 Humble ROS Apps](https://github.com/TechmanRobotInc/tm2_ros2/tree/humble) of the GitHub repository for ROS applications.<br/>
138+
> **Note**: When you have finished, press CTRL + C in all terminal windows to shut everything down.<br/>
139139
<div> </div>
140140
141141
## __3. TMflow Vision node setup and prerequisites for using TM ROS Vision__
@@ -235,7 +235,7 @@ The user can manually click the `Data Table Setting` <sup>2</sup> item and check
235235
> ros2 run image_sub sub_img
236236
> ```
237237
>
238-
> Then, the viewer will display image data from _TMflow_.
239-
**Note**: When you are finished, press CTRL + C in all terminal windows to shut everything down.<br/>
238+
> Then, the viewer will display image data from _TMflow_.<br/>
239+
> **Note**: When you have finished, press CTRL + C in all terminal windows to shut everything down.<br/>
240240
<div> </div>
241241

doc/tm_humble_demo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@ The <robot_ip_address> is the IP address of the TM Robot, the user can get it th
9696
``source ./install/setup.bash``<br/>
9797
``ros2 run demo demo_set_io``<br/>
9898
> :warning:[CAUTION] Some demos will let the TM Robot move, please be careful.<br/>
99-
**Note**: When you are finished, press CTRL + C in all terminal windows to shut everything down.<br/>
99+
**Note**: When you have finished, press CTRL + C in all terminal windows to shut everything down.<br/>
100100
<div> </div>
101101

doc/tm_humble_demo_e.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,6 @@ For example: (select to run demo_set_io)
105105
>> {workspace}$ source ./install/setup.bash
106106
>> {workspace}$ ros2 run demo demo_set_io
107107
>> ```
108-
**Note**: When you are finished, press CTRL + C in all terminal windows to shut everything down.<br/>
108+
**Note**: When you have finished, press CTRL + C in all terminal windows to shut everything down.<br/>
109109
<div> </div>
110110

doc/tm_humble_e.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ The __Listen node__: a socket server can be established and be connected with RO
206206
>
207207
>> **Note**: The <ROS_DOMAIN_ID> is the key to ROS communication and must be the same as the value of _TM Flow 2_ in the _ROS Settings_.<br/>
208208
>
209-
> Then, the viewer will display image data from _TMflow_.
210-
**Note**: When you are finished, press CTRL + C in all terminal windows to shut everything down.<br/>
209+
> Then, the viewer will display image data from _TMflow_.<br/>
210+
> **Note**: When you have finished, press CTRL + C in all terminal windows to shut everything down.<br/>
211211
<div> </div>
212212
213213
## __4. ROS Settings on Configuration__

doc/tm_humble_gui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The <robot_ip_address> is the IP address of the TM Robot, the user can get it th
5757
> 6. In another new terminal: Source setup.bash in the workspace path and start GUI debug by typing<br/>
5858
``source ./install/setup.bash``<br/>
5959
``ros2 run tm_inspect robot_ui``<br/>
60-
**Note**: When you are finished, press CTRL + C in all terminal windows to shut everything down.<br/>
60+
**Note**: When you have finished, press CTRL + C in all terminal windows to shut everything down.<br/>
6161
>
6262
>
6363
<br/>

doc/tm_humble_gui_e.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ This chapter describes a simplified GUI for displaying tm_driver connection stat
5555
``export ROS_DOMAIN_ID=<ROS_DOMAIN_ID>``<br/>
5656
The <ROS_DOMAIN_ID> value of this setting must be the same as the value of TM Flow.<br/>
5757
``ros2 run tm_inspect robot_ui``<br/>
58-
**Note**: When you are finished, press CTRL + C in all terminal windows to shut everything down.<br/>
58+
**Note**: When you have finished, press CTRL + C in all terminal windows to shut everything down.<br/>
5959
>
6060
For example:
6161
>> Assume the domain ID is set to 30 and the embedded TM ROS driver is successfully enabled on _Tmflow 2_. If the user has successfully built the specific code (tm2_ros2) before, now the user only needs to open a new terminal, and set the path to the TM driver workspace ``cd ~/tm2_ws``, then type the following command to start the debug GUI.<br/>

tm_driver/src/tm_ros2_svr.cpp

100755100644
Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,22 @@ void TmSvrRos2::publish_fbs()
7171
{
7272
PubMsg &pm = pm_;
7373
TmRobotState &state = state_;
74+
bool fbs_lock_ = false; /* MC-001: modify */
75+
76+
// Modifications based on suggestions from Collaborators (remark as MC-list)
77+
/* MC-001:start */
78+
if(state.get_receive_state() != TmCommRC::TIMEOUT) {
79+
fbs_lock_ = true;
80+
state.mtx_lock();
81+
}
82+
/* MC-001:end */
7483

7584
// Publish feedback state
7685
pm.fbs_msg.header.stamp = node->rclcpp::Node::now();
7786
if(state.get_receive_state() != TmCommRC::TIMEOUT){
7887
pm.fbs_msg.is_svr_connected = svr_.is_connected();
7988
pm.fbs_msg.is_sct_connected = sct_.is_connected() && iface_.is_on_listen_node();
80-
pm.fbs_msg.tmsrv_cperr = (int)svr_.tmSvrErrData.error_code(); //Node State Response
89+
pm.fbs_msg.tmsrv_cperr = (int)svr_.tmSvrErrData.error_code(); // Node State Response
8190
pm.fbs_msg.tmsrv_dataerr = (int)pm.svr_msg.error_code;
8291
pm.fbs_msg.tmscript_cperr = (int)sct_.tmSctErrData.error_code();
8392
pm.fbs_msg.tmscript_dataerr = (int)sct_.sct_data.sct_has_error();
@@ -130,6 +139,14 @@ void TmSvrRos2::publish_fbs()
130139
pm.fbs_msg.joint_tor_average = state.joint_torque_average();
131140
pm.fbs_msg.joint_tor_min = state.joint_torque_min();
132141
pm.fbs_msg.joint_tor_max = state.joint_torque_max();
142+
143+
/* MC-001:start */
144+
if((state.get_receive_state() != TmCommRC::TIMEOUT) || (fbs_lock_ != false)) {
145+
state.mtx_unlock();
146+
fbs_lock_ = false;
147+
}
148+
/* MC-001:end */
149+
133150
pm.fbs_pub->publish(pm.fbs_msg);
134151

135152
// Publish joint state
@@ -148,22 +165,36 @@ void TmSvrRos2::publish_fbs()
148165
pm.tool_pose_msg.pose.position.y = pose[1];
149166
pm.tool_pose_msg.pose.position.z = pose[2];
150167
pm.tool_pose_msg.pose.orientation = tf2::toMsg(quat);
151-
pm.tool_pose_pub->publish(pm.tool_pose_msg);*/
168+
pm.tool_pose_pub->publish(pm.tool_pose_msg); */
152169
}
153170
void TmSvrRos2::fake_publisher()
154171
{
155172
PubMsg &pm = pm_;
156173
TmRobotState &state = state_;
174+
bool fbs_lock_ = false; /* MC-001: modify */
157175

158176
print_info("TM_ROS: fake publisher thread begin");
159177

160178
while (rclcpp::ok()) {
161179
// Publish feedback state
162180
pm.fbs_msg.header.stamp = node->rclcpp::Node::now();
163181
{
182+
/* MC-001:start */
183+
if(state.get_receive_state() != TmCommRC::TIMEOUT) {
184+
fbs_lock_ = true;
185+
state.mtx_lock();
186+
}
187+
/* MC-001:end */
164188
pm.fbs_msg.joint_pos = state.joint_angle();
165189
pm.fbs_msg.joint_vel = state.joint_speed();
166190
pm.fbs_msg.joint_tor = state.joint_torque();
191+
192+
/* MC-001:start */
193+
if((state.get_receive_state() != TmCommRC::TIMEOUT) || (fbs_lock_ != false)) {
194+
state.mtx_unlock();
195+
fbs_lock_ = false;
196+
}
197+
/* MC-001:end */
167198
}
168199
pm.fbs_pub->publish(pm.fbs_msg);
169200

0 commit comments

Comments
 (0)