Skip to content

Commit 883ae27

Browse files
committed
upload mse_calc, to calculate the error with respect to reference.
1 parent 072c625 commit 883ae27

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 2.8.3)
2-
project(slam_mcmc)
2+
project(MCL_PI)
33

44
## Compile as C++11, supported in ROS Kinetic and newer
55
# add_compile_options(-std=c++11)

launch/mse_calc.launch

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
3+
<launch>
4+
5+
<node name="mse_calc_armadillo" pkg="MCL_PI" type="mse_calc.py" output="screen">
6+
<remap from="/vrpn_client_node/robot_name/pose" to="/vrpn_client_node/armadillo/pose"/>
7+
<remap from="/reference_pose" to="/armadillo/reference_pose"/>
8+
<remap from="/particlecloud" to="/armadillo/particlecloud"/>
9+
<remap from="/Expection" to="/armadillo/Expection"/>
10+
</node>
11+
12+
<node name="mse_calc_komodo" pkg="MCL_PI" type="mse_calc.py" output="screen">
13+
<remap from="/vrpn_client_node/robot_name/pose" to="/vrpn_client_node/komodo/pose"/>
14+
<remap from="/reference_pose" to="/komodo/reference_pose"/>
15+
<remap from="/particlecloud" to="/komodo/particlecloud"/>
16+
<remap from="/Expection" to="/komodo/Expection"/>
17+
</node>
18+
19+
</launch>

optitrack/launch/optitrack.launch

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
3+
<launch>
4+
<arg name="server" default="192.168.0.103"/>
5+
<node pkg="vrpn_client_ros" type="vrpn_client_node" name="vrpn_client_node" output="screen">
6+
<rosparam subst_value="true">
7+
server: $(arg server)
8+
port: 3883
9+
frame_id: world
10+
broadcast_tf: true
11+
# Must either specify refresh frequency > 0.0, or a list of trackers to create
12+
refresh_tracker_frequency: 100.0
13+
trackers:
14+
- '1'
15+
- '2'
16+
</rosparam>
17+
</node>
18+
</launch>

particle_filter/mse_calc.py

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python
2+
3+
import rospy
4+
import numpy as np
5+
from geometry_msgs.msg import PoseStamped, Point, Pose, PointStamped, PoseArray
6+
import tf_conversions
7+
8+
class Reference(object):
9+
10+
def __init__(self):
11+
self.p = rospy.Publisher('/reference_pose', PointStamped, queue_size = 6)
12+
rospy.Subscriber('/vrpn_client_node/robot_name/pose', PoseStamped, self.get_reference)
13+
rospy.wait_for_message('/vrpn_client_node/robot_name/pose', PoseStamped)
14+
15+
16+
def get_reference(self, msg):
17+
self.reference = np.empty(2)
18+
reference_point = msg
19+
20+
self.reference[0] = reference_point.pose.position.x
21+
self.reference[1] = reference_point.pose.position.y
22+
23+
point = PointStamped()
24+
point.header.frame_id = "map"
25+
point.point.x = self.reference[0]
26+
point.point.y = self.reference[1]
27+
point.point.z = 0
28+
self.p.publish(point)
29+
30+
class Particles(object):
31+
32+
def __init__(self):
33+
rospy.Subscriber('/particlecloud', PoseArray, self.particlecloud)
34+
rospy.wait_for_message('/particlecloud', PoseArray)
35+
36+
def particlecloud(self,msg): # callback function from topic /particlecloud
37+
self.particles = np.empty((len(msg.poses),3))
38+
for i in range(len(msg.poses)):
39+
self.particles[i,0] = msg.poses[i].position.x
40+
self.particles[i,1] = msg.poses[i].position.y
41+
angle = (
42+
msg.poses[i].orientation.x,
43+
msg.poses[i].orientation.y,
44+
msg.poses[i].orientation.z,
45+
msg.poses[i].orientation.w)
46+
self.particles[i,2] = tf_conversions.transformations.euler_from_quaternion(angle)[2]
47+
48+
def main():
49+
r = Reference()
50+
p = Particles()
51+
52+
while not rospy.is_shutdown():
53+
54+
reference_point = r.reference
55+
E = np.mean(p.particles, axis=0)
56+
57+
Error = np.linalg.norm(np.abs(E[0:2]-reference_point))
58+
59+
E_pub = rospy.Publisher('/Expection', PointStamped, queue_size = 6)
60+
point = PointStamped()
61+
point.header.frame_id = "map"
62+
point.point.x = E[0]
63+
point.point.y = E[1]
64+
point.point.z = 0
65+
E_pub.publish(point)
66+
67+
if __name__ == "__main__":
68+
rospy.init_node('mse_calc')
69+
main()
70+
71+
rospy.spin()

0 commit comments

Comments
 (0)