Skip to content

Commit a9eb72c

Browse files
authored
[protocol_v3_example.cpp] Add haptic feedback protocol information.
1 parent 27a4d6e commit a9eb72c

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

protocol_v3_example.cpp

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/**
2-
A slightly upgraded version of packet 2 with two additions:
3-
- Packet version, so that from now on the patient side can also distingish what is being received.
4-
- Data of any number of additional key states added to the configuration.json.
2+
This is the information obtained from the haptic interface.
53
*/
6-
void UDPSender::send_packet_version_3()
4+
void send_manipulator_information_packet_version_3()
75
{
86
QByteArray buffer;
97
QDataStream s(&buffer, QIODevice::WriteOnly);
@@ -73,3 +71,33 @@ void UDPSender::send_packet_version_3()
7371
}
7472
}
7573
}
74+
75+
76+
/**
77+
This is the "force" feedback information sent to the haptic interface.
78+
*/
79+
void send_manipulator_force_information_packet_version_3()
80+
{
81+
QByteArray buffer_out;
82+
QDataStream s(&buffer_out,QIODevice::WriteOnly);
83+
s << packet_version;
84+
s << computer_index;
85+
s << number_of_manipulators;
86+
87+
for(auto i=0;i<number_of_manipulators;i++)
88+
{
89+
s << quint16(1);//Manipulator valid
90+
s << float(force_x) <<
91+
float(force_y) <<
92+
float(force_z) <<
93+
float(torque_x) <<
94+
float(torque_y) <<
95+
float(torque_z);
96+
}
97+
98+
quint16 crc16_out = qChecksum(buffer_out,buffer_out.size());
99+
s << (quint16)crc16_out;
100+
101+
//Do something with the s
102+
}
103+

0 commit comments

Comments
 (0)