Skip to content

Commit 97191d0

Browse files
committed
the dots move now
1 parent a8e4151 commit 97191d0

File tree

3 files changed

+81
-31
lines changed

3 files changed

+81
-31
lines changed

docker_tester

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
matplotlib==3.1.2
2+
NavPy==1.0
3+
numba==0.58.0
4+
numpy<1.21.0
5+
osqp==0.6.3
6+
pandas==2.0.3
7+
pyembree==0.2.11
8+
pymap3d==3.0.1
9+
scipy==1.10.1
10+
trimesh==3.23.5
11+
utm==0.7.0
12+
keyboard==0.13.5
13+
tk==0.1.0

rb_ws/src/buggy/buggy/simulator/engine.py

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313

1414
class Simulator(Node):
1515
# simulator constants:
16+
UTM_EAST_ZERO = 589702.87
17+
UTM_NORTH_ZERO = 4477172.947
18+
UTM_ZONE_NUM = 17
19+
UTM_ZONE_LETTER = "T"
20+
#TODO: make these values accurate
21+
WHEELBASE_SC = 1.17
22+
WHEELBASE_NAND= 1.17
1623

1724
def __init__(self):
1825
super().__init__('sim_single')
19-
UTM_EAST_ZERO = 589702.87
20-
UTM_NORTH_ZERO = 4477172.947
21-
UTM_ZONE_NUM = 17
22-
UTM_ZONE_LETTER = "T"
23-
#TODO: make these values accurate
24-
WHEELBASE_SC = 1.17
25-
WHEELBASE_NAND= 1.17
26+
self.get_logger().info('INITIALIZED.')
2627

2728
self.starting_poses = {
2829
"Hill1_NAND": (Simulator.UTM_EAST_ZERO + 0, Simulator.UTM_NORTH_ZERO + 0, -110),
@@ -60,19 +61,22 @@ def __init__(self):
6061
)
6162
if (self.get_namespace() == "/SC"):
6263
self.buggy_name = "SC"
63-
init_pose = self.starting_poses["Hill_1SC"]
64-
64+
init_pose = self.starting_poses["Hill1_SC"]
65+
self.wheelbase = Simulator.WHEELBASE_SC
6566

6667
if (self.get_namespace() == "/NAND"):
6768
self.buggy_name = "NAND"
68-
init_pose = self.starting_poses["Hill_1NAND"]
69+
init_pose = self.starting_poses["Hill1_NAND"]
70+
self.wheelbase = Simulator.WHEELBASE_NAND
71+
6972

7073
self.e_utm, self.n_utm, self.heading = init_pose
7174
# TODO: do we want to not hard code this
7275
self.velocity = 12 # m/s
7376
self.steering_angle = 0 # degrees
7477
self.rate = 200 # Hz
7578
self.pub_skip = 2 # publish every pub_skip ticks
79+
self.pub_tick_count = 0
7680

7781
self.lock = threading.Lock()
7882

@@ -97,7 +101,7 @@ def get_steering_arc(self):
97101
return Simulator.WHEELBASE / np.tan(np.deg2rad(steering_angle))
98102

99103
def dynamics(self, state, v):
100-
l = Simulator.WHEELBASE
104+
l = self.wheelbase
101105
_, _, theta, delta = state
102106

103107
return np.array([v * np.cos(theta),
@@ -151,49 +155,50 @@ def publish(self):
151155
nsf = NavSatFix()
152156
nsf.latitude = lat
153157
nsf.longitude = long
154-
nsf.altitude = 260
158+
nsf.altitude = float(260)
155159
nsf.header.stamp = time_stamp
156-
self.navsatfix_publisher.publish(nsf)
157160

158-
if Simulator.NOISE:
159-
lat_noisy = lat + np.random.normal(0, 1e-6)
160-
long_noisy = long + np.random.normal(0, 1e-6)
161-
nsf_noisy = NavSatFix()
162-
nsf_noisy.latitude = lat_noisy
163-
nsf_noisy.longitude = long_noisy
164-
nsf_noisy.header.stamp = time_stamp
165-
self.navsatfix_noisy_publisher.publish(nsf_noisy)
161+
lat_noisy = lat + np.random.normal(0, 1e-6)
162+
long_noisy = long + np.random.normal(0, 1e-6)
163+
nsf_noisy = NavSatFix()
164+
nsf_noisy.latitude = lat_noisy
165+
nsf_noisy.longitude = long_noisy
166+
nsf_noisy.header.stamp = time_stamp
167+
self.navsatfix_noisy_publisher.publish(nsf_noisy)
166168

167169
odom = Odometry()
168170
odom.header.stamp = time_stamp
169171

170172
odom_pose = Pose()
171-
odom_pose.position.x = long
172-
odom_pose.position.y = lat
173-
odom_pose.position.z = 260
173+
odom_pose.position.x = float(long)
174+
odom_pose.position.y = float(lat)
175+
odom_pose.position.z = float(260)
174176

175177
odom_pose.orientation.z = np.sin(np.deg2rad(self.heading) / 2)
176178
odom_pose.orientation.w = np.cos(np.deg2rad(self.heading) / 2)
177179

178180
odom_twist = Twist()
179-
odom_twist.linear.x = velocity
181+
odom_twist.linear.x = float(velocity)
180182

181183
odom.pose = PoseWithCovariance(pose=odom_pose)
182184
odom.twist = TwistWithCovariance(twist=odom_twist)
183185

184186
self.pose_publisher.publish(odom)
185187

186188
def loop(self):
187-
rate = self.create_rate(self.rate)
188-
pub_tick_count = 0
189+
msg = Float64()
190+
msg.data = float(self.i)
189191

190-
self.step()
192+
self.number_publisher.publish(msg)
193+
self.i += 1
191194

192-
if pub_tick_count == self.pub_skip:
195+
self.step()
196+
if self.pub_tick_count == self.pub_skip:
193197
self.publish()
194-
pub_tick_count = 0
198+
self.pub_tick_count = 0
195199
else:
196-
pub_tick_count += 1
200+
self.pub_tick_count += 1
201+
197202

198203

199204

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#! /usr/bin/env python3
2+
import sys
3+
import time
4+
import rclpy
5+
from std_msgs.msg import String
6+
7+
class Simulator():
8+
# simulator constants:
9+
10+
def __init__(self):
11+
self.test_publisher = self.create_publisher(String, 'test', 10)
12+
if (self.get_namespace() == "SC"):
13+
self.buggy_name = "SC"
14+
15+
if (self.get_namespace() == "NAND"):
16+
self.buggy_name = "NAND"
17+
18+
def loop(self):
19+
print("hello")
20+
self.test_publisher.publish(self.buggy_name)
21+
22+
if __name__ == "__main__":
23+
rclpy.init()
24+
sim = Simulator()
25+
26+
# publish initial position, then sleep
27+
# so that auton stack has time to initialize
28+
# before buggy moves
29+
time.sleep(15.0)
30+
sim.loop()
31+
32+

0 commit comments

Comments
 (0)