I am attempting to add code to read from the hSens1.pin2 line which will then get published as a topic. When I do the catkin_make I get errors that it cannot resolve hSens1. I then added in #include <hFramework.h> to resolve this error, but then get a different error indicating it cannot find hFramework.h. Next, I did a git clone of GitHub - husarion/hFramework: hFramework is a library for creating real-time software for robotic & mechatronic devices thinking that would install the needed files. However, I am still getting this error. Thoughts on what I may have missed?
Thanks,
bobg
Please show the code that you added and the file location
The following code was added in the
/home/husarion/ros_workspace/src/rosbot_webui/src/
folder where pose_to_tf.cpp and tf_to_pose.cpp files are which similarlly publish nodes/topics.
#include <ros/ros.h>
#include <std_msgs/Bool.h>
#include <hFramework.h> //this is the line added in to resolve the hSens1.pin2 reference
std_msgs::Bool button;
ros::Publisher button_pub;
bool last_reading;
ros::Time last_debounce_time;
ros::Duration debounce_delay(0.05);
bool published = true;
void buttonProcess(void)
{
bool reading = ! hSens1.pin2.read();
if (last_reading!= reading){
last_debounce_time = ros::Time::now();
published = false;
}
//if the button value has not changed for the debounce delay, we know its stable
if ( !published && ((ros::Time::now() - last_debounce_time) > debounce_delay)) {
button.data = reading;
button_pub.publish(button);
published = true;
}
last_reading = reading;
}
int main(int argc, char **argv)
{
ros::init(argc, argv, “button_push”);
ros::NodeHandle node;
ros::Rate loop_rate(10);
button_pub = node.advertise<std_msgs::Bool>("/next_op",1);
hSens1.pin2.setIn_pu();
last_reading = ! hSens1.pin2.read();
while(ros::ok()) {
buttonProcess();
ros::spinOnce();
loop_rate.sleep();
}
return 0;
};
Thanks,
bobg
Hi bgrabon,
The files that you have in /home/husarion/ros_workspace/src/rosbot_webui/src/
are to be compiled and launched on linux.
The hFramework
is available only for CORE2 controller. Process of building code for CORE2 controller and publishing messages is covered in our ROS tutorial #3.
Thanks. I had mistakenly thought the hFramework was accessible at the linux level. I now understand that when you want to access the lower level I/O from CORE2 you need to published there, THEN the higher level linux can subscribe to those newly published nodes/topics.
bobg