Skip to content

Commit 01842b2

Browse files
authored
Merge pull request #2 from N-rwal/arm
Arm
2 parents 292dbba + 5652369 commit 01842b2

File tree

10 files changed

+168
-286
lines changed

10 files changed

+168
-286
lines changed

go2_robot_sdk/config/nav2_params_navigation.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ amcl:
1818
laser_min_range: 0.12
1919
laser_model_type: "likelihood_field"
2020
max_beams: 90
21-
max_particles: 1500
22-
min_particles: 400
21+
max_particles: 800
22+
min_particles: 200
2323
odom_frame_id: "odom"
2424
pf_err: 0.05
2525
pf_z: 0.99
@@ -95,19 +95,19 @@ controller_server:
9595
general_goal_checker:
9696
stateful: True
9797
plugin: "nav2_controller::SimpleGoalChecker"
98-
xy_goal_tolerance: 0.25
99-
yaw_goal_tolerance: 0.25
98+
xy_goal_tolerance: 0.4
99+
yaw_goal_tolerance: 0.2
100100
# DWB parameters
101101
FollowPath:
102102
plugin: "dwb_core::DWBLocalPlanner"
103103
debug_trajectory_details: True
104104
min_vel_x: 0.0
105105
min_vel_y: 0.0
106-
max_vel_x: 3.0 #changed
107-
max_vel_y: 0.0
108-
max_vel_theta: 3.0 #changed
106+
max_vel_x: 2.0 #changed
107+
max_vel_y: -1.0
108+
max_vel_theta: 1.0
109109
min_speed_xy: 0.0
110-
max_speed_xy: 3.0 #changed
110+
max_speed_xy: 3.0
111111
min_speed_theta: 0.0
112112
# Add high threshold velocity for turtlebot 3 issue.
113113
# https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/75
@@ -124,7 +124,7 @@ controller_server:
124124
linear_granularity: 0.05
125125
angular_granularity: 0.025
126126
transform_tolerance: 0.2
127-
xy_goal_tolerance: 0.3 #changed
127+
xy_goal_tolerance: 0.4
128128
trans_stopped_velocity: 0.25
129129
short_circuit_trajectory_evaluation: True
130130
stateful: True
@@ -151,12 +151,12 @@ local_costmap:
151151
width: 5
152152
height: 5
153153
resolution: 0.05
154-
footprint: "[[-0.25, -0.15], [-0.25, 0.15], [0.25, 0.15], [0.25, -0.15]]"
154+
footprint: "[[-0.30, -0.20], [-0.30, 0.20], [0.30, 0.20], [0.30, -0.20]]"
155155
plugins: ["voxel_layer", "inflation_layer"]
156156
inflation_layer:
157157
plugin: "nav2_costmap_2d::InflationLayer"
158-
cost_scaling_factor: 1.5
159-
inflation_radius: 0.35
158+
cost_scaling_factor: 3.5
159+
inflation_radius: 0.60
160160
voxel_layer:
161161
plugin: "nav2_costmap_2d::VoxelLayer"
162162
enabled: True
@@ -190,7 +190,7 @@ global_costmap:
190190
publish_frequency: 2.0
191191
global_frame: map
192192
robot_base_frame: base_link
193-
footprint: "[[-0.25, -0.15], [-0.25, 0.15], [0.25, 0.15], [0.25, -0.15]]"
193+
footprint: "[[-0.30, -0.20], [-0.30, 0.20], [0.30, 0.20], [0.30, -0.20]]"
194194
width: 100
195195
height: 100
196196
resolution: 0.05
@@ -215,8 +215,8 @@ global_costmap:
215215
map_subscribe_transient_local: True
216216
inflation_layer:
217217
plugin: "nav2_costmap_2d::InflationLayer"
218-
cost_scaling_factor: 1.5
219-
inflation_radius: 0.35
218+
cost_scaling_factor: 3.5
219+
inflation_radius: 0.60
220220
always_send_full_costmap: True
221221

222222
# The yaml_filename does not need to be specified since it going to be set by defaults in launch.
@@ -298,8 +298,8 @@ velocity_smoother:
298298
smoothing_frequency: 20.0
299299
scale_velocities: False
300300
feedback: "OPEN_LOOP"
301-
max_velocity: [0.5, 0.0, 1.0]
302-
min_velocity: [-0.5, 0.0, -1.0]
301+
max_velocity: [0.5, 0.0, 1.5]
302+
min_velocity: [-0.5, 0.0, -1.5]
303303
max_accel: [1.5, 0.0, 2.0]
304304
max_decel: [-1.5, 0.0, -2.0]
305305
odom_topic: "odom"

go2_robot_sdk/go2_robot_sdk/initial_pose_pub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def __init__(self):
1111
def publish_pose(self):
1212
msg = PoseWithCovarianceStamped()
1313
msg.header.frame_id = 'map'
14-
msg.pose.pose.position.x = 1.0
15-
msg.pose.pose.position.y = 2.0
14+
msg.pose.pose.position.x = 0.0
15+
msg.pose.pose.position.y = -1.0
1616
msg.pose.pose.orientation.z = 0.0
1717
msg.pose.pose.orientation.w = 1.0
1818
msg.pose.covariance = [0.0] * 36
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python3
2+
import rclpy
3+
from rclpy.node import Node
4+
from std_srvs.srv import SetBool
5+
import subprocess
6+
7+
class NavController(Node):
8+
def __init__(self):
9+
super().__init__('nav_controller')
10+
self.srv = self.create_service(SetBool, 'nav_control', self.callback)
11+
self.test_running = False
12+
self.get_logger().info('Nav controller ready')
13+
self.get_logger().info('Start test: ros2 service call /nav_control std_srvs/srv/SetBool "{data: true}"')
14+
15+
def callback(self, request, response):
16+
if request.data and not self.test_running:
17+
self.test_running = True
18+
self.get_logger().info('Starting navigation test...')
19+
20+
result = subprocess.run(
21+
['ros2', 'run', 'go2_robot_sdk', 'sequential_nav_test'],
22+
capture_output=True,
23+
text=True
24+
)
25+
26+
self.test_running = False
27+
response.success = True
28+
response.message = f'Test completed. Output: {result.stdout[:100]}...'
29+
30+
elif not request.data and self.test_running:
31+
#could add stop logic here
32+
response.success = True
33+
response.message = 'Stop requested'
34+
else:
35+
response.success = False
36+
response.message = 'Already in requested state'
37+
38+
return response
39+
40+
def main():
41+
rclpy.init()
42+
rclpy.spin(NavController())
43+
rclpy.shutdown()
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env python3
2+
3+
import math
4+
import time
5+
6+
import rclpy
7+
from rclpy.node import Node
8+
from rclpy.action import ActionClient
9+
10+
from nav2_msgs.action import NavigateToPose
11+
from geometry_msgs.msg import PoseStamped
12+
#from tf_transformations import quaternion_from_euler
13+
14+
15+
class SequentialNavTest(Node):
16+
def __init__(self):
17+
super().__init__('sequential_nav_test')
18+
19+
self.client = ActionClient(self, NavigateToPose, 'navigate_to_pose')
20+
21+
self.get_logger().info('Waiting for Nav2 action server...')
22+
self.client.wait_for_server()
23+
self.get_logger().info('Nav2 action server ready')
24+
25+
self.run_sequence()
26+
27+
def make_pose(self, x, y, yaw):
28+
pose = PoseStamped()
29+
pose.header.frame_id = 'map'
30+
pose.header.stamp = self.get_clock().now().to_msg()
31+
32+
pose.pose.position.x = x
33+
pose.pose.position.y = y
34+
35+
pose.pose.orientation.z = math.sin(yaw / 2.0)
36+
pose.pose.orientation.w = math.cos(yaw / 2.0)
37+
38+
return pose
39+
40+
def send_goal(self, pose):
41+
goal = NavigateToPose.Goal()
42+
goal.pose = pose
43+
44+
future = self.client.send_goal_async(goal)
45+
rclpy.spin_until_future_complete(self, future)
46+
47+
goal_handle = future.result()
48+
if not goal_handle.accepted:
49+
self.get_logger().error('Goal rejected')
50+
return False
51+
52+
self.get_logger().info('Goal accepted, waiting for result...')
53+
result_future = goal_handle.get_result_async()
54+
rclpy.spin_until_future_complete(self, result_future)
55+
56+
return True
57+
58+
def run_sequence(self):
59+
i = 0
60+
for i in range (0,2):
61+
self.send_goal(self.make_pose(-1.61775, 17.2127, 1.70432)) #main entrance
62+
time.sleep(1.0)
63+
self.send_goal(self.make_pose(9.57915, 19.4981, -1.21812)) #front main entrance
64+
time.sleep(1.0)
65+
self.send_goal(self.make_pose(-1.61775, 17.2127, 2.36622)) #main entrance
66+
time.sleep(1.0)
67+
self.send_goal(self.make_pose(2.27953, -1.53849, -1.41637)) #second hall
68+
time.sleep(1.0)
69+
self.send_goal(self.make_pose(12.5844, 1.70121, -1.21812)) #front second entrance
70+
time.sleep(1.0)
71+
self.send_goal(self.make_pose(2.27953, -1.53849, 2.36622)) #second hall
72+
time.sleep(1.0)
73+
74+
75+
#self.send_goal(self.make_pose(20.0, 20.0, math.pi))
76+
#time.sleep(1.0)
77+
#self.send_goal(self.make_pose(15.0, 15.0, math.pi))
78+
79+
def main():
80+
rclpy.init()
81+
node = SequentialNavTest()
82+
rclpy.shutdown()
83+
84+
if __name__ == '__main__':
85+
main()
86+
87+

go2_robot_sdk/initial_pose_pub.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)